toolchain: Ensure that Kconfig endianness matches the compiler's

In preparation for using CONFIG_(BIG|LITTLE)_ENDIAN exclusively for
endianness-based conditional compilation in the tree, ensure that the
Kconfig CONFIG_(BIG|LITTLE)_ENDIAN options match the compiler's
__BYTE_ORDER__ macro.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit is contained in:
Carles Cufi
2022-10-26 17:08:31 +02:00
committed by Stephanos Ioannidis
parent ab05448307
commit ae123c9bd1

View File

@@ -117,8 +117,8 @@
/*
* Ensure that __BYTE_ORDER__ and related preprocessor definitions are defined,
* as these are often used without checking for definition and doing so can
* cause unexpected behaviours.
* and that they match the Kconfig option that is used in the code itself to
* check for endianness.
*/
#ifndef _LINKER
#if !defined(__BYTE_ORDER__) || !defined(__ORDER_BIG_ENDIAN__) || \
@@ -126,6 +126,13 @@
#error "__BYTE_ORDER__ is not defined"
#else
#if (defined(CONFIG_BIG_ENDIAN) && (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__)) || \
(defined(CONFIG_LITTLE_ENDIAN) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__))
#error "Endiannes mismatch"
#endif
#endif
#endif /* !_LINKER */