xref: /netbsd-src/common/lib/libc/gen/bswap16.c (revision 82d56013d7b633d116a93943de88e08335357a7c)
1 /*  $NetBSD: bswap16.c,v 1.4 2012/03/17 20:57:35 martin Exp $    */
2 
3 /*
4  * Written by Manuel Bouyer <bouyer@NetBSD.org>.
5  * Public domain.
6  */
7 
8 #include <sys/cdefs.h>
9 #if defined(LIBC_SCCS) && !defined(lint)
10 __RCSID("$NetBSD: bswap16.c,v 1.4 2012/03/17 20:57:35 martin Exp $");
11 #endif /* LIBC_SCCS and not lint */
12 
13 #include <sys/types.h>
14 #include <machine/bswap.h>
15 
16 #undef bswap16
17 
18 uint16_t
19 bswap16(uint16_t x)
20 {
21 	/*LINTED*/
22 	return ((x << 8) & 0xff00) | ((x >> 8) & 0x00ff);
23 }
24