diff options
author | Chris Robinson <[email protected]> | 2014-04-16 07:18:28 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-04-16 07:18:28 -0700 |
commit | 959d75edc8bd4431c9c16dad92668dfa34521be3 (patch) | |
tree | c55cb2df131197ecc0a9100695f5d8b9ea5efb26 /OpenAL32/Include/threads.h | |
parent | b020dd13fda12ffa275f6c8165dcad481f9658d6 (diff) |
Fix althrd_sleep return value
Diffstat (limited to 'OpenAL32/Include/threads.h')
-rw-r--r-- | OpenAL32/Include/threads.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/OpenAL32/Include/threads.h b/OpenAL32/Include/threads.h index b6a29f65..943ef045 100644 --- a/OpenAL32/Include/threads.h +++ b/OpenAL32/Include/threads.h @@ -2,7 +2,6 @@ #define AL_THREADS_H #include <time.h> -#include <errno.h> enum { @@ -95,6 +94,7 @@ inline int almtx_trylock(almtx_t *mtx) #else #include <stdint.h> +#include <errno.h> #include <pthread.h> @@ -124,7 +124,13 @@ inline void althrd_yield(void) inline int althrd_sleep(const struct timespec *ts, struct timespec *rem) { - return nanosleep(ts, rem); + int ret = nanosleep(ts, rem); + if(ret != 0) + { + ret = ((errno==EINTR) ? -1 : -2); + errno = 0; + } + return ret; } @@ -171,7 +177,7 @@ inline void al_nssleep(time_t sec, long nsec) ts.tv_sec = sec; ts.tv_nsec = nsec; - while(althrd_sleep(&ts, &rem) == -1 && errno == EINTR) + while(althrd_sleep(&ts, &rem) == -1) ts = rem; } |