21#include "../../SDL_internal.h"
34#if defined(__MACOSX__) || defined(__IPHONEOS__)
36#include "../generic/SDL_syssem.c"
50 if (sem_init(&
sem->sem, 0, initial_value) < 0) {
65 sem_destroy(&
sem->sem);
79 if (sem_trywait(&
sem->sem) == 0) {
96 }
while (
retval < 0 && errno == EINTR);
108#ifdef HAVE_SEM_TIMEDWAIT
109#ifndef HAVE_CLOCK_GETTIME
112 struct timespec ts_timeout;
129#ifdef HAVE_SEM_TIMEDWAIT
134#ifdef HAVE_CLOCK_GETTIME
135 clock_gettime(CLOCK_REALTIME, &ts_timeout);
138 ts_timeout.tv_nsec += (
timeout % 1000) * 1000000;
139 ts_timeout.tv_sec +=
timeout / 1000;
141 gettimeofday(&now,
NULL);
144 ts_timeout.tv_sec = now.tv_sec + (
timeout / 1000);
145 ts_timeout.tv_nsec = (now.tv_usec + (
timeout % 1000) * 1000) * 1000;
149 if (ts_timeout.tv_nsec > 1000000000) {
150 ts_timeout.tv_sec += 1;
151 ts_timeout.tv_nsec -= 1000000000;
156 retval = sem_timedwait(&
sem->sem, &ts_timeout);
157 }
while (
retval < 0 && errno == EINTR);
160 if (errno == ETIMEDOUT) {
163 SDL_SetError(
"sem_timedwait returned an error: %s", strerror(errno));
184 sem_getvalue(&
sem->sem, &ret);
#define SDL_OutOfMemory()
#define SDL_MUTEX_TIMEDOUT
#define SDL_MUTEX_MAXWAIT
GLbitfield GLuint64 timeout
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
#define SDL_TICKS_PASSED(A, B)
Compare SDL ticks values, and return true if A has passed B.
int SDL_SemWait(SDL_sem *sem)
int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
SDL_sem * SDL_CreateSemaphore(Uint32 initial_value)
void SDL_DestroySemaphore(SDL_sem *sem)
int SDL_SemPost(SDL_sem *sem)
Uint32 SDL_SemValue(SDL_sem *sem)
int SDL_SemTryWait(SDL_sem *sem)