Favor using pthread_mutexattr_settype() on Linux.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401327
This commit is contained in:
Sam Lantinga 2006-02-03 06:33:54 +00:00
parent 17858398d5
commit a7df9020de
2 changed files with 32 additions and 29 deletions

View file

@ -62,15 +62,13 @@ SDL_mutex *SDL_CreateMutex (void)
mutex = (SDL_mutex *)calloc(1, sizeof(*mutex));
if ( mutex ) {
pthread_mutexattr_init(&attr);
#ifdef PTHREAD_NO_RECURSIVE_MUTEX
/* No extra attributes necessary */
#else
#ifdef linux
#if defined(PTHREAD_RECURSIVE_MUTEX)
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
#elif defined(PTHREAD_RECURSIVE_MUTEX_NP)
pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
#else
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
#endif
#endif /* PTHREAD_NO_RECURSIVE_MUTEX */
/* No extra attributes necessary */
#endif /* PTHREAD_RECURSIVE_MUTEX */
if ( pthread_mutex_init(&mutex->id, &attr) != 0 ) {
SDL_SetError("pthread_mutex_init() failed");
free(mutex);