]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Make <isc/endian.h> detect GNU rather than Linux
authorOndřej Surý <ondrej@sury.org>
Mon, 3 Jun 2019 12:13:23 +0000 (14:13 +0200)
committerMichał Kępień <michal@isc.org>
Mon, 3 Jun 2019 12:13:23 +0000 (14:13 +0200)
Instead of only supporting Linux, try making <isc/endian.h> support
other GNU platforms as well.  Since some compilers define __GNUC__ on
BSDs (e.g. Clang on FreeBSD), move the relevant section to the bottom of
the platform-specific part of <isc/endian.h>, so that it only gets
evaluated when more specific platform determination criteria are not
met.  Also include <byteswap.h> so that any byte-swapping macros which
may be defined in that file on older platforms are used in the fallback
definitions of the nonstandard hto[bl]e{16,32,64}() and
[bl]e{16,32,64}toh() conversion functions.

lib/isc/include/isc/endian.h

index 98a26dafac18c9bc2d8e28d6b559141ea6987a9e..30a8f1e076005cce2d6fbfd84b67a549d4915ad7 100644 (file)
 
 #pragma once
 
-#if defined(__linux__) || defined(__CYGWIN__)
-
-#include <endian.h>
-
-#elif defined __APPLE__
+#if defined __APPLE__
 
 #include <libkern/OSByteOrder.h>
 
 # define bswap_32(x) BSWAP_32(x)
 # define bswap_64(x) BSWAP_64(x)
 
+#elif defined(__ANDROID__) || defined(__CYGWIN__) || \
+      defined(__GNUC__) || defined(__GNU__)
+
+# include <byteswap.h>
+# include <endian.h>
+
 #else
 
 #endif /* Specific platform support */