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/htons.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/lib/libc/net/htons.c') diff --git a/src/lib/libc/net/htons.c b/src/lib/libc/net/htons.c index f48d91ee03..28b13cef98 100644 --- a/src/lib/libc/net/htons.c +++ b/src/lib/libc/net/htons.c @@ -1,6 +1,5 @@ -/* $OpenBSD: htons.c,v 1.9 2014/07/21 01:51:10 guenther Exp $ */ +/* $OpenBSD: htons.c,v 1.10 2024/04/15 14:30:48 naddy Exp $ */ /* - * Written by J.T. Conklin . * Public domain. */ @@ -9,13 +8,8 @@ #undef htons -u_int16_t -htons(u_int16_t x) +uint16_t +htons(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 htobe16(x); } -- cgit v1.2.3-55-g6feb