diff options
author | Chris Robinson <[email protected]> | 2010-07-18 06:21:16 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-07-18 06:21:16 -0700 |
commit | 34a0c998cd849ab40a1e6325b37ca53c2740c355 (patch) | |
tree | e53cde63803784f3e20905a9e21f83bc71e25746 | |
parent | e658df493a01b83dc1515f39e931c33d5b02d8b2 (diff) |
Use CLOCK_MONOTONIC when available
-rw-r--r-- | OpenAL32/Include/alMain.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 4d963563..d6fc5c15 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -184,16 +184,26 @@ static __inline void DeleteCriticalSection(CRITICAL_SECTION *cs) * as opposed to the actual time. */ static __inline ALuint timeGetTime(void) { - int ret; #if _POSIX_TIMERS > 0 + static int hasmono = 0; struct timespec ts; + int ret = -1; - ret = clock_gettime(CLOCK_REALTIME, &ts); +#if defined(_POSIX_MONOTONIC_CLOCK) && (_POSIX_MONOTONIC_CLOCK >= 0) +#if _POSIX_MONOTONIC_CLOCK == 0 + if(hasmono > 0 || (hasmono == 0 && + (hasmono=sysconf(_SC_MONOTONIC_CLOCK)) > 0)) +#endif + ret = clock_gettime(CLOCK_MONOTONIC, &ts); +#endif + if(ret != 0) + ret = clock_gettime(CLOCK_REALTIME, &ts); assert(ret == 0); return ts.tv_nsec/1000000 + ts.tv_sec*1000; #else struct timeval tv; + int ret; ret = gettimeofday(&tv, NULL); assert(ret == 0); |