Subject: Re: bswap{16,32,64} in libutil ?
To: Eduardo E. Horvath <>
From: Manuel Bouyer <>
List: tech-userlevel
Date: 03/04/1998 18:21:04
On Mar 4, Eduardo E. Horvath wrote
> 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?)

If they also can do 'read as little-endian' and 'read as big endian', it will
be possible. If only store instructions are available, it will be harder,
as there are places where convertions are done 'on the fly', such as
 var = ufs_bswap32(ufs_bswap32(var) +1); /* formely vas var++ */

Manuel Bouyer, LIP6, Universite Paris VI.