summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/inet/ntohl.c54
1 files changed, 15 insertions, 39 deletions
diff --git a/libc/inet/ntohl.c b/libc/inet/ntohl.c
index 1a5863286..8e500a5e3 100644
--- a/libc/inet/ntohl.c
+++ b/libc/inet/ntohl.c
@@ -6,9 +6,6 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <stdint.h>
-#include <endian.h>
-#include <byteswap.h>
#include <netinet/in.h>
#undef ntohl
@@ -16,51 +13,30 @@
#undef htonl
#undef htons
-#if __BYTE_ORDER == __BIG_ENDIAN
-uint32_t ntohl (uint32_t x)
-{
- return x;
-}
-
-uint16_t ntohs (uint16_t x)
-{
- return x;
-}
-
-uint32_t htonl (uint32_t x)
-{
- return x;
-}
+#if __BYTE_ORDER != __BIG_ENDIAN && __BYTE_ORDER != __LITTLE_ENDIAN
+# error "You seem to have an unsupported byteorder"
+#endif
-uint16_t htons (uint16_t x)
-{
- return x;
-}
-#elif __BYTE_ORDER == __LITTLE_ENDIAN
uint32_t ntohl (uint32_t x)
{
+#if __BYTE_ORDER == __BIG_ENDIAN
+ return x;
+#else
return __bswap_32(x);
+#endif
}
+libc_hidden_def(ntohl)
+strong_alias(ntohl,htonl)
+libc_hidden_def(htonl)
uint16_t ntohs (uint16_t x)
{
- return __bswap_16(x);
-}
-
-uint32_t htonl (uint32_t x)
-{
- return __bswap_32(x);
-}
-
-uint16_t htons (uint16_t x)
-{
- return __bswap_16(x);
-}
+#if __BYTE_ORDER == __BIG_ENDIAN
+ return x;
#else
-#error "You seem to have an unsupported byteorder"
+ return __bswap_16(x);
#endif
-
-libc_hidden_def(ntohl)
+}
libc_hidden_def(ntohs)
-libc_hidden_def(htonl)
+strong_alias(ntohs,htons)
libc_hidden_def(htons)