Subject: bswap{16,32,64} in libutil ?
To: None <tech-userlevel@NetBSD.ORG>
From: Manuel Bouyer <>
List: tech-userlevel
Date: 03/04/1998 17:03:15
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.
Now, there are much more utilities that will need it than I originally
thouh: badsect, clri, dump, fsck_ffs, fsdb, fsirand, newfs, tunefs, dumpfs,
quotacheck (If I missed some, tell me !) So it could make sense to include
these 3 functions to libutil. 
These functions are prototyped in machine/endian.h, so that they can
be overriden by __inlines or macro on ports which can have small assembly
versions of these.

Also nearly all these utilities make use of ffs specific functions defined
in sys/ufs/ffs/ffs_bswap.c, and all Makefiles pull this file from here.
I don't think this one could have a place in a userland library.

Any comments ?
Also, does POSIX says something about such functions ?

Manuel Bouyer, LIP6, Universite Paris VI.