This package consists of one command-line program and three subroutines for dealing with byte-ordering differences between machines. The command-line program byteorder determines the byte order of the host machine. Get_Endianness is the subroutine that does the actual work. The subroutines lswab and qswab swap the bytes of 4-byte and 8-byte integers respectively. They supplement the standard library routine swab(3), which only handles 2-byte integers.

Note that the gcc header file byteswap.h provides definitions for macros bswap_32 and bswap_64 which are likely to be faster than lswab and qswab, especially on machines with certain instruction sets. (To see what the macros do on your machine, inspect the actual macro definitions, which are in bits/byteswap.h.) The routines provided here should work regardless of the compiler and architecture, so long as a long int is 4 bytes and a long long int is 8 bytes. The routines provided here also do the swap in place, whereas the gcc macros return the swapped value.


LicenseGNU General Public License
Current version1.1
Last modified2007-02-26


Source tarball

Back to Bill Poser's software page.