src/thread/pthread/SDL_syssem.c
changeset 1851 536b0704b7d8
parent 1630 eba962f9d603
child 1895 c121d94672cb
child 4159 a1b03ba2fcd0
equal deleted inserted replaced
1850:d5d3a6fe05a1 1851:536b0704b7d8
    21 */
    21 */
    22 #include "SDL_config.h"
    22 #include "SDL_config.h"
    23 
    23 
    24 #include <pthread.h>
    24 #include <pthread.h>
    25 #include <semaphore.h>
    25 #include <semaphore.h>
       
    26 #include <errno.h>
    26 
    27 
    27 #include "SDL_thread.h"
    28 #include "SDL_thread.h"
    28 #include "SDL_timer.h"
    29 #include "SDL_timer.h"
    29 
    30 
    30 /* Wrapper around POSIX 1003.1b semaphores */
    31 /* Wrapper around POSIX 1003.1b semaphores */
    84 	if ( ! sem ) {
    85 	if ( ! sem ) {
    85 		SDL_SetError("Passed a NULL semaphore");
    86 		SDL_SetError("Passed a NULL semaphore");
    86 		return -1;
    87 		return -1;
    87 	}
    88 	}
    88 
    89 
    89 	retval = sem_wait(&sem->sem);
    90 	while ( ((retval = sem_wait(&sem->sem)) == -1) && (errno == EINTR) ) {}
    90 	if ( retval < 0 ) {
    91 	if ( retval < 0 ) {
    91 		SDL_SetError("sem_wait() failed");
    92 		SDL_SetError("sem_wait() failed");
    92 	}
    93 	}
    93 	return retval;
    94 	return retval;
    94 }
    95 }