From 965a89108e09172d30e8f4922fe67414b41600b2 Mon Sep 17 00:00:00 2001 From: kinichiro Date: Mon, 25 Dec 2017 16:30:49 +0900 Subject: Add CLOCK_MONOTONIC and timersub for the OS that does not have them --- include/compat/sys/time.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include') diff --git a/include/compat/sys/time.h b/include/compat/sys/time.h index 235bc6e..3d31985 100644 --- a/include/compat/sys/time.h +++ b/include/compat/sys/time.h @@ -13,4 +13,20 @@ int gettimeofday(struct timeval *tp, void *tzp); #include_next #endif +#ifndef CLOCK_MONOTONIC +#define CLOCK_MONOTONIC CLOCK_REALTIME +#endif + +#ifndef timersub +#define timersub(tvp, uvp, vvp) \ + do { \ + (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ + (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ + if ((vvp)->tv_usec < 0) { \ + (vvp)->tv_sec--; \ + (vvp)->tv_usec += 1000000; \ + } \ + } while (0) +#endif + #endif -- cgit v1.2.3-55-g6feb