]> The Tcpdump Group git mirrors - libpcap/blobdiff - ftmacros.h
CI: Call print_so_deps() on rpcapd in remote enabled build
[libpcap] / ftmacros.h
index bb08a11a2b871a11768d113d239013fefd345245..2e367a35eaf1ae90da3e2292ec9275c8fafe38e4 100644 (file)
  * namespace to the maximum extent possible"?
  */
 #if defined(sun) || defined(__sun)
-  #define __EXTENSIONS__
+  /*
+   * On Solaris Clang defines __EXTENSIONS__ automatically.
+   */
+  #ifndef __EXTENSIONS__
+    #define __EXTENSIONS__
+  #endif
 
   /*
    * We also need to define _XPG4_2 in order to get
@@ -59,7 +64,7 @@
   /*
    * We need this to get the versions of socket functions that
    * use socklen_t.  Define it only if it's not already defined,
-   * so we don't get redefiniton warnings.
+   * so we don't get redefinition warnings.
    */
   #ifndef _XOPEN_SOURCE_EXTENDED
     #define _XOPEN_SOURCE_EXTENDED
    * least with HP's C compiler; hopefully doing so won't make it
    * *not* work with *un*-threaded code.
    */
-#elif defined(__linux__) || defined(linux) || defined(__linux) || defined(__CYGWIN__)
+#else
   /*
    * Turn on _GNU_SOURCE to get everything GNU libc has to offer,
-   * including asprintf().
+   * including asprintf(), if we're using GNU libc.
    *
    * Unfortunately, one thing it has to offer is a strerror_r()
    * that's not POSIX-compliant, but we deal with that in
-   * pcap_fmt_errmsg_for_errno().
+   * pcapint_fmt_errmsg_for_errno().
+   *
+   * We don't limit this to, for example, Linux and Cygwin, because
+   * this might, for example, be GNU/HURD or one of Debian's kFreeBSD
+   * OSes ("GNU/FreeBSD").
+   *
+   * Avoid redefining, same as below.
    */
-  #define _GNU_SOURCE
+  #ifndef _GNU_SOURCE
+    #define _GNU_SOURCE
+  #endif
 
   /*
    * We turn on both _DEFAULT_SOURCE and _BSD_SOURCE to try to get
    * don't whine about _BSD_SOURCE being deprecated; we still have
    * to define _BSD_SOURCE to handle older versions of GNU libc that
    * don't support _DEFAULT_SOURCE.
+   *
+   * But, if it's already defined, don't define it, so that we don't
+   * get a warning of it being redefined if it's defined as, for
+   * example, 1.
    */
-  #define _DEFAULT_SOURCE
-  #define _BSD_SOURCE
+  #ifndef _DEFAULT_SOURCE
+    #define _DEFAULT_SOURCE
+  #endif
+  /* Avoid redefining _BSD_SOURCE if it's already defined as for ex. 1 */
+  #ifndef _BSD_SOURCE
+    #define _BSD_SOURCE
+  #endif
 #endif
 
 #endif