statx: make include conditional, fixes non-csky arch buildroot builds
[uclibc-ng.git] / libc / inet / ntohl.c
blobb40ec295351977a66442b6ed5b1c1bd90c656967
1 /*
2 * Functions to convert between host and network byte order.
4 * Copyright (C) 2003-2006 by Erik Andersen <andersen@uclibc.org>
6 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
7 */
9 #include <netinet/in.h>
11 #undef ntohl
12 #undef ntohs
13 #undef htonl
14 #undef htons
16 #if __BYTE_ORDER != __BIG_ENDIAN && __BYTE_ORDER != __LITTLE_ENDIAN
17 # error "You seem to have an unsupported byteorder"
18 #endif
20 uint32_t ntohl (uint32_t x)
22 #if __BYTE_ORDER == __BIG_ENDIAN
23 return x;
24 #else
25 return __bswap_32(x);
26 #endif
28 libc_hidden_def(ntohl)
29 strong_alias(ntohl,htonl)
30 libc_hidden_def(htonl)
32 uint16_t ntohs (uint16_t x)
34 #if __BYTE_ORDER == __BIG_ENDIAN
35 return x;
36 #else
37 return __bswap_16(x);
38 #endif
40 libc_hidden_def(ntohs)
41 strong_alias(ntohs,htons)
42 libc_hidden_def(htons)