From 718b4c4d7559f879cfa90a451133890988f18669 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 27 Feb 2015 15:01:29 -0500 Subject: clock_gettime() port fix for OS X. --- ntpshmread.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'ntpshmread.c') diff --git a/ntpshmread.c b/ntpshmread.c index 880ef542..0775583d 100644 --- a/ntpshmread.c +++ b/ntpshmread.c @@ -5,6 +5,7 @@ * * Some of this was swiped from the NTPD distribution. */ +#define _XOPEN_SOURCE 600 #include #include #include @@ -72,7 +73,17 @@ enum segstat_t shm_query(/*@null@*/struct shmTime *shm_in, /*@out@*/struct shm_s /*@-type@*//* splint is confused about struct timespec */ shm_stat->tvc.tv_sec = shm_stat->tvc.tv_nsec = 0; + +#ifdef HAVE_CLOCK_GETTIME clock_gettime(CLOCK_REALTIME, &shm_stat->tvc); +#else + { + struct timeval tv; + (void)gettimeofday(&tv, NULL); + shm_stat->tvc.tv_sec = tv.tv_sec; + shm_stat->tvc.tv_nsec = tv.tv_usec * 1000; + } +#endif /* relying on word access to be atomic here */ if (shm->valid == 0) { -- cgit v1.2.1