From f7646eb021595fb6f85c38b99e043277fa2436bc Mon Sep 17 00:00:00 2001 From: naddy <> Date: Mon, 15 Apr 2024 14:30:48 +0000 Subject: 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@ --- src/lib/libc/net/ntohl.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/lib/libc/net/ntohl.c') 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 @@ -/* $OpenBSD: ntohl.c,v 1.7 2014/07/21 01:51:10 guenther Exp $ */ +/* $OpenBSD: ntohl.c,v 1.8 2024/04/15 14:30:48 naddy Exp $ */ /* - * Written by J.T. Conklin . * Public domain. */ @@ -9,13 +8,8 @@ #undef ntohl -u_int32_t -ntohl(u_int32_t x) +uint32_t +ntohl(uint32_t x) { -#if BYTE_ORDER == LITTLE_ENDIAN - u_char *s = (u_char *)&x; - return (u_int32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]); -#else - return x; -#endif + return be32toh(x); } -- cgit v1.2.3-55-g6feb