]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/uclibc/lib/contrib/uclibc/libc/inet/ntohl.c
Update
[l4.git] / l4 / pkg / l4re-core / uclibc / lib / contrib / uclibc / libc / inet / ntohl.c
1 /* vi: set sw=4 ts=4:
2  * Functions to convert between host and network byte order.
3  *
4  * Copyright (C) 2003-2006 by Erik Andersen <andersen@uclibc.org>
5  *
6  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
7  */
8
9 #include <netinet/in.h>
10
11 #undef ntohl
12 #undef ntohs
13 #undef htonl
14 #undef htons
15
16 #if __BYTE_ORDER != __BIG_ENDIAN && __BYTE_ORDER != __LITTLE_ENDIAN
17 # error "You seem to have an unsupported byteorder"
18 #endif
19
20 uint32_t ntohl (uint32_t x)
21 {
22 #if __BYTE_ORDER == __BIG_ENDIAN
23         return x;
24 #else
25         return __bswap_32(x);
26 #endif
27 }
28 libc_hidden_def(ntohl)
29 strong_alias(ntohl,htonl)
30 libc_hidden_def(htonl)
31
32 uint16_t ntohs (uint16_t x)
33 {
34 #if __BYTE_ORDER == __BIG_ENDIAN
35         return x;
36 #else
37         return __bswap_16(x);
38 #endif
39 }
40 libc_hidden_def(ntohs)
41 strong_alias(ntohs,htons)
42 libc_hidden_def(htons)