Add other BSD variants to the same area that fixed FreeBSD builds

This commit is contained in:
Nikolaj Schlej 2022-09-15 06:46:02 +02:00
parent 4358f31242
commit a9d1016a52

View File

@ -2,6 +2,7 @@
#define KS_STR_ENCODING_NONE #define KS_STR_ENCODING_NONE
// macOS
#if defined(__APPLE__) #if defined(__APPLE__)
#include <machine/endian.h> #include <machine/endian.h>
#include <libkern/OSByteOrder.h> #include <libkern/OSByteOrder.h>
@ -11,7 +12,8 @@
#define __BYTE_ORDER BYTE_ORDER #define __BYTE_ORDER BYTE_ORDER
#define __BIG_ENDIAN BIG_ENDIAN #define __BIG_ENDIAN BIG_ENDIAN
#define __LITTLE_ENDIAN LITTLE_ENDIAN #define __LITTLE_ENDIAN LITTLE_ENDIAN
#elif defined(_MSC_VER) // !__APPLE__ // Windows with MS compiler
#elif defined(_MSC_VER)
#include <stdlib.h> #include <stdlib.h>
#define __LITTLE_ENDIAN 1234 #define __LITTLE_ENDIAN 1234
#define __BIG_ENDIAN 4321 #define __BIG_ENDIAN 4321
@ -19,12 +21,14 @@
#define bswap_16(x) _byteswap_ushort(x) #define bswap_16(x) _byteswap_ushort(x)
#define bswap_32(x) _byteswap_ulong(x) #define bswap_32(x) _byteswap_ulong(x)
#define bswap_64(x) _byteswap_uint64(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> #include <sys/endian.h>
#define bswap_16(x) bswap16(x) #define bswap_16(x) bswap16(x)
#define bswap_32(x) bswap32(x) #define bswap_32(x) bswap32(x)
#define bswap_64(x) bswap64(x) #define bswap_64(x) bswap64(x)
#else // !__APPLE__ or !_MSC_VER // Everything else
#else
#include <endian.h> #include <endian.h>
#include <byteswap.h> #include <byteswap.h>
#endif #endif