diff options
author | Chris Robinson <[email protected]> | 2008-01-11 08:15:44 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2008-01-11 08:15:44 -0800 |
commit | e1d0ad749bd5772d968aa8b5ed600dee905310a4 (patch) | |
tree | 64de690a4be8e58532bc38aeb8d97a69788e6e74 | |
parent | 2a5a5b5c1b97cfe66149bd77b4402e80f69c37c1 (diff) |
Use nanosleep instead of usleep
So not to rely on the non-standard unistd.h header
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 12 |
2 files changed, 13 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 32f717a2..4955d250 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,8 +137,8 @@ IF(NOT "${HAVE_WINDOWS_H}") MESSAGE(FATAL_ERROR "No timing function found!") ENDIF() - CHECK_FUNCTION_EXISTS(usleep HAVE_USLEEP) - IF(NOT "${HAVE_USLEEP}") + CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP) + IF(NOT "${HAVE_NANOSLEEP}") MESSAGE(FATAL_ERROR "No sleep function found!") ENDIF() diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 113101e4..c238a3a9 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -14,6 +14,8 @@ #include <assert.h> #include <pthread.h> #include <sys/time.h> +#include <time.h> +#include <errno.h> #define IsBadWritePtr(a,b) (0) @@ -68,7 +70,15 @@ static inline ALuint timeGetTime(void) return tv.tv_usec/1000 + tv.tv_sec*1000; } -#define Sleep(x) ((void)usleep((unsigned int)x*1000)) +static inline void Sleep(ALuint t) +{ + struct timespec tv, rem; + tv.tv_nsec = (t*1000000)%1000000000; + tv.tv_sec = t/1000; + + while(nanosleep(&tv, &rem) == -1 && errno == EINTR) + tv = rem; +} #define min(x,y) (((x)<(y))?(x):(y)) #define max(x,y) (((x)>(y))?(x):(y)) #endif |