summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/ntohl.c
diff options
context:
space:
mode:
authornaddy <>2024-04-15 14:30:48 +0000
committernaddy <>2024-04-15 14:30:48 +0000
commitf7646eb021595fb6f85c38b99e043277fa2436bc (patch)
tree161adc5a1fbde78ccfb6b293bd0da5239b8b5045 /src/lib/libc/net/ntohl.c
parent22372f5970deb0d15444f4ce803b5a44934b22e5 (diff)
downloadopenbsd-f7646eb021595fb6f85c38b99e043277fa2436bc.tar.gz
openbsd-f7646eb021595fb6f85c38b99e043277fa2436bc.tar.bz2
openbsd-f7646eb021595fb6f85c38b99e043277fa2436bc.zip
drop htonl(), htons(), ntohl(), ntohs() MD functions from libc
Userland code compiled in a normal fashion picks up the htonl(), htons(), ntohl(), ntohs() macros implemented by endian.h. The functions in libc are effectively unused. Keep the MI functions in case something looks for the symbols in libc or plays games with #undef, but change them to wrap the implementation from endian.h. tweaks suggested by claudio@, ok miod@
Diffstat (limited to '')
-rw-r--r--src/lib/libc/net/ntohl.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/lib/libc/net/ntohl.c b/src/lib/libc/net/ntohl.c
index 0d05bac78a..7592398e8c 100644
--- a/src/lib/libc/net/ntohl.c
+++ b/src/lib/libc/net/ntohl.c
@@ -1,6 +1,5 @@
1/* $OpenBSD: ntohl.c,v 1.7 2014/07/21 01:51:10 guenther Exp $ */ 1/* $OpenBSD: ntohl.c,v 1.8 2024/04/15 14:30:48 naddy Exp $ */
2/* 2/*
3 * Written by J.T. Conklin <jtc@netbsd.org>.
4 * Public domain. 3 * Public domain.
5 */ 4 */
6 5
@@ -9,13 +8,8 @@
9 8
10#undef ntohl 9#undef ntohl
11 10
12u_int32_t 11uint32_t
13ntohl(u_int32_t x) 12ntohl(uint32_t x)
14{ 13{
15#if BYTE_ORDER == LITTLE_ENDIAN 14 return be32toh(x);
16 u_char *s = (u_char *)&x;
17 return (u_int32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
18#else
19 return x;
20#endif
21} 15}