Lines Matching refs:mutex

45     SDL_mutex *mutex;  in SDL_CreateMutex()  local
49 mutex = (SDL_mutex *) SDL_calloc(1, sizeof(*mutex)); in SDL_CreateMutex()
50 if (mutex) { in SDL_CreateMutex()
59 if (pthread_mutex_init(&mutex->id, &attr) != 0) { in SDL_CreateMutex()
61 SDL_free(mutex); in SDL_CreateMutex()
62 mutex = NULL; in SDL_CreateMutex()
67 return (mutex); in SDL_CreateMutex()
71 SDL_DestroyMutex(SDL_mutex * mutex) in SDL_DestroyMutex() argument
73 if (mutex) { in SDL_DestroyMutex()
74 pthread_mutex_destroy(&mutex->id); in SDL_DestroyMutex()
75 SDL_free(mutex); in SDL_DestroyMutex()
81 SDL_LockMutex(SDL_mutex * mutex) in SDL_LockMutex() argument
87 if (mutex == NULL) { in SDL_LockMutex()
93 if (mutex->owner == this_thread) { in SDL_LockMutex()
94 ++mutex->recursive; in SDL_LockMutex()
100 if (pthread_mutex_lock(&mutex->id) == 0) { in SDL_LockMutex()
101 mutex->owner = this_thread; in SDL_LockMutex()
102 mutex->recursive = 0; in SDL_LockMutex()
108 if (pthread_mutex_lock(&mutex->id) != 0) { in SDL_LockMutex()
116 SDL_TryLockMutex(SDL_mutex * mutex) in SDL_TryLockMutex() argument
124 if (mutex == NULL) { in SDL_TryLockMutex()
131 if (mutex->owner == this_thread) { in SDL_TryLockMutex()
132 ++mutex->recursive; in SDL_TryLockMutex()
138 result = pthread_mutex_trylock(&mutex->id); in SDL_TryLockMutex()
140 mutex->owner = this_thread; in SDL_TryLockMutex()
141 mutex->recursive = 0; in SDL_TryLockMutex()
149 result = pthread_mutex_trylock(&mutex->id); in SDL_TryLockMutex()
162 SDL_UnlockMutex(SDL_mutex * mutex) in SDL_UnlockMutex() argument
164 if (mutex == NULL) { in SDL_UnlockMutex()
170 if (pthread_self() == mutex->owner) { in SDL_UnlockMutex()
171 if (mutex->recursive) { in SDL_UnlockMutex()
172 --mutex->recursive; in SDL_UnlockMutex()
179 mutex->owner = 0; in SDL_UnlockMutex()
180 pthread_mutex_unlock(&mutex->id); in SDL_UnlockMutex()
187 if (pthread_mutex_unlock(&mutex->id) != 0) { in SDL_UnlockMutex()