bswap64.c revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/* $NetBSD: bswap64.c,v 1.1 2005/12/20 19:28:51 christos Exp $ */
/*
* Written by Manuel Bouyer <bouyer@NetBSD.org>.
* Public domain.
*/
//#if defined(LIBC_SCCS) && !defined(lint)
//__RCSID("$NetBSD: bswap64.c,v 1.1 2005/12/20 19:28:51 christos Exp $");
//#endif /* LIBC_SCCS and not lint */
{
#ifndef _LP64
/*
* Assume we have wide enough registers to do it without touching
* memory.
*/
return ( (x << 56) & 0xff00000000000000UL ) |
( (x << 40) & 0x00ff000000000000UL ) |
( (x << 24) & 0x0000ff0000000000UL ) |
( (x << 8) & 0x000000ff00000000UL ) |
( (x >> 8) & 0x00000000ff000000UL ) |
( (x >> 24) & 0x0000000000ff0000UL ) |
( (x >> 40) & 0x000000000000ff00UL ) |
( (x >> 56) & 0x00000000000000ffUL );
#else
/*
* Split the operation in two 32bit steps.
*/
#endif
}