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 <no-reply+haikuformatbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Trung Nguyen 2024-05-28 07:56:20 +10:00 committed by waddlesplash
parent ef761f9fba
commit 1834e12564
1 changed files with 13 additions and 3 deletions

View File

@ -8,13 +8,17 @@
#include_next <endian.h>
#include <features.h>
#include <stdint.h>
#ifdef _DEFAULT_SOURCE
#include <config/HaikuConfig.h>
#if __GNUC__ < 4
#include <support/ByteOrder.h>
#include <support/SupportDefs.h>
#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