HomeFreeBSD

Consolidate machine/endian.h definitions

Description

Consolidate machine/endian.h definitions

This change serves two purposes.

First, we take advantage of the compiler provided endian definitions to
eliminate some long-standing duplication between the different versions
of this header. BYTE_ORDER has been defined since GCC 4.6, so there
is no need to rely on platform defaults or e.g. MIPSEB to determine
endianness. A new common sub-header is added, but there should be no
changes to the visibility of these definitions.

Second, this eliminates the hand-rolled __bswapNN() routines, again in
favor of the compiler builtins. This was done already for x86 in
e6ff6154d203. The benefit here is that we no longer have to maintain our
own implementations on each arch, and can instead rely on the compiler
to emit appropriate instructions or libcalls, as available. This should
result in equivalent or better code generation. Notably 32-bit arm will
start using the rev instruction for these routines, which is available
on armv6+.

PR: 236920
Reviewed by: arichardson, imp
Tested by: bdragon (BE powerpc)
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D29012

Details

Provenance
mhorneAuthored on Mar 1 2021, 3:07 PM
Reviewer
arichardson
Differential Revision
D29012: Convert bswap primitives to builtins on !x86 archs
Parents
rG4233882f4ed3: security.7: fix typo in sysctl name
Branches
Unknown
Tags
Unknown