Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

endian.h: Guard against __{BIG,LITTLE}_ENDIAN being defined #114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bsdimp
Copy link

@bsdimp bsdimp commented May 6, 2024

When compiled on FreeBSD, we get both __LITTLE_ENDIAN and __BIG_ENDIAN defined. glibc defines these as well, but it defines them to 1234 and
4321. However, FreeBSD defines them to ORDER_LITTLE_ENDIAN and ORDER_BIG_ENDIAN to take advantage of the recent gcc and clang predefines. Check to see if __LITTLE_ENDIAN is defined before we redefine it. This is less than perfect, I'll grant, but anything starting with __ is in the implementation namespace so some care needs to be taken.

When compiled on FreeBSD, we get both __LITTLE_ENDIAN and __BIG_ENDIAN
defined. glibc defines these as well, but it defines them to 1234 and
4321. However, FreeBSD defines them to __ORDER_LITTLE_ENDIAN__ and
__ORDER_BIG_ENDIAN__ to take advantage of the recent gcc and clang
predefines. Check to see if __LITTLE_ENDIAN is defined before we
redefine it. This is less than perfect, I'll grant, but anything
starting with __ is in the implementation namespace so some care needs
to be taken.

Signed-off-by: Warner Losh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants