ByteOrder.h: remove use of __builtin_bswap16.

* Fixes the build for host compilers older than gcc-4.8
This commit is contained in:
Jessica Hamilton 2014-05-30 08:01:37 +12:00
parent d0592a1164
commit 040dc2eebc
3 changed files with 9 additions and 8 deletions

View File

@ -29,6 +29,11 @@ typedef enum {
# 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)
static inline uint16 __swap_int16(uint16 arg)
{
return (arg >> 8) | (arg << 8);
}
#endif
/* always swap macros */
@ -123,11 +128,9 @@ extern float __swap_float(float arg);
#if __GNUC__ >= 4
#define __swap_int64(arg) __builtin_bswap64(arg)
#define __swap_int32(arg) __builtin_bswap32(arg)
#define __swap_int16(arg) __builtin_bswap16(arg)
#else
extern uint64 __swap_int64(uint64 arg);
extern uint32 __swap_int32(uint32 arg);
extern uint16 __swap_int16(uint16 arg);
#endif
#ifdef __cplusplus

View File

@ -31,6 +31,10 @@ typedef uint32_t in_addr_t;
# else
extern unsigned int __swap_int32(unsigned int); /* private */
# endif
static inline uint16_t __swap_int16(uint16_t arg)
{
return (arg >> 8) | (arg << 8);
}
extern uint16_t __swap_int16(uint16_t); /* private */
# if BYTE_ORDER == LITTLE_ENDIAN
# define htonl(x) ((uint32_t)__swap_int32(x))

View File

@ -7,12 +7,6 @@
#include <ByteOrder.h>
uint16
__swap_int16(uint16 value)
{
return (value >> 8) | (value << 8);
}
uint32
__swap_int32(uint32 value)
{