big-endian. i386, pc532 and vax still include <machine/byte_swap.h>
and define macros for the {n,h}to{h,n}*() functions. mips also
defines some endian-independent assembly-code aliases for unaligned
memory accesses.
minor of libc and the major of libutil). For little-endian architectures
merge the bnswap() assembly versions with nto* and hton* using symbols
aliasing. Use symbol renaming for the bswap function in this case to avoid
namespace pollution.
Declare bswap* in machine/bswap.h, not machine/endian.h. For little-endian
machines, common code for inline macros go in machine/byte_swap.h
Sync libkern with libc.
Adjust #include in kernel sources for machine/bswap.h.
expressions is a GNU C extension; mark as such them with __extension__ to
suppress portability warnings. Addresses kern/3562 and misc/6185, as suggested
by Dave Sainty <dave@dtsp.co.nz>.
Only assembly version for i386 bswap16 and bswap32 for now (bswap64 uses
bswap32). Contribution of assembly versions of these are welcome.
Add byte-swapping of ext2fs metadata for big-endian systems.
Tested on i386 and sparc.
Changing types from unsigned {long,short} to u_int{32,16}_t causes problems
in a lot of userlevel code because those types aren't defined when machine/
endian.h is included. And IMO including sys/types.h in machine/endian.h
is clearly wrong.
XPG4.2 defines new types in_addr_t and in_port_t for the {h,n}to{n,h}{l,s}
functions. But we don't have time to figure out the implementation issues
given the current release schedule.
faster (on the i486 & i586) rorw $8, %w1. The inline assembly for GCC 1.X
already used rorw. Using rorw is one byte longer, but we wouldn't be
inlining at all if we weren't optimizing for speed.
Use GCC's inline assembly iff we are using GCC.
Use bswap instruction if using gcc and defined(KERNEL) &&
((defined(I486_CPU) || defined(I586_CPU)) && !defined(I386_CPU))