summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/ntohs.c
diff options
context:
space:
mode:
authorderaadt <>1995-10-18 08:42:23 +0000
committerderaadt <>1995-10-18 08:42:23 +0000
commit0527d29da443886d92e9a418180c5b25a5f8d270 (patch)
tree86b3a64928451a669cefa27900e5884036b4e349 /src/lib/libc/net/ntohs.c
downloadopenbsd-0527d29da443886d92e9a418180c5b25a5f8d270.tar.gz
openbsd-0527d29da443886d92e9a418180c5b25a5f8d270.tar.bz2
openbsd-0527d29da443886d92e9a418180c5b25a5f8d270.zip
initial import of NetBSD tree
Diffstat (limited to 'src/lib/libc/net/ntohs.c')
-rw-r--r--src/lib/libc/net/ntohs.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lib/libc/net/ntohs.c b/src/lib/libc/net/ntohs.c
new file mode 100644
index 0000000000..93ab83ee4d
--- /dev/null
+++ b/src/lib/libc/net/ntohs.c
@@ -0,0 +1,27 @@
1/* $NetBSD: ntohs.c,v 1.5 1995/04/28 23:25:23 jtc Exp $ */
2
3/*
4 * Written by J.T. Conklin <jtc@netbsd.org>.
5 * Public domain.
6 */
7
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>
13#include <machine/endian.h>
14
15#undef ntohs
16
17unsigned short
18ntohs(x)
19 unsigned short x;
20{
21#if BYTE_ORDER == LITTLE_ENDIAN
22 u_char *s = (u_char *) &x;
23 return s[0] << 8 | s[1];
24#else
25 return x;
26#endif
27}