diff --git a/src/system/Clock.cxx b/src/system/Clock.cxx index 4a880ccf2..70b4a50ad 100644 --- a/src/system/Clock.cxx +++ b/src/system/Clock.cxx @@ -21,104 +21,6 @@ #ifdef WIN32 #include -#elif defined(__APPLE__) -#include -#else -#include -#ifndef CLOCK_MONOTONIC -#include -#endif -#endif - -unsigned -MonotonicClockS(void) -{ -#ifdef WIN32 - return GetTickCount() / 1000; -#elif defined(__APPLE__) /* OS X does not define CLOCK_MONOTONIC */ - static mach_timebase_info_data_t base; - if (base.denom == 0) - (void)mach_timebase_info(&base); - - return (unsigned)(((double)mach_absolute_time() * base.numer / 1000) - / base.denom / 1000000); -#elif defined(CLOCK_MONOTONIC) - struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - return ts.tv_sec; -#else - /* we have no monotonic clock, fall back to time() */ - return time(nullptr); -#endif -} - -unsigned -MonotonicClockMS(void) -{ -#ifdef WIN32 - return GetTickCount(); -#elif defined(__APPLE__) /* OS X does not define CLOCK_MONOTONIC */ - static mach_timebase_info_data_t base; - if (base.denom == 0) - (void)mach_timebase_info(&base); - - return (unsigned)(((double)mach_absolute_time() * base.numer) - / base.denom / 1000000); -#elif defined(CLOCK_MONOTONIC) - struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - return ts.tv_sec * 1000 + ts.tv_nsec / 1000000; -#else - /* we have no monotonic clock, fall back to gettimeofday() */ - struct timeval tv; - gettimeofday(&tv, 0); - return tv.tv_sec * 1000 + tv.tv_usec / 1000; -#endif -} - -uint64_t -MonotonicClockUS(void) -{ -#ifdef WIN32 - LARGE_INTEGER l_value, l_frequency; - - if (!QueryPerformanceCounter(&l_value) || - !QueryPerformanceFrequency(&l_frequency)) - return 0; - - uint64_t value = l_value.QuadPart; - uint64_t frequency = l_frequency.QuadPart; - - if (frequency > 1000000) { - value *= 10000; - value /= frequency / 100; - } else if (frequency < 1000000) { - value *= 10000; - value /= frequency; - value *= 100; - } - - return value; -#elif defined(__APPLE__) /* OS X does not define CLOCK_MONOTONIC */ - static mach_timebase_info_data_t base; - if (base.denom == 0) - (void)mach_timebase_info(&base); - - return (uint64_t)(((double)mach_absolute_time() * base.numer) - / base.denom / 1000); -#elif defined(CLOCK_MONOTONIC) - struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - return (uint64_t)ts.tv_sec * 1000000 + (uint64_t)(ts.tv_nsec / 1000); -#else - /* we have no monotonic clock, fall back to gettimeofday() */ - struct timeval tv; - gettimeofday(&tv, 0); - return (uint64_t)tv.tv_sec * 1000 + (uint64_t)tv.tv_usec; -#endif -} - -#ifdef WIN32 gcc_const static unsigned diff --git a/src/system/Clock.hxx b/src/system/Clock.hxx index aa8587324..af4ed93b1 100644 --- a/src/system/Clock.hxx +++ b/src/system/Clock.hxx @@ -22,29 +22,6 @@ #include "Compiler.h" -#include - -/** - * Returns the value of a monotonic clock in seconds. - */ -gcc_pure -unsigned -MonotonicClockS(); - -/** - * Returns the value of a monotonic clock in milliseconds. - */ -gcc_pure -unsigned -MonotonicClockMS(); - -/** - * Returns the value of a monotonic clock in microseconds. - */ -gcc_pure -uint64_t -MonotonicClockUS(); - #ifdef WIN32 /**