summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2019-07-22 11:52:00 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2019-07-22 11:52:00 +0000
commitf51fc9df9760e23ab1d98170955c33415cf66137 (patch)
treecac0b4a7636a28f52ac3cf46279f035ceb6817cb
parentfd4fcc7a6cc0f242a6c1b08248fde214652015b5 (diff)
downloadskalibs-f51fc9df9760e23ab1d98170955c33415cf66137.tar.xz
Rework skalibs/nonposix.h to avoid glibc squealing like a pig
Also move a conformance workaround from nonposix.h to posixishard.h This may break things on MacOS, needs testing.
-rw-r--r--src/include/skalibs/nonposix.h42
-rw-r--r--src/include/skalibs/posixishard.h10
2 files changed, 31 insertions, 21 deletions
diff --git a/src/include/skalibs/nonposix.h b/src/include/skalibs/nonposix.h
index cf87674..9f21252 100644
--- a/src/include/skalibs/nonposix.h
+++ b/src/include/skalibs/nonposix.h
@@ -1,7 +1,7 @@
/* ISC license. */
-#ifndef NONPOSIX_H
-#define NONPOSIX_H
+#ifndef SKALIBS_NONPOSIX_H
+#define SKALIBS_NONPOSIX_H
/* Drop all pretense of standardness: some libc headers are *more*
@@ -12,6 +12,8 @@
#undef _XOPEN_SOURCE
+#if defined(sun) || defined(__sun)
+
/* Solaris: the socket API is not POSIX unless you enable this */
#ifndef _XPG4_2
@@ -29,31 +31,34 @@
#define __EXTENSIONS__
#endif
+#endif /* sun || __sun */
+
+
+#if defined(__linux__) || defined(__GLIBC__)
- /* GNU: most extensions are unavailable unless you enable this */
+ /* GNU: most extensions are unavailable unless you enable _GNU_SOURCE.
+ Some Linux interfaces are also unavailable without it. */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
+#else /* __linux__ || __GLIBC__. */
- /* BSD and Linux libcs that are not glibc: _BSD_SOURCE opens up a
- lot of extensions. Of course, glibc insisted on changing to a
- different macro, because coordination and consistency would make
- developers' life too easy. */
+ /* Various BSDs and others: _BSD_SOURCE opens up a lot of extensions.
+ We guard this under not-glibc because recent glibcs scream their
+ heads off if you define _BSD_SOURCE. Stay classy, GNU. */
-#ifdef __GLIBC__
-#ifndef _DEFAULT_SOURCE
-#define _DEFAULT_SOURCE
-#endif
-#else
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
#endif
-#endif
+
+#endif /* __linux__ || __GLIBC__ */
- /* NetBSD: of course they had to have their own macro too. */
+#ifdef __NetBSD__
+
+ /* NetBSD: of course they had to have their own macros too. */
#ifndef _NETBSD_SOURCE
#define _NETBSD_SOURCE
@@ -62,12 +67,7 @@
#define _INCOMPLETE_XOPEN_C063
#endif
-
- /* MacOS: needs this for full SUSv3 conformance. Standards are hard. */
-
-#ifndef _DARWIN_C_SOURCE
-#define _DARWIN_C_SOURCE
-#endif
+#endif /* __NetBSD__ */
/* old versions of BSD and some broken GNU toolchains:
@@ -76,4 +76,4 @@
#include <sys/types.h>
-#endif
+#endif /* SKALIBS_NONPOSIX_H */
diff --git a/src/include/skalibs/posixishard.h b/src/include/skalibs/posixishard.h
index b5da077..b813494 100644
--- a/src/include/skalibs/posixishard.h
+++ b/src/include/skalibs/posixishard.h
@@ -27,4 +27,14 @@ extern size_t strnlen (char const *, size_t) gccattr_pure ;
#define MSG_NOSIGNAL 0
#endif
+#if defined(__APPLE__) && defined(__MACH__)
+
+ /* MacOS: needs this for full SUSv3 conformance. */
+
+#ifndef _DARWIN_C_SOURCE
+#define _DARWIN_C_SOURCE
+#endif
+
+#endif /* __APPLE__ && __MACH__ */
+
#endif