2012-11-15 12:06:41 +01:00
|
|
|
/* $NetBSD: bswap32.c,v 1.3 2011/07/04 21:20:27 joerg Exp $ */
|
2011-02-14 20:36:03 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Written by Manuel Bouyer <bouyer@NetBSD.org>.
|
|
|
|
* Public domain.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#if defined(LIBC_SCCS) && !defined(lint)
|
2012-11-15 12:06:41 +01:00
|
|
|
__RCSID("$NetBSD: bswap32.c,v 1.3 2011/07/04 21:20:27 joerg Exp $");
|
2011-02-14 20:36:03 +01:00
|
|
|
#endif /* LIBC_SCCS and not lint */
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <machine/bswap.h>
|
|
|
|
|
|
|
|
#undef bswap32
|
|
|
|
|
|
|
|
uint32_t
|
2012-11-15 12:06:41 +01:00
|
|
|
bswap32(uint32_t x)
|
2011-02-14 20:36:03 +01:00
|
|
|
{
|
|
|
|
return ((x << 24) & 0xff000000 ) |
|
|
|
|
((x << 8) & 0x00ff0000 ) |
|
|
|
|
((x >> 8) & 0x0000ff00 ) |
|
|
|
|
((x >> 24) & 0x000000ff );
|
|
|
|
}
|