Subject: hto{le,be}{16,32,64}() - a plan
To: None <,>
From: Simon Burge <>
List: tech-kern
Date: 08/08/1999 01:31:52
Further to the discussion about two months ago about making functions
available to convert to/from big- and little-endian formats, I've put
together the following:

 + Rationalise the <machine/endian.h> files.  Most of them
   only contain a fragment like:


	#include <sys/endian.h>

	#endif /* !_MACHINE_ENDIAN_H_ */

   A few of them (i386, pc532 and vax) also include #defines
   for using the __byte_swap_{word,long} functions.  The mips
   endian.h also includes a few assembler macros.

 + The same is done for the <machine/bswap.h> files.

 + There's some ugliness so that either <sys/endian.h> or
   <machine/endian.h> can be included, and the right thing
   happens (and the same for bswap.h).  It seemed rather
   backward to have a common header in sys/, but not being
   able to directly include it.

The only thing I think that needs to be resolved is why some ports
rename bswap{16,32} to __bswap{16,32} - wouldn't it have been easier
to define both entry points to those routines?  Even weirder is
that bswap64 isn't renamed...  For now, I've got the ports that do
symbol renaming in userland defining __BSWAP_RENAME before include

I've put a tar file of the relevent files in:
since the diffs are huge since most MD files are gutted, and the
raw files come to about 900-odd lines.

To answer a few miscellaneous questions, I couldn't find anything in C9X
or other OS's that perform these sorts of funtions.  I'd like to get
this in soon, and that should allow me to then finish making /usr/share