summaryrefslogtreecommitdiff
path: root/gl/lib/gettime.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2019-01-05 12:02:12 +0000
committerColin Watson <cjwatson@debian.org>2019-01-05 12:02:12 +0000
commit182141146d0ad9c735949840504bdfc66332da4e (patch)
treed8cbbf520eb4b5c656a54b2e36947008dcb751ad /gl/lib/gettime.c
parent68d15a97e215a4b7927039421566bbb1f74e5460 (diff)
parent033354546dc61e8a996d281aa2da2c440ac95c9f (diff)
Import man-db_2.8.5.orig.tar.xz
Diffstat (limited to 'gl/lib/gettime.c')
-rw-r--r--gl/lib/gettime.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/gl/lib/gettime.c b/gl/lib/gettime.c
index 9a4e342f..1fd153f6 100644
--- a/gl/lib/gettime.c
+++ b/gl/lib/gettime.c
@@ -1,6 +1,6 @@
/* gettime -- get the system clock
- Copyright (C) 2002, 2004-2007, 2009-2018 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004-2007, 2009-2019 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -28,21 +28,22 @@
void
gettime (struct timespec *ts)
{
-#if HAVE_NANOTIME
- nanotime (ts);
+#if defined CLOCK_REALTIME && HAVE_CLOCK_GETTIME
+ clock_gettime (CLOCK_REALTIME, ts);
#else
+ struct timeval tv;
+ gettimeofday (&tv, NULL);
+ ts->tv_sec = tv.tv_sec;
+ ts->tv_nsec = tv.tv_usec * 1000;
+#endif
+}
-# if defined CLOCK_REALTIME && HAVE_CLOCK_GETTIME
- if (clock_gettime (CLOCK_REALTIME, ts) == 0)
- return;
-# endif
-
- {
- struct timeval tv;
- gettimeofday (&tv, NULL);
- ts->tv_sec = tv.tv_sec;
- ts->tv_nsec = tv.tv_usec * 1000;
- }
+/* Return the current system time as a struct timespec. */
-#endif
+struct timespec
+current_timespec (void)
+{
+ struct timespec ts;
+ gettime (&ts);
+ return ts;
}