From 1834e1256422c755688f319e059559115fad96fc Mon Sep 17 00:00:00 2001 From: Trung Nguyen Date: Tue, 28 May 2024 07:56:20 +1000 Subject: [PATCH] headers/bsd: Remove Haiku-specific include deps Remove the `ByteOrder.h` and `SupportDefs.h` Haiku-specific headers from `bsd/endian.h` on GCC >= 4 and replace them with compiler builtins. This prevents some unwanted symbols like `type_code` causing name clashes in ported applications. Change-Id: Id88791ea5954c260f4e7f5e82a564f3ae6bafe69 Reviewed-on: https://review.haiku-os.org/c/haiku/+/7642 Haiku-Format: Haiku-format Bot Reviewed-by: waddlesplash --- headers/compatibility/bsd/endian.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/headers/compatibility/bsd/endian.h b/headers/compatibility/bsd/endian.h index 0dcf5ee10a..7bba14b714 100644 --- a/headers/compatibility/bsd/endian.h +++ b/headers/compatibility/bsd/endian.h @@ -8,13 +8,17 @@ #include_next #include +#include #ifdef _DEFAULT_SOURCE #include + +#if __GNUC__ < 4 #include #include +#endif #ifdef __cplusplus extern "C" { @@ -23,9 +27,15 @@ extern "C" { /* * General byte order swapping functions. */ -#define bswap16(x) __swap_int16(x) -#define bswap32(x) __swap_int32(x) -#define bswap64(x) __swap_int64(x) +#if __GNUC__ >= 4 +#define bswap16(x) __builtin_bswap16(x) +#define bswap32(x) __builtin_bswap32(x) +#define bswap64(x) __builtin_bswap64(x) +#else +#define bswap16(x) __swap_int16(x) +#define bswap32(x) __swap_int32(x) +#define bswap64(x) __swap_int64(x) +#endif /* * Host to big endian, host to little endian, big endian to host, and little