From 0527d29da443886d92e9a418180c5b25a5f8d270 Mon Sep 17 00:00:00 2001 From: deraadt <> Date: Wed, 18 Oct 1995 08:42:23 +0000 Subject: initial import of NetBSD tree --- src/lib/libc/net/ntohs.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/lib/libc/net/ntohs.c (limited to 'src/lib/libc/net/ntohs.c') 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 @@ +/* $NetBSD: ntohs.c,v 1.5 1995/04/28 23:25:23 jtc Exp $ */ + +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char *rcsid = "$NetBSD: ntohs.c,v 1.5 1995/04/28 23:25:23 jtc Exp $"; +#endif + +#include +#include + +#undef ntohs + +unsigned short +ntohs(x) + unsigned short x; +{ +#if BYTE_ORDER == LITTLE_ENDIAN + u_char *s = (u_char *) &x; + return s[0] << 8 | s[1]; +#else + return x; +#endif +} -- cgit v1.2.3-55-g6feb