21 #include "../../SDL_internal.h" 45 if (pthread_cond_init(&cond->
cond,
NULL) != 0) {
59 pthread_cond_destroy(&cond->
cond);
75 if (pthread_cond_signal(&cond->
cond) != 0) {
92 if (pthread_cond_broadcast(&cond->
cond) != 0) {
102 #ifndef HAVE_CLOCK_GETTIME 103 struct timeval delta;
105 struct timespec abstime;
108 return SDL_SetError(
"Passed a NULL condition variable");
111 #ifdef HAVE_CLOCK_GETTIME 112 clock_gettime(CLOCK_REALTIME, &abstime);
114 abstime.tv_nsec += (ms % 1000) * 1000000;
115 abstime.tv_sec += ms / 1000;
117 gettimeofday(&delta,
NULL);
119 abstime.tv_sec = delta.tv_sec + (ms / 1000);
120 abstime.tv_nsec = (delta.tv_usec + (ms % 1000) * 1000) * 1000;
122 if (abstime.tv_nsec > 1000000000) {
124 abstime.tv_nsec -= 1000000000;
128 retval = pthread_cond_timedwait(&cond->
cond, &mutex->
id, &abstime);
139 retval =
SDL_SetError(
"pthread_cond_timedwait() failed");
151 return SDL_SetError(
"Passed a NULL condition variable");
152 }
else if (pthread_cond_wait(&cond->
cond, &mutex->
id) != 0) {
int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex)
#define SDL_MUTEX_TIMEDOUT
SDL_cond * SDL_CreateCond(void)
int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)
int SDL_CondBroadcast(SDL_cond *cond)
int SDL_CondSignal(SDL_cond *cond)
void SDL_DestroyCond(SDL_cond *cond)