summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2019-07-22 13:58:11 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2019-07-22 13:58:11 +0000
commitd44819ae9c55f4d3c0f347b2640f58a2deddebb4 (patch)
tree040c9d2c5ce734047af365df4b86edc33379dd70 /src/include
parent8923a6ffa3da869b5fc56b9b1f698f483e3180a4 (diff)
downloadskalibs-d44819ae9c55f4d3c0f347b2640f58a2deddebb4.tar.xz
Factor all the BSD complaints into one new header
Diffstat (limited to 'src/include')
-rw-r--r--src/include/skalibs/bsdsnowflake.h48
-rw-r--r--src/include/skalibs/error.h12
-rw-r--r--src/include/skalibs/posixishard.h10
3 files changed, 51 insertions, 19 deletions
diff --git a/src/include/skalibs/bsdsnowflake.h b/src/include/skalibs/bsdsnowflake.h
new file mode 100644
index 0000000..97186d2
--- /dev/null
+++ b/src/include/skalibs/bsdsnowflake.h
@@ -0,0 +1,48 @@
+/* ISC license. */
+
+#ifndef SKALIBS_BSDSNOWFLAKE_H
+#define SKALIBS_BSDSNOWFLAKE_H
+
+ /*
+ Like skalibs/nonposix.h, this header is supposed to be included
+ *before* system headers.
+ Unlike skalibs/nonposix.h, though, it does not define ftms that
+ enable non-portable behaviour; it just attempts to work around
+ blatant brokenness, things that actually ARE defined by POSIX
+ but where OSes just ignore the spec.
+ The BSDs are experts at this, hence the name.
+ */
+
+
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__) || defined(__DragonFly__)
+
+ /* BSDs: the eponym.
+ Sometimes you just need to recognize who they are and what they do. */
+
+#ifndef SKALIBS_BSD_SUCKS
+#define SKALIBS_BSD_SUCKS
+#endif
+
+ /* Other times you just need to say you're a BSD so they deign
+ to define symbols like EOVERFLOW. Give me my POSIX symbols,
+ pretty please? */
+
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+
+#endif
+
+
+#if defined(__APPLE__) && defined(__MACH__)
+
+ /* MacOS: needs this for full SUSv3 conformance. That's how you
+ can tell it's really a BSD inside. With additional layers of crap. */
+
+#ifndef _DARWIN_C_SOURCE
+#define _DARWIN_C_SOURCE
+#endif
+
+#endif /* __APPLE__ && __MACH__ */
+
+#endif /* SKALIBS_BSDSNOWFLAKE_H */
diff --git a/src/include/skalibs/error.h b/src/include/skalibs/error.h
index 353e879..5431eb9 100644
--- a/src/include/skalibs/error.h
+++ b/src/include/skalibs/error.h
@@ -1,18 +1,12 @@
/* ISC license. */
-#ifndef ERROR_H
-#define ERROR_H
+#ifndef SKALIBS_ERROR_H
+#define SKALIBS_ERROR_H
-#include <skalibs/sysdeps.h>
#include <skalibs/gccattributes.h>
extern int error_temp (int) gccattr_const ;
+extern int error_isalready (int) gccattr_const ;
#define error_isagain(e) (((e) == EAGAIN) || ((e) == EWOULDBLOCK))
-#ifdef SKALIBS_BSD_SUCKS
-# define error_isalready(e) (((e) == EALREADY) || ((e) == EINPROGRESS) || ((e) == EADDRINUSE))
-#else
-# define error_isalready(e) (((e) == EALREADY) || ((e) == EINPROGRESS))
-#endif
-
#endif
diff --git a/src/include/skalibs/posixishard.h b/src/include/skalibs/posixishard.h
index b813494..b5da077 100644
--- a/src/include/skalibs/posixishard.h
+++ b/src/include/skalibs/posixishard.h
@@ -27,14 +27,4 @@ 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