Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
xcc.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_TOOLCHAIN_XCC_H_
8#define ZEPHYR_INCLUDE_TOOLCHAIN_XCC_H_
9
10/* toolchain/gcc.h errors out if __BYTE_ORDER__ cannot be determined
11 * there. However, __BYTE_ORDER__ is actually being defined later in
12 * this file. So define __BYTE_ORDER__ to skip the check in gcc.h
13 * and undefine after including gcc.h.
14 *
15 * Clang has it defined so there is no need to work around.
16 */
17#ifndef __clang__
18#define __BYTE_ORDER__
19#endif
20
21#include <toolchain/gcc.h>
22
23#ifndef __clang__
24#undef __BYTE_ORDER__
25#endif
26
27#include <stdbool.h>
28
29#ifndef __INT8_C
30#define __INT8_C(x) x
31#endif
32
33#ifndef INT8_C
34#define INT8_C(x) __INT8_C(x)
35#endif
36
37#ifndef __UINT8_C
38#define __UINT8_C(x) x ## U
39#endif
40
41#ifndef UINT8_C
42#define UINT8_C(x) __UINT8_C(x)
43#endif
44
45#ifndef __INT16_C
46#define __INT16_C(x) x
47#endif
48
49#ifndef INT16_C
50#define INT16_C(x) __INT16_C(x)
51#endif
52
53#ifndef __UINT16_C
54#define __UINT16_C(x) x ## U
55#endif
56
57#ifndef UINT16_C
58#define UINT16_C(x) __UINT16_C(x)
59#endif
60
61#ifndef __INT32_C
62#define __INT32_C(x) x
63#endif
64
65#ifndef INT32_C
66#define INT32_C(x) __INT32_C(x)
67#endif
68
69#ifndef __UINT32_C
70#define __UINT32_C(x) x ## U
71#endif
72
73#ifndef UINT32_C
74#define UINT32_C(x) __UINT32_C(x)
75#endif
76
77#ifndef __INT64_C
78#define __INT64_C(x) x
79#endif
80
81#ifndef INT64_C
82#define INT64_C(x) __INT64_C(x)
83#endif
84
85#ifndef __UINT64_C
86#define __UINT64_C(x) x ## ULL
87#endif
88
89#ifndef UINT64_C
90#define UINT64_C(x) __UINT64_C(x)
91#endif
92
93#ifndef __INTMAX_C
94#define __INTMAX_C(x) x
95#endif
96
97#ifndef INTMAX_C
98#define INTMAX_C(x) __INTMAX_C(x)
99#endif
100
101#ifndef __UINTMAX_C
102#define __UINTMAX_C(x) x ## ULL
103#endif
104
105#ifndef UINTMAX_C
106#define UINTMAX_C(x) __UINTMAX_C(x)
107#endif
108
109#ifndef __COUNTER__
110/* XCC (GCC-based compiler) doesn't support __COUNTER__
111 * but this should be good enough
112 */
113#define __COUNTER__ __LINE__
114#endif
115
116#undef __in_section_unique
117#define __in_section_unique(seg) \
118 __attribute__((section("." STRINGIFY(seg) "." STRINGIFY(__COUNTER__))))
119
120#ifndef __GCC_LINKER_CMD__
121#include <xtensa/config/core.h>
122
123/*
124 * XCC does not define the following macros with the expected names, but the
125 * HAL defines similar ones. Thus we include it and define the missing macros
126 * ourselves.
127 */
128#if XCHAL_MEMORY_ORDER == XTHAL_BIGENDIAN
129#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
130#elif XCHAL_MEMORY_ORDER == XTHAL_LITTLEENDIAN
131#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
132#else
133#error "Cannot determine __BYTE_ORDER__"
134#endif
135
136#endif /* __GCC_LINKER_CMD__ */
137
138#define __builtin_unreachable() do { __ASSERT(false, "Unreachable code"); } \
139 while (true)
140
141#ifdef __deprecated
142/*
143 * XCC does not support using deprecated attribute in enum,
144 * so just nullify it here to avoid compilation errors.
145 */
146#undef __deprecated
147#define __deprecated
148#endif
149
150#endif
GCC toolchain abstraction.