system/Clock: remove obsolete MonotonicClock*() functions

We're using std::chrono::steady_clock now.  No need to duplicate code.
This commit is contained in:
Max Kellermann 2016-12-28 22:24:09 +01:00
parent 4011899846
commit 837134daef
2 changed files with 0 additions and 121 deletions

View File

@ -21,104 +21,6 @@
#ifdef WIN32
#include <windows.h>
#elif defined(__APPLE__)
#include <mach/mach_time.h>
#else
#include <time.h>
#ifndef CLOCK_MONOTONIC
#include <sys/time.h>
#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

View File

@ -22,29 +22,6 @@
#include "Compiler.h"
#include <stdint.h>
/**
* 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
/**