From d0d389bcd65c2d8ca519a6dbe6f083d5a34ec249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Mon, 13 Jan 2014 21:19:44 +0200 Subject: [PATCH] add TIMEVAL_TO_TIMESPEC and TIMESPEC_TO_TIMEVAL --- include/sys/time.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/sys/time.h b/include/sys/time.h index b6787c3..9fd791c 100644 --- a/include/sys/time.h +++ b/include/sys/time.h @@ -10,6 +10,17 @@ extern "C" { int gettimeofday (struct timeval *__restrict, void *__restrict); +#if defined(_GNU_SOURCE) +#define TIMEVAL_TO_TIMESPEC(tv, ts) { \ + (ts)->tv_sec = (tv)->tv_sec; \ + (ts)->tv_nsec = (tv)->tv_usec * 1000; \ +} +#define TIMESPEC_TO_TIMEVAL(tv, ts) { \ + (tv)->tv_sec = (ts)->tv_sec; \ + (tv)->tv_usec = (ts)->tv_nsec / 1000; \ +} +#endif + #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ || defined(_BSD_SOURCE) -- 1.8.5.2