diff options
author | Michael Tatarinov <kukabu@gmail.com> | 2011-10-20 11:35:01 +0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2011-10-20 03:42:33 -0400 |
commit | c034d9f6e2665b580c063b78fc7184c710ef4681 (patch) | |
tree | c856c2ef51d5030b10241dd0b845328452d11758 /gpsutils.c | |
parent | e102e0dd7049cc79a005891bf85df02b74559804 (diff) | |
download | gpsd-c034d9f6e2665b580c063b78fc7184c710ef4681.tar.gz |
Used clock_gettime() instead of gettimeofday() if possible.
Signed-off-by: Eric S. Raymond <esr@thyrsus.com>
Diffstat (limited to 'gpsutils.c')
-rw-r--r-- | gpsutils.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -290,9 +290,15 @@ void gps_merge_fix( /*@ out @*/ struct gps_fix_t *to, timestamp_t timestamp(void) { - struct timespec ts; - /*@i2@*/(void)clock_gettime(CLOCK_REALTIME, &ts); - /*@i3@*/return (timestamp_t)(ts.tv_sec + ts.tv_nsec * 1e-9); +#ifdef HAVE_CLOCK_GETTIME + struct timespec ts; + /*@i2@*/(void)clock_gettime(CLOCK_REALTIME, &ts); + /*@i3@*/return (timestamp_t)(ts.tv_sec + ts.tv_nsec * 1e-9); +#else + struct timeval tv; + (void)gettimeofday(&tv, NULL); + return (timestamp_t)(tv.tv_sec + tv.tv_usec * 1e-6); +#endif } time_t mkgmtime(register struct tm * t) |