bswap16.c revision 1.3
11.3Sjoerg/* $NetBSD: bswap16.c,v 1.3 2011/07/04 21:20:27 joerg 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.3Sjoerg__RCSID("$NetBSD: bswap16.c,v 1.3 2011/07/04 21:20:27 joerg 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.2Sapbuint16_t 191.3Sjoergbswap16(uint16_t x) 201.1Schristos{ 211.1Schristos return ((x << 8) & 0xff00) | ((x >> 8) & 0x00ff); 221.1Schristos} 23