From 3f3283ee17d3318fa9bfb5c9900c06dbec434568 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Wed, 29 Sep 2010 13:35:18 +0200 Subject: client: Fall back to gettimeofday if clock_gettime not found --- client/threads.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'client/threads.cpp') diff --git a/client/threads.cpp b/client/threads.cpp index a9b8ea50..eb4b7a18 100644 --- a/client/threads.cpp +++ b/client/threads.cpp @@ -22,6 +22,9 @@ #ifdef WIN32 #include #endif +#ifdef HAVE_SYS_TIME_H +#include +#endif Thread::Thread(thread_main_t thread_main, void* opaque) { @@ -43,8 +46,13 @@ static inline void rel_time(struct timespec& time, uint64_t delta_nano) _ftime_s(&now); time.tv_sec = (long)now.time; time.tv_nsec = now.millitm * 1000 * 1000; -#else +#elif defined(HAVE_CLOCK_GETTIME) clock_gettime(CLOCK_MONOTONIC, &time); +#else + struct timeval tv; + gettimeofday(&tv,NULL); + time.tv_sec = tv.tv_sec; + time.tv_nsec = tv.tv_usec*1000; #endif delta_nano += (uint64_t)time.tv_sec * 1000 * 1000 * 1000; delta_nano += time.tv_nsec; -- cgit