Zephyr Project API 4.4.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#ifndef __deprecated
19#define __deprecated
20#endif
21
22#define __in_section_unique(seg) \
23 __attribute__((section("." STRINGIFY(seg) "." STRINGIFY(__COUNTER__))))
24
25#define __in_section_unique_named(seg, name) \
26 __attribute__((section("." STRINGIFY(seg) \
27 "." STRINGIFY(__COUNTER__) \
28 "." STRINGIFY(name))))
29
30/* toolchain/gcc.h errors out if __BYTE_ORDER__ cannot be determined
31 * there. However, __BYTE_ORDER__ is actually being defined later in
32 * this file. So define __BYTE_ORDER__ to skip the check in gcc.h
33 * and undefine after including gcc.h.
34 *
35 * Clang has it defined so there is no need to work around.
36 */
37#ifndef __clang__
38#define __BYTE_ORDER__
39#endif
40
41#ifdef __clang__
43#else
45/* Cadence/Tensilica XCC pragma unroll support is unknown. */
46#undef TOOLCHAIN_PRAGMA_UNROLL
47#endif
48
49#ifdef __clang__
50/* For some reasons, xt-clang does not like "%hhd" or "%hd" (for example)
51 * being fed int data (same goes for unsigned ones) and will always complain
52 * about mismatched types. GCC and newer LLVM/Clang do not complain.
53 * This could be due to xt-clang being based on older LLVM/Clang.
54 * So skip the check.
55 */
56#ifdef __printf_like
57#undef __printf_like
58#define __printf_like(f, a)
59#endif
60#endif
61
62#ifndef __clang__
63#undef __BYTE_ORDER__
64#endif
65
66#include <stdbool.h>
67
68#ifndef __INT8_C
69#define __INT8_C(x) x
70#endif
71
72#ifndef INT8_C
73#define INT8_C(x) __INT8_C(x)
74#endif
75
76#ifndef __UINT8_C
77#define __UINT8_C(x) x ## U
78#endif
79
80#ifndef UINT8_C
81#define UINT8_C(x) __UINT8_C(x)
82#endif
83
84#ifndef __INT16_C
85#define __INT16_C(x) x
86#endif
87
88#ifndef INT16_C
89#define INT16_C(x) __INT16_C(x)
90#endif
91
92#ifndef __UINT16_C
93#define __UINT16_C(x) x ## U
94#endif
95
96#ifndef UINT16_C
97#define UINT16_C(x) __UINT16_C(x)
98#endif
99
100#ifndef __INT32_C
101#define __INT32_C(x) x
102#endif
103
104#ifndef INT32_C
105#define INT32_C(x) __INT32_C(x)
106#endif
107
108#ifndef __UINT32_C
109#define __UINT32_C(x) x ## U
110#endif
111
112#ifndef UINT32_C
113#define UINT32_C(x) __UINT32_C(x)
114#endif
115
116#ifndef __INT64_C
117#define __INT64_C(x) x
118#endif
119
120#ifndef INT64_C
121#define INT64_C(x) __INT64_C(x)
122#endif
123
124#ifndef __UINT64_C
125#define __UINT64_C(x) x ## ULL
126#endif
127
128#ifndef UINT64_C
129#define UINT64_C(x) __UINT64_C(x)
130#endif
131
132#ifndef __INTMAX_C
133#define __INTMAX_C(x) x
134#endif
135
136#ifndef INTMAX_C
137#define INTMAX_C(x) __INTMAX_C(x)
138#endif
139
140#ifndef __UINTMAX_C
141#define __UINTMAX_C(x) x ## ULL
142#endif
143
144#ifndef UINTMAX_C
145#define UINTMAX_C(x) __UINTMAX_C(x)
146#endif
147
148#ifndef __COUNTER__
149/* XCC (GCC-based compiler) doesn't support __COUNTER__
150 * but this should be good enough
151 */
152#define __COUNTER__ __LINE__
153#endif
154
155#ifndef __GCC_LINKER_CMD__
156#include <xtensa/config/core.h>
157
158/*
159 * XCC does not define the following macros with the expected names, but the
160 * HAL defines similar ones. Thus we include it and define the missing macros
161 * ourselves.
162 */
163#if XCHAL_MEMORY_ORDER == XTHAL_BIGENDIAN
164#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
165#elif XCHAL_MEMORY_ORDER == XTHAL_LITTLEENDIAN
166#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
167#else
168#error "Cannot determine __BYTE_ORDER__"
169#endif
170
171#endif /* __GCC_LINKER_CMD__ */
172
173#define __builtin_unreachable() __builtin_trap()
174
175/* Not a full barrier, just a SW barrier */
176#define __sync_synchronize() do { __asm__ __volatile__ ("" ::: "memory"); } \
177 while (false)
178
179#endif
GCC toolchain abstraction.