diff options
| author | kinichiro <kinichiro.inoguchi@gmail.com> | 2017-12-25 16:30:49 +0900 |
|---|---|---|
| committer | kinichiro <kinichiro.inoguchi@gmail.com> | 2017-12-25 16:30:49 +0900 |
| commit | 965a89108e09172d30e8f4922fe67414b41600b2 (patch) | |
| tree | d9cc798e9365a8b37c2b3188f142f5dde35c8ef1 /include | |
| parent | 7b6953e9a931dab2e6f85d204de1c68c81074553 (diff) | |
| download | portable-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 'include')
| -rw-r--r-- | include/compat/sys/time.h | 16 |
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 |
