]> The Tcpdump Group git mirrors - libpcap/blobdiff - portability.h
Update config.{guess,sub}, timestamps 2023-01-01,2023-01-21
[libpcap] / portability.h
index 39e1583b4f83d170e4dddf794c077016ddcc18fc..84d0778a5c77cb6ec97048e265d8ab8dde77c0a2 100644 (file)
@@ -83,8 +83,6 @@ extern "C" {
 #endif
 
 #ifdef _MSC_VER
-  #define isascii      __isascii
-
   /*
    * If <crtdbg.h> has been included, and _DEBUG is defined, and
    * __STDC__ is zero, <crtdbg.h> will define strdup() to call
@@ -114,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 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 /* timeradd */
+#ifndef 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 /* timersub */
+
 #ifdef HAVE_STRTOK_R
   #define pcap_strtok_r        strtok_r
 #else