* 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
/*
* 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)
+#else
+ /*
+ * Turn on _GNU_SOURCE to get everything GNU libc has to offer,
+ * 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
+ * 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.
+ */
+ #ifndef _GNU_SOURCE
+ #define _GNU_SOURCE
+ #endif
+
/*
- * We can't turn _GNU_SOURCE on because some versions of GNU Libc
- * will give the GNU version of strerror_r(), which returns a
- * string pointer and doesn't necessarily fill in the buffer,
- * rather than the standard version of strerror_r(), which
- * returns 0 or an errno and always fills in the buffer. We
- * require both of the latter behaviors.
+ * We turn on both _DEFAULT_SOURCE and _BSD_SOURCE to try to get
+ * the BSD u_XXX types, such as u_int and u_short, defined. We
+ * define _DEFAULT_SOURCE first, so that newer versions of GNU libc
+ * 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.
*
- * So we try turning everything else on that we can. This includes
- * defining _XOPEN_SOURCE as 600, because we want to force crypt()
- * to be declared on systems that use GNU libc, such as most Linux
- * distributions.
+ * 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 _POSIX_C_SOURCE 200809L
- #define _XOPEN_SOURCE 600
- #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