]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix <isc/endian.h> on BSD systems
authorMichał Kępień <michal@isc.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)
Current versions of DragonFly BSD, FreeBSD, NetBSD, and OpenBSD all
support the modern variants of functions converting values between host
and big-endian/little-endian byte order while older ones might not.
Ensure <isc/endian.h> works properly in both cases.

lib/isc/include/isc/endian.h

index 35ea578b330bd192bbd1c468b1f361e302121723..f713cec02557f8821b3d8a490aad2b85217bf9b1 100644 (file)
 # define __LITTLE_ENDIAN LITTLE_ENDIAN
 # define __PDP_ENDIAN    PDP_ENDIAN
 
-#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
+#elif defined(__DragonFly__) || defined(__FreeBSD__) || \
+      defined(__NetBSD__) || defined (__OpenBSD__) || defined(__bsdi__)
 
 # include <sys/endian.h>
 
-# define be16toh(x) betoh16(x)
-# define le16toh(x) letoh16(x)
-
-# define be32toh(x) betoh32(x)
-# define le32toh(x) letoh32(x)
-
-# define be64toh(x) betoh64(x)
-# define le64toh(x) letoh64(x)
+/*
+ * Recent BSDs should have [bl]e{16,32,64}toh() defined in <sys/endian.h>.
+ * Older ones might not, but these should have the alternatively named
+ * [bl]etoh{16,32,64}() functions defined.
+ */
+# ifndef be16toh
+#  define be16toh(x) betoh16(x)
+#  define le16toh(x) letoh16(x)
+#  define be32toh(x) betoh32(x)
+#  define le32toh(x) letoh32(x)
+#  define be64toh(x) betoh64(x)
+#  define le64toh(x) letoh64(x)
+# endif /* !be16toh */
 
 #elif defined(_WIN32)
 /* Windows is always little endian */