diff options
| author | Brent Cook <busterb@gmail.com> | 2017-12-12 03:31:35 -0600 |
|---|---|---|
| committer | Brent Cook <busterb@gmail.com> | 2017-12-12 03:31:35 -0600 |
| commit | 7b6953e9a931dab2e6f85d204de1c68c81074553 (patch) | |
| tree | 258435598bbeec093d0fb5df14c53fdf47904197 /include | |
| parent | 6d0192ff17ca1294fefd0839012b50a5e14cb904 (diff) | |
| download | portable-7b6953e9a931dab2e6f85d204de1c68c81074553.tar.gz portable-7b6953e9a931dab2e6f85d204de1c68c81074553.tar.bz2 portable-7b6953e9a931dab2e6f85d204de1c68c81074553.zip | |
add timerspecsub
Diffstat (limited to 'include')
| -rw-r--r-- | include/compat/time.h | 12 |
1 files changed, 12 insertions, 0 deletions
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); | |||
| 21 | #ifndef HAVE_TIMEGM | 21 | #ifndef HAVE_TIMEGM |
| 22 | time_t timegm(struct tm *tm); | 22 | time_t timegm(struct tm *tm); |
| 23 | #endif | 23 | #endif |
| 24 | |||
| 25 | #ifndef timespecsub | ||
| 26 | #define timespecsub(tsp, usp, vsp) \ | ||
| 27 | do { \ | ||
| 28 | (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ | ||
| 29 | (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ | ||
| 30 | if ((vsp)->tv_nsec < 0) { \ | ||
| 31 | (vsp)->tv_sec--; \ | ||
| 32 | (vsp)->tv_nsec += 1000000000L; \ | ||
| 33 | } \ | ||
| 34 | } while (0) | ||
| 35 | #endif | ||
