Use CLOCK_MONOTONIC on macOS too
This commit is contained in:
parent
65175a9d8f
commit
4a814f3f2a
1 changed files with 0 additions and 11 deletions
11
util.c
11
util.c
|
|
@ -33,20 +33,9 @@ int verbosity = 0;
|
||||||
time_t time_monotonic()
|
time_t time_monotonic()
|
||||||
{
|
{
|
||||||
#ifndef NMRPFLASH_WINDOWS
|
#ifndef NMRPFLASH_WINDOWS
|
||||||
#ifndef NMRPFLASH_OSX
|
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
return ts.tv_sec;
|
return ts.tv_sec;
|
||||||
#else
|
|
||||||
static double factor = 0.0;
|
|
||||||
mach_timebase_info_data_t timebase;
|
|
||||||
if (factor == 0.0) {
|
|
||||||
mach_timebase_info(&timebase);
|
|
||||||
factor = (double)timebase.numer / timebase.denom;
|
|
||||||
}
|
|
||||||
|
|
||||||
return round(mach_absolute_time() * factor / 1e9);
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
return round(GetTickCount() / 1000.0);
|
return round(GetTickCount() / 1000.0);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue