From 7b6953e9a931dab2e6f85d204de1c68c81074553 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Tue, 12 Dec 2017 03:31:35 -0600 Subject: add timerspecsub --- include/compat/time.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/compat/time.h b/include/compat/time.h index 99a2001..df65530 100644 --- a/include/compat/time.h +++ b/include/compat/time.h @@ -21,3 +21,15 @@ struct tm *__gmtime_r(const time_t * t, struct tm * tm); #ifndef HAVE_TIMEGM time_t timegm(struct tm *tm); #endif + +#ifndef timespecsub +#define timespecsub(tsp, usp, vsp) \ + do { \ + (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ + (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ + if ((vsp)->tv_nsec < 0) { \ + (vsp)->tv_sec--; \ + (vsp)->tv_nsec += 1000000000L; \ + } \ + } while (0) +#endif -- cgit v1.2.3-55-g6feb