comparison src/thread/linux/SDL_sysmutex.c @ 1324:42e95163d553

Favor using pthread_mutexattr_settype() on Linux.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 03 Feb 2006 06:33:54 +0000
parents c9b51268668f
children 3692456e7b0f
comparison
equal deleted inserted replaced
1323:be736c197ceb 1324:42e95163d553
60 60
61 /* Allocate the structure */ 61 /* Allocate the structure */
62 mutex = (SDL_mutex *)calloc(1, sizeof(*mutex)); 62 mutex = (SDL_mutex *)calloc(1, sizeof(*mutex));
63 if ( mutex ) { 63 if ( mutex ) {
64 pthread_mutexattr_init(&attr); 64 pthread_mutexattr_init(&attr);
65 #ifdef PTHREAD_NO_RECURSIVE_MUTEX 65 #if defined(PTHREAD_RECURSIVE_MUTEX)
66 /* No extra attributes necessary */ 66 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
67 #else 67 #elif defined(PTHREAD_RECURSIVE_MUTEX_NP)
68 #ifdef linux
69 pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP); 68 pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
70 #else 69 #else
71 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); 70 /* No extra attributes necessary */
72 #endif 71 #endif /* PTHREAD_RECURSIVE_MUTEX */
73 #endif /* PTHREAD_NO_RECURSIVE_MUTEX */
74 if ( pthread_mutex_init(&mutex->id, &attr) != 0 ) { 72 if ( pthread_mutex_init(&mutex->id, &attr) != 0 ) {
75 SDL_SetError("pthread_mutex_init() failed"); 73 SDL_SetError("pthread_mutex_init() failed");
76 free(mutex); 74 free(mutex);
77 mutex = NULL; 75 mutex = NULL;
78 } 76 }