2017-05-11 04:28:38 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Intel Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#ifndef ZEPHYR_INCLUDE_TOOLCHAIN_XCC_H_
|
|
|
|
#define ZEPHYR_INCLUDE_TOOLCHAIN_XCC_H_
|
2017-05-11 04:28:38 +08:00
|
|
|
|
2019-11-26 04:14:41 +08:00
|
|
|
/* toolchain/gcc.h errors out if __BYTE_ORDER__ cannot be determined
|
|
|
|
* there. However, __BYTE_ORDER__ is actually being defined later in
|
|
|
|
* this file. So define __BYTE_ORDER__ to skip the check in gcc.h
|
|
|
|
* and undefine after including gcc.h.
|
2019-12-17 09:26:54 +08:00
|
|
|
*
|
|
|
|
* Clang has it defined so there is no need to work around.
|
2019-11-26 04:14:41 +08:00
|
|
|
*/
|
2019-12-17 09:26:54 +08:00
|
|
|
#ifndef __clang__
|
2019-11-26 04:14:41 +08:00
|
|
|
#define __BYTE_ORDER__
|
2019-12-17 09:26:54 +08:00
|
|
|
#endif
|
|
|
|
|
2017-05-11 04:28:38 +08:00
|
|
|
#include <toolchain/gcc.h>
|
2019-12-17 09:26:54 +08:00
|
|
|
|
|
|
|
#ifndef __clang__
|
2019-11-26 04:14:41 +08:00
|
|
|
#undef __BYTE_ORDER__
|
2019-12-17 09:26:54 +08:00
|
|
|
#endif
|
2019-11-26 04:14:41 +08:00
|
|
|
|
2018-11-22 08:12:49 +08:00
|
|
|
#include <stdbool.h>
|
2017-05-11 04:28:38 +08:00
|
|
|
|
2019-12-17 01:35:03 +08:00
|
|
|
#ifndef UINT32_C
|
|
|
|
#define UINT32_C(x) x ## U
|
|
|
|
#endif
|
|
|
|
|
2019-12-17 09:26:54 +08:00
|
|
|
#ifndef __COUNTER__
|
|
|
|
/* XCC (GCC-based compiler) doesn't support __COUNTER__
|
|
|
|
* but this should be good enough
|
|
|
|
*/
|
2017-08-15 04:26:23 +08:00
|
|
|
#define __COUNTER__ __LINE__
|
2019-12-17 09:26:54 +08:00
|
|
|
#endif
|
2017-08-15 04:26:23 +08:00
|
|
|
|
|
|
|
#undef __in_section_unique
|
|
|
|
#define __in_section_unique(seg) \
|
|
|
|
__attribute__((section("." STRINGIFY(seg) "." STRINGIFY(__COUNTER__))))
|
|
|
|
|
2017-05-11 04:28:38 +08:00
|
|
|
#ifndef __GCC_LINKER_CMD__
|
|
|
|
#include <xtensa/config/core.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XCC does not define the following macros with the expected names, but the
|
|
|
|
* HAL defines similar ones. Thus we include it and define the missing macros
|
|
|
|
* ourselves.
|
|
|
|
*/
|
2019-11-26 04:14:41 +08:00
|
|
|
#if XCHAL_MEMORY_ORDER == XTHAL_BIGENDIAN
|
|
|
|
#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
|
|
|
|
#elif XCHAL_MEMORY_ORDER == XTHAL_LITTLEENDIAN
|
|
|
|
#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
|
|
|
|
#else
|
|
|
|
#error "Cannot determine __BYTE_ORDER__"
|
2017-05-11 04:28:38 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __GCC_LINKER_CMD__ */
|
|
|
|
|
2018-11-22 08:12:49 +08:00
|
|
|
#define __builtin_unreachable() do { __ASSERT(false, "Unreachable code"); } \
|
2018-11-02 04:27:03 +08:00
|
|
|
while (true)
|
2017-12-13 01:59:37 +08:00
|
|
|
|
2017-05-11 04:28:38 +08:00
|
|
|
#endif
|