netinet/in: Use the GCC4 builtin byteswap functions for htonl.

Fixes the build breakage caused by PulkoMandy's recent commit.
Remove these from ByteOrder.h now also, as per POSIX they should
come from netinet/in.h.

This is a small source compatibility breakage, but it will only
affect a small portion of non-POSIX, partially-Be applications.
This commit is contained in:
Augustin Cavalier
2019-03-26 19:33:43 -04:00
parent 204ec4dec6
commit 9cb15d72bd
2 changed files with 12 additions and 17 deletions
+1 -9
View File
@@ -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)
+11 -8
View File
@@ -22,16 +22,19 @@ extern "C" {
typedef uint16_t in_port_t;
typedef uint32_t in_addr_t;
/* We can't include <ByteOrder.h> 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 <ByteOrder.h> 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))