diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib/libc/net/htonl.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/lib/libc/net/htonl.c b/src/lib/libc/net/htonl.c index 6ee6e7efbf..58bfb4699a 100644 --- a/src/lib/libc/net/htonl.c +++ b/src/lib/libc/net/htonl.c | |||
@@ -1,6 +1,5 @@ | |||
1 | /* $OpenBSD: htonl.c,v 1.7 2014/07/21 01:51:10 guenther Exp $ */ | 1 | /* $OpenBSD: htonl.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 htonl | 9 | #undef htonl |
11 | 10 | ||
12 | u_int32_t | 11 | uint32_t |
13 | htonl(u_int32_t x) | 12 | htonl(uint32_t x) |
14 | { | 13 | { |
15 | #if BYTE_ORDER == LITTLE_ENDIAN | 14 | return htobe32(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 | } |