From a9d1016a529f7970419c670f8f57d818f8259a63 Mon Sep 17 00:00:00 2001
From: Nikolaj Schlej <nschlej@apple.com>
Date: Thu, 15 Sep 2022 06:46:02 +0200
Subject: [PATCH] Add other BSD variants to the same area that fixed FreeBSD
 builds

---
 common/kaitai/kaitaistream.cpp | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/common/kaitai/kaitaistream.cpp b/common/kaitai/kaitaistream.cpp
index c91493f..95ece45 100644
--- a/common/kaitai/kaitaistream.cpp
+++ b/common/kaitai/kaitaistream.cpp
@@ -2,6 +2,7 @@
 
 #define KS_STR_ENCODING_NONE
 
+// macOS
 #if defined(__APPLE__)
 #include <machine/endian.h>
 #include <libkern/OSByteOrder.h>
@@ -11,7 +12,8 @@
 #define __BYTE_ORDER    BYTE_ORDER
 #define __BIG_ENDIAN    BIG_ENDIAN
 #define __LITTLE_ENDIAN LITTLE_ENDIAN
-#elif defined(_MSC_VER) // !__APPLE__
+// Windows with MS compiler
+#elif defined(_MSC_VER)
 #include <stdlib.h>
 #define __LITTLE_ENDIAN     1234
 #define __BIG_ENDIAN        4321
@@ -19,12 +21,14 @@
 #define bswap_16(x) _byteswap_ushort(x)
 #define bswap_32(x) _byteswap_ulong(x)
 #define bswap_64(x) _byteswap_uint64(x)
-#elif defined(__FreeBSD__)
+// BSD
+#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
 #include <sys/endian.h>
 #define bswap_16(x) bswap16(x)
 #define bswap_32(x) bswap32(x)
 #define bswap_64(x) bswap64(x)
-#else // !__APPLE__ or !_MSC_VER
+// Everything else
+#else
 #include <endian.h>
 #include <byteswap.h>
 #endif