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