aboutsummaryrefslogtreecommitdiff
path: root/portability.h
diff options
context:
space:
mode:
authorDenis Ovsienko <denis@ovsienko.info>2021-03-31 21:41:47 +0100
committerDenis Ovsienko <denis@ovsienko.info>2021-03-31 21:41:47 +0100
commit127da7e4672edae04b1555eb84237c6e111867e0 (patch)
tree00a0c5dfce668c8b3d11ef1c9ade6af19d73cbf1 /portability.h
parent4a183a9e6addd23285921840c2da536b47612a64 (diff)
Define timeradd() and timersub() if necessary.
testprogs/findalldevstest-perf uses timeradd() and timersub(), which are available as macros in Solaris 11 via <sys/time.h> (same as in Linux, for example), but not in earlier versions. Add the conditional definitions to fix "make testprogs" on Solaris 10.
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