lib: add le16toh definition for win32/apple

This commit is contained in:
itsmattkc committed 2026-08-26 15:23:38 -07:00
1 parent 0681459cc8
commit 7caf3a4d9e
1 file changed
+12 -1
+12 -1
View File
@@ -10,6 +10,17 @@
#define MAX(a,b) (((a)>(b))?(a):(b))
#define CLAMP(x, min, max) (MIN(MAX(x, min), max))
#if defined(_WIN32)
// Windows has no htobe32, and is always virtually little-endiam
#define htobe32(x) htonl(x)
#define le16toh(x) (x)
#elif defined(__APPLE__)
// macOS has no htobe32
#include <libkern/OSByteOrder.h>
#define htobe32(x) OSSwapHostToBigInt32(x)
#define le16toh(x) OSSwapLittleToHostInt16(x)
#endif // __APPLE__
size_t read_line_from_fd(int fd, char *output, size_t max_output_size);
size_t read_line_from_file(FILE *file, char *output, size_t max_output_size);
size_t get_max_path_length();
@@ -26,4 +37,4 @@ uint16_t crc16(const void* data, size_t len);
void print_hex(const void *data, size_t len);
#endif // VANILLA_UTIL_H
#endif // VANILLA_UTIL_H