aboutsummaryrefslogtreecommitdiff
path: root/portability.h
diff options
context:
space:
mode:
Diffstat (limited to 'portability.h')
-rw-r--r--portability.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/portability.h b/portability.h
index d606368d..3acc9ba2 100644
--- a/portability.h
+++ b/portability.h
@@ -112,6 +112,30 @@ extern int pcap_asprintf(char **, PCAP_FORMAT_STRING(const char *), ...)
extern int pcap_vasprintf(char **, const char *, va_list ap);
#endif
+/* For Solaris before 11. */
+#ifndef HAVE_TIMERADD
+#define timeradd(a, b, result) \
+ do { \
+ (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
+ (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
+ if ((result)->tv_usec >= 1000000) { \
+ ++(result)->tv_sec; \
+ (result)->tv_usec -= 1000000; \
+ } \
+ } while (0)
+#endif /* HAVE_TIMERADD */
+#ifndef HAVE_TIMERSUB
+#define timersub(a, b, result) \
+ do { \
+ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
+ (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
+ if ((result)->tv_usec < 0) { \
+ --(result)->tv_sec; \
+ (result)->tv_usec += 1000000; \
+ } \
+ } while (0)
+#endif /* HAVE_TIMERSUB */
+
#ifdef HAVE_STRTOK_R
#define pcap_strtok_r strtok_r
#else