| @@ -17,7 +17,7 @@ | |||||
| * function prototypes that are sometimes missing. | * function prototypes that are sometimes missing. | ||||
| */ | */ | ||||
| #if defined(HAVE_INTTYPES_H) && !defined(__KERNEL__) | |||||
| #if defined HAVE_INTTYPES_H && !defined __KERNEL__ | |||||
| # include <inttypes.h> | # include <inttypes.h> | ||||
| #else | #else | ||||
| typedef signed char int8_t; | typedef signed char int8_t; | ||||
| @@ -32,22 +32,24 @@ typedef long int intptr_t; | |||||
| typedef unsigned long int uintptr_t; | typedef unsigned long int uintptr_t; | ||||
| #endif | #endif | ||||
| #if defined(HAVE_HTONS) | |||||
| # if defined(HAVE_ARPA_INET_H) | |||||
| #if defined HAVE_HTONS | |||||
| # if defined __KERNEL__ | |||||
| /* Nothing to do */ | |||||
| # elif defined HAVE_ARPA_INET_H | |||||
| # include <arpa/inet.h> | # include <arpa/inet.h> | ||||
| # elif defined(HAVE_NETINET_IN_H) | |||||
| # elif defined HAVE_NETINET_IN_H | |||||
| # include <netinet/in.h> | # include <netinet/in.h> | ||||
| # endif | # endif | ||||
| # define hton16 htons | # define hton16 htons | ||||
| # define hton32 htonl | # define hton32 htonl | ||||
| #else | #else | ||||
| # if defined(HAVE_ENDIAN_H) | |||||
| # if defined HAVE_ENDIAN_H | |||||
| # include <endian.h> | # include <endian.h> | ||||
| # endif | # endif | ||||
| static inline uint16_t hton16(uint16_t x) | static inline uint16_t hton16(uint16_t x) | ||||
| { | { | ||||
| /* This is compile-time optimised with at least -O1 or -Os */ | /* This is compile-time optimised with at least -O1 or -Os */ | ||||
| #if defined(HAVE_ENDIAN_H) | |||||
| #if defined HAVE_ENDIAN_H | |||||
| if(__BYTE_ORDER == __BIG_ENDIAN) | if(__BYTE_ORDER == __BIG_ENDIAN) | ||||
| #else | #else | ||||
| uint32_t const dummy = 0x12345678; | uint32_t const dummy = 0x12345678; | ||||
| @@ -61,7 +63,7 @@ static inline uint16_t hton16(uint16_t x) | |||||
| static inline uint32_t hton32(uint32_t x) | static inline uint32_t hton32(uint32_t x) | ||||
| { | { | ||||
| /* This is compile-time optimised with at least -O1 or -Os */ | /* This is compile-time optimised with at least -O1 or -Os */ | ||||
| #if defined(HAVE_ENDIAN_H) | |||||
| #if defined HAVE_ENDIAN_H | |||||
| if(__BYTE_ORDER == __BIG_ENDIAN) | if(__BYTE_ORDER == __BIG_ENDIAN) | ||||
| #else | #else | ||||
| uint32_t const dummy = 0x12345678; | uint32_t const dummy = 0x12345678; | ||||
| @@ -74,6 +76,7 @@ static inline uint32_t hton32(uint32_t x) | |||||
| } | } | ||||
| #endif | #endif | ||||
| #if defined(__KERNEL__) | |||||
| #undef HAVE_ERRNO_H | |||||
| #if defined __KERNEL__ | |||||
| # undef HAVE_ERRNO_H | |||||
| #endif | #endif | ||||