Subject: Re: bswap{16,32,64} in libutil ?
To: Manuel Bouyer <bouyer@antioche.lip6.fr>
From: Eduardo E. Horvath <eeh@one-o.com>
List: tech-userlevel
Date: 03/04/1998 09:00:29
On Wed, 4 Mar 1998, Manuel Bouyer wrote:

> Hi,
> In order to have all the ffs utilities be usable on both big and
> little endian filesystems, I need the bswap16, bswap32 and bswap64 functions
> I introdused to libkern some time ago.
> bswap16 and bswap32 are already used by fsck_ext2fs. These functions are
> in src/sbin/fsck/bswap.c, which is pulled by a .PATH directive in
> the makefile of utilities which needs it.

Is it possible to break these functions down into "store as little-endian"
and "store as big endian"?  There are architectures where this is a big
performance issue.  Byte swapping on SPARC V9 machines is a complicated
process involving lots of shifts and masking, but storing to a particular
endianness is practically a NOP.  Machines that really do swaps can
have one set of macros as NOPs and the others do the swap.  (Or do I just
assume that the only time bswap*() is called on a big endian machine is to
access little-endian data and vice-versa?)

=========================================================================
Eduardo Horvath				eeh@one-o.com
"Cliffs are for climbing.  That's why God invented grappling hooks."
					- Benton Frasier