We don't actually use clock_gettime here. Which is fortunate, because its arrival in OSX 10.12 would pose a slightly tricky code target consistency question
This commit is contained in:
@@ -164,27 +164,6 @@ void gettimeofday(struct timeval *tv, void *tz)
|
||||
tv->tv_sec = (long)((now.ns100 - 116444736000000000LL) / 10000000LL);
|
||||
}
|
||||
|
||||
void clock_gettime(int, struct timespec *ts)
|
||||
{
|
||||
static LARGE_INTEGER cps;
|
||||
static bool haveCps = false;
|
||||
|
||||
if (!haveCps) {
|
||||
QueryPerformanceFrequency(&cps);
|
||||
haveCps = true;
|
||||
}
|
||||
|
||||
LARGE_INTEGER counter;
|
||||
QueryPerformanceCounter(&counter);
|
||||
|
||||
//!!! check this
|
||||
ts->tv_sec = counter.QuadPart / cps.QuadPart;
|
||||
double sub = counter.QuadPart % cps.QuadPart;
|
||||
sub = sub / cps.QuadPart;
|
||||
sub = sub * 1000000000.;
|
||||
ts->tv_nsec = long(sub) ;
|
||||
}
|
||||
|
||||
void usleep(unsigned long usec)
|
||||
{
|
||||
::Sleep(usec == 0 ? 0 : usec < 1000 ? 1 : usec / 1000);
|
||||
@@ -192,20 +171,6 @@ void usleep(unsigned long usec)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
void clock_gettime(int, struct timespec *ts)
|
||||
{
|
||||
uint64_t t = mach_absolute_time();
|
||||
static mach_timebase_info_data_t sTimebaseInfo;
|
||||
if (sTimebaseInfo.denom == 0) (void)mach_timebase_info(&sTimebaseInfo);
|
||||
uint64_t n = t * sTimebaseInfo.numer / sTimebaseInfo.denom;
|
||||
ts->tv_sec = n / 1000000000;
|
||||
ts->tv_nsec = n % 1000000000;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void system_specific_initialise()
|
||||
{
|
||||
#if defined HAVE_IPP
|
||||
|
||||
@@ -81,24 +81,11 @@ extern void system_specific_application_initialise();
|
||||
enum ProcessStatus { ProcessRunning, ProcessNotRunning, UnknownProcessStatus };
|
||||
extern ProcessStatus system_get_process_status(int pid);
|
||||
|
||||
#ifdef __APPLE__
|
||||
struct timespec { long tv_sec; long tv_nsec; };
|
||||
void clock_gettime(int clk_id, struct timespec *p);
|
||||
#define CLOCK_MONOTONIC 1
|
||||
#define CLOCK_REALTIME 2
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
struct timeval { long tv_sec; long tv_usec; };
|
||||
void gettimeofday(struct timeval *p, void *tz);
|
||||
|
||||
struct timespec { long tv_sec; long tv_nsec; };
|
||||
// always uses GetPerformanceCounter, does not check whether it's valid or not:
|
||||
void clock_gettime(int clk_id, struct timespec *p);
|
||||
#define CLOCK_MONOTONIC 1
|
||||
#define CLOCK_REALTIME 2
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __MSVC__
|
||||
|
||||
Reference in New Issue
Block a user