sys: Explicitly include toolchain.h to check for endianness definitions.

This commit adds an explicit inclusion of toolchain.h from byteorder.h.

The endianness preprocessor definitions (__BYTE_ORDER__,
__ORDER_LITTLE_ENDIAN__, __ORDER_BIG_ENDIAN__) are used by byteorder.h;
these being not defined can easily go unnoticed and cause unexpected
behaviours, as detailed in PR #18922.

toolchain.h ensures that these preprocessor definitions are defined and
*must* be included in a file that uses these definitions.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
Stephanos Ioannidis 2019-09-09 21:34:47 +09:00 committed by Carles Cufí
parent 33fbe002d0
commit 07e9394dba

View file

@ -14,6 +14,7 @@
#include <zephyr/types.h>
#include <stddef.h>
#include <sys/__assert.h>
#include <toolchain.h>
/* Internal helpers only used by the sys_* APIs further below */
#define __bswap_16(x) ((u16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))