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.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/lib/libc/net/ntohs.c b/src/lib/libc/net/ntohs.c
index 93ab83ee4d..8f345e84ad 100644
--- a/src/lib/libc/net/ntohs.c
+++ b/src/lib/libc/net/ntohs.c
@@ -1,26 +1,20 @@
1/* $NetBSD: ntohs.c,v 1.5 1995/04/28 23:25:23 jtc Exp $ */ 1/* $OpenBSD: ntohs.c,v 1.8 2005/08/06 20:30:03 espie Exp $ */
2
3/* 2/*
4 * Written by J.T. Conklin <jtc@netbsd.org>. 3 * Written by J.T. Conklin <jtc@netbsd.org>.
5 * Public domain. 4 * Public domain.
6 */ 5 */
7 6
8#if defined(LIBC_SCCS) && !defined(lint)
9static char *rcsid = "$NetBSD: ntohs.c,v 1.5 1995/04/28 23:25:23 jtc Exp $";
10#endif
11
12#include <sys/types.h> 7#include <sys/types.h>
13#include <machine/endian.h> 8#include <machine/endian.h>
14 9
15#undef ntohs 10#undef ntohs
16 11
17unsigned short 12u_int16_t
18ntohs(x) 13ntohs(u_int16_t x)
19 unsigned short x;
20{ 14{
21#if BYTE_ORDER == LITTLE_ENDIAN 15#if BYTE_ORDER == LITTLE_ENDIAN
22 u_char *s = (u_char *) &x; 16 u_char *s = (u_char *) &x;
23 return s[0] << 8 | s[1]; 17 return (u_int16_t)(s[0] << 8 | s[1]);
24#else 18#else
25 return x; 19 return x;
26#endif 20#endif