bswap16.c revision 1.1
11.1Schristos/* $NetBSD: bswap16.c,v 1.1 2005/12/20 19:28:51 christos Exp $ */ 21.1Schristos 31.1Schristos/* 41.1Schristos * Written by Manuel Bouyer <bouyer@NetBSD.org>. 51.1Schristos * Public domain. 61.1Schristos */ 71.1Schristos 81.1Schristos#include <sys/cdefs.h> 91.1Schristos#if defined(LIBC_SCCS) && !defined(lint) 101.1Schristos__RCSID("$NetBSD: bswap16.c,v 1.1 2005/12/20 19:28:51 christos Exp $"); 111.1Schristos#endif /* LIBC_SCCS and not lint */ 121.1Schristos 131.1Schristos#include <sys/types.h> 141.1Schristos#include <machine/bswap.h> 151.1Schristos 161.1Schristos#undef bswap16 171.1Schristos 181.1Schristosu_int16_t 191.1Schristosbswap16(x) 201.1Schristos u_int16_t x; 211.1Schristos{ 221.1Schristos return ((x << 8) & 0xff00) | ((x >> 8) & 0x00ff); 231.1Schristos} 24