diff --git a/headers/os/support/ByteOrder.h b/headers/os/support/ByteOrder.h index d02cba1ac6..67b6879ac3 100644 --- a/headers/os/support/ByteOrder.h +++ b/headers/os/support/ByteOrder.h @@ -1,5 +1,5 @@ /* - * Copyright 2007 Haiku, Inc. All rights reserved. + * Copyright 2007, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _BYTE_ORDER_H @@ -23,14 +23,6 @@ typedef enum { } swap_action; -/* BSD/networking macros */ -#ifndef htonl -# define htonl(x) B_HOST_TO_BENDIAN_INT32(x) -# define ntohl(x) B_BENDIAN_TO_HOST_INT32(x) -# define htons(x) B_HOST_TO_BENDIAN_INT16(x) -# define ntohs(x) B_BENDIAN_TO_HOST_INT16(x) -#endif - /* always swap macros */ #define B_SWAP_DOUBLE(arg) __swap_double(arg) #define B_SWAP_FLOAT(arg) __swap_float(arg) diff --git a/headers/posix/netinet/in.h b/headers/posix/netinet/in.h index ab891cb8dd..786b978569 100644 --- a/headers/posix/netinet/in.h +++ b/headers/posix/netinet/in.h @@ -22,16 +22,19 @@ extern "C" { typedef uint16_t in_port_t; typedef uint32_t in_addr_t; -/* We can't include since we are a posix file, - * and we are not allowed to import all the BeOS types here. - */ -#ifndef htonl -# ifdef __HAIKU_BEOS_COMPATIBLE_TYPES - extern unsigned long __swap_int32(unsigned long); /* private */ +/* We can't include since we are a POSIX file, + * and we are not allowed to import all the BeOS types here. */ +#if !defined(__swap_int32) +# if __GNUC__ >= 4 +# define __swap_int32(arg) (uint32)__builtin_bswap32(arg) +# define __swap_int16(arg) (uint16)__builtin_bswap16(arg) # else - extern unsigned int __swap_int32(unsigned int); /* private */ + extern unsigned long __swap_int32(unsigned long); /* private */ + extern uint16_t __swap_int16(uint16_t); /* private */ # endif - extern uint16_t __swap_int16(uint16_t); /* private */ +#endif + +#ifndef htonl # if BYTE_ORDER == LITTLE_ENDIAN # define htonl(x) ((uint32_t)__swap_int32(x)) # define ntohl(x) ((uint32_t)__swap_int32(x))