aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkinichiro <kinichiro.inoguchi@gmail.com>2017-12-25 16:30:49 +0900
committerkinichiro <kinichiro.inoguchi@gmail.com>2017-12-25 16:30:49 +0900
commit965a89108e09172d30e8f4922fe67414b41600b2 (patch)
treed9cc798e9365a8b37c2b3188f142f5dde35c8ef1
parent7b6953e9a931dab2e6f85d204de1c68c81074553 (diff)
downloadportable-965a89108e09172d30e8f4922fe67414b41600b2.tar.gz
portable-965a89108e09172d30e8f4922fe67414b41600b2.tar.bz2
portable-965a89108e09172d30e8f4922fe67414b41600b2.zip
Add CLOCK_MONOTONIC and timersub for the OS that does not have them
Diffstat (limited to '')
-rw-r--r--include/compat/sys/time.h16
1 files changed, 16 insertions, 0 deletions
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);
13#include_next <sys/time.h> 13#include_next <sys/time.h>
14#endif 14#endif
15 15
16#ifndef CLOCK_MONOTONIC
17#define CLOCK_MONOTONIC CLOCK_REALTIME
18#endif
19
20#ifndef timersub
21#define timersub(tvp, uvp, vvp) \
22 do { \
23 (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
24 (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
25 if ((vvp)->tv_usec < 0) { \
26 (vvp)->tv_sec--; \
27 (vvp)->tv_usec += 1000000; \
28 } \
29 } while (0)
30#endif
31
16#endif 32#endif