1 /* $NetBSD: htons.c,v 1.10 2003/07/26 19:24:48 salo Exp $ */
4 * Written by J.T. Conklin <jtc@NetBSD.org>.
9 #if defined(LIBC_SCCS) && !defined(lint)
10 __RCSID("$NetBSD: htons.c,v 1.10 2003/07/26 19:24:48 salo Exp $");
13 #include <sys/types.h>
21 #if BYTE_ORDER == LITTLE_ENDIAN
22 u_char
*s
= (u_char
*) &x
;
23 return (uint16_t)(s
[0] << 8 | s
[1]);