summaryrefslogtreecommitdiffstats
path: root/lib/monotime.h
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2017-01-23 23:17:35 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2017-01-23 23:17:35 +0100
commit39cea8220a9bcc51d97a7832760591e117cdde7a (patch)
tree2941563e6b40d08bd2351f59594cc5ce430ed935 /lib/monotime.h
parentlib: cope with negative timeout in thread.c (diff)
downloadfrr-39cea8220a9bcc51d97a7832760591e117cdde7a.tar.xz
frr-39cea8220a9bcc51d97a7832760591e117cdde7a.zip
lib: time: add TIMEVAL_TO_TIMESPEC
Should be in system headers, but not specified by any standard. Not currently used anywhere yet. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/monotime.h')
-rw-r--r--lib/monotime.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/monotime.h b/lib/monotime.h
index 10d3bb604..0fd494043 100644
--- a/lib/monotime.h
+++ b/lib/monotime.h
@@ -28,6 +28,13 @@
(tv)->tv_usec = (ts)->tv_nsec / 1000; \
} while (0)
#endif
+#ifndef TIMEVAL_TO_TIMESPEC
+/* should be in sys/time.h on BSD & Linux libcs */
+#define TIMEVAL_TO_TIMESPEC(tv, ts) do { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+ } while (0)
+#endif
static inline time_t monotime(struct timeval *tvo)
{