move __BYTE_ORDER definition to alltypes.h
authorRich Felker <dalias@aerifal.cx>
Thu, 17 Oct 2019 19:40:16 +0000 (15:40 -0400)
committerRich Felker <dalias@aerifal.cx>
Thu, 17 Oct 2019 19:55:15 +0000 (15:55 -0400)
commit97d35a552ec5b6ddf7923dd2f9a8eb973526acea
tree5cdbf3c58a4fb7eae7257f69f6d9d5d0aaee2a0e
parent00ec11d19e7c5fc99b5383233510c60a565cb01b
move __BYTE_ORDER definition to alltypes.h

this change is motivated by the intersection of several factors.
presently, despite being a nonstandard header, endian.h is exposing
the unprefixed byte order macros and functions only if _BSD_SOURCE or
_GNU_SOURCE is defined. this is to accommodate use of endian.h from
other headers, including bits headers, which need to define structure
layout in terms of endianness. with time64 switch-over, even more
headers will need to do this.

at the same time, the resolution of Austin Group issue 162 makes
endian.h a standard header for POSIX-future, requiring that it expose
the unprefixed macros and the functions even in standards-conforming
profiles. changes to meet this new requirement would break existing
internal usage of endian.h by causing it to violate namespace where
it's used.

instead, have the arch's alltypes.h define __BYTE_ORDER, either as a
fixed constant or depending on the right arch-specific predefined
macros for determining endianness. explicit literals 1234 and 4321 are
used instead of __LITTLE_ENDIAN and __BIG_ENDIAN so that there's no
danger of getting the wrong result if a macro is undefined and
implicitly evaluates to 0 at the preprocessor level.

the powerpc (32-bit) bits/endian.h being removed had logic for varying
endianness, but our powerpc arch has never supported that and has
always been big-endian-only. this logic is not carried over to the new
__BYTE_ORDER definition in alltypes.h.
34 files changed:
arch/aarch64/bits/alltypes.h.in
arch/aarch64/bits/endian.h [deleted file]
arch/arm/bits/alltypes.h.in
arch/arm/bits/endian.h [deleted file]
arch/i386/bits/alltypes.h.in
arch/i386/bits/endian.h [deleted file]
arch/m68k/bits/alltypes.h.in
arch/m68k/bits/endian.h [deleted file]
arch/microblaze/bits/alltypes.h.in
arch/microblaze/bits/endian.h [deleted file]
arch/mips/bits/alltypes.h.in
arch/mips/bits/endian.h [deleted file]
arch/mips64/bits/alltypes.h.in
arch/mips64/bits/endian.h [deleted file]
arch/mipsn32/bits/alltypes.h.in
arch/mipsn32/bits/endian.h [deleted file]
arch/or1k/bits/alltypes.h.in
arch/or1k/bits/endian.h [deleted file]
arch/powerpc/bits/alltypes.h.in
arch/powerpc/bits/endian.h [deleted file]
arch/powerpc64/bits/alltypes.h.in
arch/powerpc64/bits/endian.h [deleted file]
arch/riscv64/bits/alltypes.h.in
arch/riscv64/bits/endian.h [deleted file]
arch/s390x/bits/alltypes.h.in
arch/s390x/bits/endian.h [deleted file]
arch/sh/bits/alltypes.h.in
arch/sh/bits/endian.h [deleted file]
arch/x32/bits/alltypes.h.in
arch/x32/bits/endian.h [deleted file]
arch/x86_64/bits/alltypes.h.in
arch/x86_64/bits/endian.h [deleted file]
include/alltypes.h.in
include/endian.h