Merge "Linux always has POSIX clocks available."

This commit is contained in:
Elliott Hughes 2015-01-10 00:34:15 +00:00 committed by Gerrit Code Review
commit 9da414f95e
2 changed files with 3 additions and 11 deletions

View file

@ -113,15 +113,15 @@ inline status_t Condition::waitRelative(Mutex& mutex, nsecs_t reltime) {
return -pthread_cond_timedwait_relative_np(&mCond, &mutex.mMutex, &ts); return -pthread_cond_timedwait_relative_np(&mCond, &mutex.mMutex, &ts);
#else // HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE #else // HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE
struct timespec ts; struct timespec ts;
#if defined(HAVE_POSIX_CLOCKS) #if defined(__linux__)
clock_gettime(CLOCK_REALTIME, &ts); clock_gettime(CLOCK_REALTIME, &ts);
#else // HAVE_POSIX_CLOCKS #else // __APPLE__
// we don't support the clocks here. // we don't support the clocks here.
struct timeval t; struct timeval t;
gettimeofday(&t, NULL); gettimeofday(&t, NULL);
ts.tv_sec = t.tv_sec; ts.tv_sec = t.tv_sec;
ts.tv_nsec= t.tv_usec*1000; ts.tv_nsec= t.tv_usec*1000;
#endif // HAVE_POSIX_CLOCKS #endif
ts.tv_sec += reltime/1000000000; ts.tv_sec += reltime/1000000000;
ts.tv_nsec+= reltime%1000000000; ts.tv_nsec+= reltime%1000000000;
if (ts.tv_nsec >= 1000000000) { if (ts.tv_nsec >= 1000000000) {

View file

@ -727,18 +727,10 @@ void ggl_enable_texture2d(context_t* c, int enable)
int64_t ggl_system_time() int64_t ggl_system_time()
{ {
#if defined(HAVE_POSIX_CLOCKS)
struct timespec t; struct timespec t;
t.tv_sec = t.tv_nsec = 0; t.tv_sec = t.tv_nsec = 0;
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &t); clock_gettime(CLOCK_THREAD_CPUTIME_ID, &t);
return int64_t(t.tv_sec)*1000000000LL + t.tv_nsec; return int64_t(t.tv_sec)*1000000000LL + t.tv_nsec;
#else
// we don't support the clocks here.
struct timeval t;
t.tv_sec = t.tv_usec = 0;
gettimeofday(&t, NULL);
return int64_t(t.tv_sec)*1000000000LL + int64_t(t.tv_usec)*1000LL;
#endif
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------