Branch
Hash :
56c72c11
Author :
Thomas de Grivel
Date :
2025-08-26T20:11:32
fix build on windows
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
/* kc3
* Copyright from 2022 to 2025 kmx.io <contact@kmx.io>
*
* Permission is hereby granted to use this software granted the above
* copyright notice and this permission paragraph are included in all
* copies and substantial portions of this software.
*
* THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
* PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
#ifndef LIBKC3_ENDIAN_H
#define LIBKC3_ENDIAN_H
#ifdef htobe16
# undef htobe16
# undef htole16
# undef be16toh
# undef le16toh
# undef htobe32
# undef htole32
# undef be32toh
# undef le32toh
# undef htobe64
# undef htole64
# undef be64toh
# undef le64toh
#endif
#ifdef htons
# undef htons
# undef ntohs
# undef htonl
# undef ntohl
#endif
#if ! defined(__APPLE__)
# define BSWAP(b, x) __builtin_bswap ## b (x)
# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
# define htobe16(x) BSWAP(16, x)
# define htole16(x) (x)
# define be16toh(x) BSWAP(16, x)
# define le16toh(x) (x)
# define htobe32(x) BSWAP(32, x)
# define htole32(x) (x)
# define be32toh(x) BSWAP(32, x)
# define le32toh(x) (x)
# define htobe64(x) BSWAP(64, x)
# define htole64(x) (x)
# define be64toh(x) BSWAP(64, x)
# define le64toh(x) (x)
# if ! (defined(WIN32) || defined(WIN64))
# define htons(x) BSWAP(16, x)
# define ntohs(x) BSWAP(16, x)
# define htonl(x) BSWAP(32, x)
# define ntohl(x) BSWAP(32, x)
# endif
# else
# define htobe16(x) (x)
# define htole16(x) BSWAP(16, x)
# define be16toh(x) (x)
# define le16toh(x) BSWAP(16, x)
# define htobe32(x) (x)
# define htole32(x) BSWAP(32, x)
# define be32toh(x) (x)
# define le32toh(x) BSWAP(32, x)
# define htobe64(x) (x)
# define htole64(x) BSWAP(64, x)
# define be64toh(x) (x)
# define le64toh(x) BSWAP(64, x)
# if ! (defined(WIN32) || defined(WIN64))
# define htons(x) (x)
# define ntohs(x) (x)
# define htonl(x) (x)
# define ntohl(x) (x)
# endif
# endif
#else
# include <libkern/OSByteOrder.h>
# define htobe16(x) OSSwapHostToBigInt16(x)
# define htons(x) OSSwapHostToBigInt16(x)
# define htole16(x) OSSwapHostToLittleInt16(x)
# define be16toh(x) OSSwapBigToHostInt16(x)
# define ntohs(x) OSSwapBigToHostInt16(x)
# define le16toh(x) OSSwapLittleToHostInt16(x)
# define htobe32(x) OSSwapHostToBigInt32(x)
# define htole32(x) OSSwapHostToLittleInt32(x)
# define be32toh(x) OSSwapBigToHostInt32(x)
# define le32toh(x) OSSwapLittleToHostInt32(x)
# define htobe64(x) OSSwapHostToBigInt64(x)
# define htole64(x) OSSwapHostToLittleInt64(x)
# define be64toh(x) OSSwapBigToHostInt64(x)
# define le64toh(x) OSSwapLittleToHostInt64(x)
#endif
#endif /* LIBKC3_ENDIAN_H */