summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/ntohs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/net/ntohs.c')
-rw-r--r--src/lib/libc/net/ntohs.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/lib/libc/net/ntohs.c b/src/lib/libc/net/ntohs.c
index 93ab83ee4d..4c3ab33f31 100644
--- a/src/lib/libc/net/ntohs.c
+++ b/src/lib/libc/net/ntohs.c
@@ -1,26 +1,23 @@
1/* $NetBSD: ntohs.c,v 1.5 1995/04/28 23:25:23 jtc Exp $ */
2
3/* 1/*
4 * Written by J.T. Conklin <jtc@netbsd.org>. 2 * Written by J.T. Conklin <jtc@netbsd.org>.
5 * Public domain. 3 * Public domain.
6 */ 4 */
7 5
8#if defined(LIBC_SCCS) && !defined(lint) 6#if defined(LIBC_SCCS) && !defined(lint)
9static char *rcsid = "$NetBSD: ntohs.c,v 1.5 1995/04/28 23:25:23 jtc Exp $"; 7static char *rcsid = "$OpenBSD: ntohs.c,v 1.7 2002/02/19 19:39:36 millert Exp $";
10#endif 8#endif /* LIBC_SCCS and not lint */
11 9
12#include <sys/types.h> 10#include <sys/types.h>
13#include <machine/endian.h> 11#include <machine/endian.h>
14 12
15#undef ntohs 13#undef ntohs
16 14
17unsigned short 15u_int16_t
18ntohs(x) 16ntohs(u_int16_t x)
19 unsigned short x;
20{ 17{
21#if BYTE_ORDER == LITTLE_ENDIAN 18#if BYTE_ORDER == LITTLE_ENDIAN
22 u_char *s = (u_char *) &x; 19 u_char *s = (u_char *) &x;
23 return s[0] << 8 | s[1]; 20 return (u_int16_t)(s[0] << 8 | s[1]);
24#else 21#else
25 return x; 22 return x;
26#endif 23#endif