1999-01-15 16:31:15 +03:00
|
|
|
/* $NetBSD: bswap32.c,v 1.2 1999/01/15 13:31:28 bouyer Exp $ */
|
1997-10-09 19:42:19 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Written by Manuel Bouyer <bouyer@netbsd.org>.
|
|
|
|
* Public domain.
|
|
|
|
*/
|
|
|
|
|
1999-01-15 16:31:15 +03:00
|
|
|
#include <sys/cdefs.h>
|
1997-10-09 19:42:19 +04:00
|
|
|
#if defined(LIBC_SCCS) && !defined(lint)
|
1999-01-15 16:31:15 +03:00
|
|
|
__RCSID("$NetBSD: bswap32.c,v 1.2 1999/01/15 13:31:28 bouyer Exp $");
|
|
|
|
#endif /* LIBC_SCCS and not lint */
|
1997-10-09 19:42:19 +04:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
1999-01-15 16:31:15 +03:00
|
|
|
#include <machine/bswap.h>
|
1997-10-09 19:42:19 +04:00
|
|
|
|
|
|
|
#undef bswap32
|
|
|
|
|
|
|
|
u_int32_t
|
|
|
|
bswap32(x)
|
1999-01-15 16:31:15 +03:00
|
|
|
u_int32_t x;
|
1997-10-09 19:42:19 +04:00
|
|
|
{
|
1999-01-15 16:31:15 +03:00
|
|
|
return ((x << 24) & 0xff000000 ) |
|
|
|
|
((x << 8) & 0x00ff0000 ) |
|
|
|
|
((x >> 8) & 0x0000ff00 ) |
|
|
|
|
((x >> 24) & 0x000000ff );
|
1997-10-09 19:42:19 +04:00
|
|
|
}
|