1/* $NetBSD: bswap32.c,v 1.2 2008/02/16 17:37:13 apb 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: bswap32.c,v 1.2 2008/02/16 17:37:13 apb Exp $"); 11#endif /* LIBC_SCCS and not lint */ 12 13#include <sys/types.h> 14#include <machine/bswap.h> 15 16#undef bswap32 17 18uint32_t 19bswap32(uint32_t x) 20{ 21 return ((x << 24) & 0xff000000 ) | 22 ((x << 8) & 0x00ff0000 ) | 23 ((x >> 8) & 0x0000ff00 ) | 24 ((x >> 24) & 0x000000ff ); 25} 26