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
Fails to detect endianness on 64-bit ARM #39
Comments
Thanks for reporting. The byte order check for #ifdef __ARMEL__
#define C4_BYTE_ORDER _C4EL
#elif defined(__ARMEB__)
#define C4_BYTE_ORDER _C4EB
#else
#error "unknown endianness"
#endif There are no tests for this architecture (or s390x) in the current pipeline, and although I intend to add them unfortunately I cannot work on that ATM. So can you confirm this (or something similar) fixes your problem? #if defined(__ARMEL__) || defined(__LITTLE_ENDIAN__) || defined(__AARCH64EL__) \
|| (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
#define C4_BYTE_ORDER _C4EL
#elif defined(__ARMEB__) || defined(__BIG_ENDIAN__) || defined(__AARCH64EB__) \
|| (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
#define C4_BYTE_ORDER _C4EB
#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_PDP_ENDIAN__)
#define C4_BYTE_ORDER _C4EM
#else
#error "unknown endianness"
#endif |
I added s390x tests to the CI (as well as aarch64 and ppc64le), and they succeed with this change. So the PR will close this. |
Thanks! I didn’t have a chance to test your change yet, but this is appreciated. |
On 64-bit ARM (
aarch64
), which can technically be little- or big-endian, since c233f40 the project cannot compile because the endianness is not successfully detected from predefined preprocessor macros.I’ve tested this on Linux, with recent (11.x) GCC, on little-endian
aarch64
.Perhaps it would help, across all architectures, to look for
__BYTE_ORDER__
and/or__FLOAT_WORD_ORDER__
, which may be defined to__ORDER_BIG_ENDIAN__
,__ORDER_LITTLE_ENDIAN__
, or (if you are cursed)__ORDER_PDP_ENDIAN__
. These are GCC-specific, but they allow you to tell which mode is in use on bi-endian architectures.Similarly, some toolchains (clang, I think) define
__BIG_ENDIAN__
or__LITTLE_ENDIAN__
. When present, they are conclusive.Finally, according to https://sourceforge.net/p/predef/wiki/Endianness/, some environments apparently define
__AARCH64EB__
or__AARCH64EL__
onaarch64
. These are not present on gcc/Linux.The text was updated successfully, but these errors were encountered: