aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-05-06 17:46:17 -0700
committerChris Robinson <[email protected]>2014-05-06 17:46:17 -0700
commit1a76a3238c86cc40499e0c724f698d9b17f776c4 (patch)
tree40cef4c17f8dd274195c991a4f63cf9e1d39c728
parentcbb94405db8f28e95fd60b611db479605b5d2a61 (diff)
Use gettimeofday if clock_gettime isn't available
-rw-r--r--Alc/threads.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/Alc/threads.c b/Alc/threads.c
index 0325c104..06036685 100644
--- a/Alc/threads.c
+++ b/Alc/threads.c
@@ -307,6 +307,7 @@ void alcall_once(alonce_flag *once, void (*callback)(void))
#else
+#include <sys/time.h>
#include <unistd.h>
#include <pthread.h>
#ifdef HAVE_PTHREAD_NP_H
@@ -497,14 +498,19 @@ int altimespec_get(struct timespec *ts, int base)
{
if(base == AL_TIME_UTC)
{
+ int ret;
#if _POSIX_TIMERS > 0
- int ret = clock_gettime(CLOCK_REALTIME, ts);
+ ret = clock_gettime(CLOCK_REALTIME, ts);
if(ret == 0) return base;
#else /* _POSIX_TIMERS > 0 */
-#warning "clock_gettime (POSIX.1-2001) is not available, timing resolution will be poor."
- ts->tv_sec = time(NULL);
- ts->tv_nsec = 0;
- return base;
+ struct timeval tv;
+ ret = gettimeofday(&tv, NULL);
+ if(ret == 0)
+ {
+ ts->tv_sec = tv.tv_sec;
+ ts->tv_nsec = tv.tv_usec * 1000;
+ return base;
+ }
#endif
}