moved C11 code path to timespec_get

This commit is contained in:
Yann Collet 2019-04-10 14:15:11 -07:00
parent 4765929271
commit 36d2dfd846

View File

@ -11,9 +11,6 @@
/* === Dependencies === */ /* === Dependencies === */
#include <stdlib.h> /* abort */
#include <stdio.h> /* perror */
#include "timefn.h" #include "timefn.h"
@ -23,6 +20,9 @@
#if defined(_WIN32) /* Windows */ #if defined(_WIN32) /* Windows */
#include <stdlib.h> /* abort */
#include <stdio.h> /* perror */
UTIL_time_t UTIL_getTime(void) { UTIL_time_t x; QueryPerformanceCounter(&x); return x; } UTIL_time_t UTIL_getTime(void) { UTIL_time_t x; QueryPerformanceCounter(&x); return x; }
PTime UTIL_getSpanTimeMicro(UTIL_time_t clockStart, UTIL_time_t clockEnd) PTime UTIL_getSpanTimeMicro(UTIL_time_t clockStart, UTIL_time_t clockEnd)
@ -83,14 +83,16 @@ PTime UTIL_getSpanTimeNano(UTIL_time_t clockStart, UTIL_time_t clockEnd)
#elif (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */) \ #elif (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */)
&& defined (CLOCK_MONOTONIC)
#include <stdlib.h> /* abort */
#include <stdio.h> /* perror */
UTIL_time_t UTIL_getTime(void) UTIL_time_t UTIL_getTime(void)
{ {
UTIL_time_t time; UTIL_time_t time;
if (clock_gettime(CLOCK_MONOTONIC, &time)) { if (timespec_get(&time, TIME_UTC) == 0) {
perror("timefb::clock_gettime"); perror("timefn::timespec_get");
abort(); abort();
} }
return time; return time;