2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2009 Sam Lantinga
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "SDL_config.h"
32 #include "SDL_mutex.h"
33 #include "SDL_sysmutex_c.h"
36 SDL_mutex *SDL_CreateMutex(void)
40 /* Allocate mutex memory */
41 mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
43 /* Create the mutex, with initial value signaled */
44 if (!pth_mutex_init(&(mutex->mutexpth_p))) {
45 SDL_SetError("Couldn't create mutex");
56 void SDL_DestroyMutex(SDL_mutex *mutex)
64 int SDL_mutexP(SDL_mutex *mutex)
66 if ( mutex == NULL ) {
67 SDL_SetError("Passed a NULL mutex");
71 pth_mutex_acquire(&(mutex->mutexpth_p), FALSE, NULL);
76 /* Unlock the mutex */
77 int SDL_mutexV(SDL_mutex *mutex)
79 if ( mutex == NULL ) {
80 SDL_SetError("Passed a NULL mutex");
84 pth_mutex_release(&(mutex->mutexpth_p));