diff options
Diffstat (limited to 'src/network/htonl.c')
| -rw-r--r-- | src/network/htonl.c | 8 | 
1 files changed, 3 insertions, 5 deletions
| diff --git a/src/network/htonl.c b/src/network/htonl.c index b21dace0..6622d16c 100644 --- a/src/network/htonl.c +++ b/src/network/htonl.c @@ -1,10 +1,8 @@  #include <netinet/in.h> +#include <byteswap.h>  uint32_t htonl(uint32_t n)  { -	union { -		uint8_t b[4]; -		uint32_t i; -	} u = { { n>>24, n>>16, n>>8, n } }; -	return u.i; +	union { int i; char c; } u = { 1 }; +	return u.c ? bswap_32(n) : n;  } | 
