From 127da7e4672edae04b1555eb84237c6e111867e0 Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Wed, 31 Mar 2021 21:41:47 +0100 Subject: Define timeradd() and timersub() if necessary. testprogs/findalldevstest-perf uses timeradd() and timersub(), which are available as macros in Solaris 11 via (same as in Linux, for example), but not in earlier versions. Add the conditional definitions to fix "make testprogs" on Solaris 10. --- portability.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'portability.h') 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 -- cgit v1.2.3