ARC defconfigs: enable some items
[uclibc-ng.git] / libc / inet / ntohl.c
blob8e500a5e30005a7a4212c6736842539723a70624
1 /* vi: set sw=4 ts=4:
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)