Lines Matching refs:mutex
42 SDL_mutex *mutex; in SDL_CreateMutex() local
45 mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); in SDL_CreateMutex()
46 if (mutex) { in SDL_CreateMutex()
48 mutex->sem = SDL_CreateSemaphore(1); in SDL_CreateMutex()
49 mutex->recursive = 0; in SDL_CreateMutex()
50 mutex->owner = 0; in SDL_CreateMutex()
51 if (!mutex->sem) { in SDL_CreateMutex()
52 SDL_free(mutex); in SDL_CreateMutex()
53 mutex = NULL; in SDL_CreateMutex()
58 return mutex; in SDL_CreateMutex()
63 SDL_DestroyMutex(SDL_mutex * mutex) in SDL_DestroyMutex() argument
65 if (mutex) { in SDL_DestroyMutex()
66 if (mutex->sem) { in SDL_DestroyMutex()
67 SDL_DestroySemaphore(mutex->sem); in SDL_DestroyMutex()
69 SDL_free(mutex); in SDL_DestroyMutex()
75 SDL_mutexP(SDL_mutex * mutex) in SDL_mutexP() argument
82 if (mutex == NULL) { in SDL_mutexP()
87 if (mutex->owner == this_thread) { in SDL_mutexP()
88 ++mutex->recursive; in SDL_mutexP()
94 SDL_SemWait(mutex->sem); in SDL_mutexP()
95 mutex->owner = this_thread; in SDL_mutexP()
96 mutex->recursive = 0; in SDL_mutexP()
105 SDL_mutexV(SDL_mutex * mutex) in SDL_mutexV() argument
110 if (mutex == NULL) { in SDL_mutexV()
115 if (SDL_ThreadID() != mutex->owner) { in SDL_mutexV()
119 if (mutex->recursive) { in SDL_mutexV()
120 --mutex->recursive; in SDL_mutexV()
127 mutex->owner = 0; in SDL_mutexV()
128 SDL_SemPost(mutex->sem); in SDL_mutexV()