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/ntohs.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/lib/libc/net/ntohs.c') diff --git a/src/lib/libc/net/ntohs.c b/src/lib/libc/net/ntohs.c index b5ea361f83..ef22ea3068 100644 --- a/src/lib/libc/net/ntohs.c +++ b/src/lib/libc/net/ntohs.c @@ -1,6 +1,5 @@ -/* $OpenBSD: ntohs.c,v 1.9 2014/07/21 01:51:10 guenther Exp $ */ +/* $OpenBSD: ntohs.c,v 1.10 2024/04/15 14:30:48 naddy Exp $ */ /* - * Written by J.T. Conklin . * Public domain. */ @@ -9,13 +8,8 @@ #undef ntohs -u_int16_t -ntohs(u_int16_t x) +uint16_t +ntohs(uint16_t x) { -#if BYTE_ORDER == LITTLE_ENDIAN - u_char *s = (u_char *) &x; - return (u_int16_t)(s[0] << 8 | s[1]); -#else - return x; -#endif + return be16toh(x); } -- cgit v1.2.3-55-g6feb