diff options
Diffstat (limited to 'utils/utils.h')
-rw-r--r-- | utils/utils.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/utils/utils.h b/utils/utils.h index 84322156e..079708843 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -91,6 +91,31 @@ typedef struct #define nsmkdir(dir, mode) mkdir((dir)) #endif +#ifndef timeradd +#define timeradd(a, aa, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec + (aa)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec + (aa)->tv_usec; \ + if ((result)->tv_usec >= 1000000) { \ + ++(result)->tv_sec; \ + (result)->tv_usec -= 1000000; \ + } \ + } while (0) +#endif + +#ifndef timersub +#define timersub(a, aa, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec - (aa)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec - (aa)->tv_usec; \ + if ((result)->tv_usec < 0) { \ + --(result)->tv_sec; \ + (result)->tv_usec += 1000000; \ + } \ + } while (0) +#endif + + /** * Private-word-capable realloc() implementation which * behaves as most NS libraries expect in the face of |