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