Use clock_gettime() instead of timespec_get()

clock_gettime(CLOCK_REALTIME, &ts) is equivalent to timespec_get(&ts,
TIME_UTC) in C11.

It has the advantage that avoids the following building error when building
with macOS:

  warning: 'timespec_get' is only available on macOS 10.15 or newer
   [-Wunguarded-availability-new]
This commit is contained in:
Jim Huang 2019-06-24 23:54:38 +08:00 committed by Jim Huang
parent 91222691cb
commit 855e2f0d89

View file

@ -312,10 +312,10 @@ static double mi_clock_now() {
}
#else
#include <time.h>
#ifdef TIME_UTC
#ifdef CLOCK_REALTIME
static double mi_clock_now() {
struct timespec t;
timespec_get(&t, TIME_UTC);
clock_gettime(CLOCK_REALTIME, &t);
return (double)t.tv_sec + (1.0e-9 * (double)t.tv_nsec);
}
#else