Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
 4.1.99
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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#ifdef __clang__
46/* For some reasons, xt-clang does not like "%hhd" or "%hd" (for example)
47 * being fed int data (same goes for unsigned ones) and will always complain
48 * about mismatched types. GCC and newer LLVM/Clang do not complain.
49 * This could be due to xt-clang being based on older LLVM/Clang.
50 * So skip the check.
51 */
52#ifdef __printf_like
53#undef __printf_like
54#define __printf_like(f, a)
55#endif
56#endif
57
58#ifndef __clang__
59#undef __BYTE_ORDER__
60#endif
61
62#include <stdbool.h>
63
64#ifndef __INT8_C
65#define __INT8_C(x) x
66#endif
67
68#ifndef INT8_C
69#define INT8_C(x) __INT8_C(x)
70#endif
71
72#ifndef __UINT8_C
73#define __UINT8_C(x) x ## U
74#endif
75
76#ifndef UINT8_C
77#define UINT8_C(x) __UINT8_C(x)
78#endif
79
80#ifndef __INT16_C
81#define __INT16_C(x) x
82#endif
83
84#ifndef INT16_C
85#define INT16_C(x) __INT16_C(x)
86#endif
87
88#ifndef __UINT16_C
89#define __UINT16_C(x) x ## U
90#endif
91
92#ifndef UINT16_C
93#define UINT16_C(x) __UINT16_C(x)
94#endif
95
96#ifndef __INT32_C
97#define __INT32_C(x) x
98#endif
99
100#ifndef INT32_C
101#define INT32_C(x) __INT32_C(x)
102#endif
103
104#ifndef __UINT32_C
105#define __UINT32_C(x) x ## U
106#endif
107
108#ifndef UINT32_C
109#define UINT32_C(x) __UINT32_C(x)
110#endif
111
112#ifndef __INT64_C
113#define __INT64_C(x) x
114#endif
115
116#ifndef INT64_C
117#define INT64_C(x) __INT64_C(x)
118#endif
119
120#ifndef __UINT64_C
121#define __UINT64_C(x) x ## ULL
122#endif
123
124#ifndef UINT64_C
125#define UINT64_C(x) __UINT64_C(x)
126#endif
127
128#ifndef __INTMAX_C
129#define __INTMAX_C(x) x
130#endif
131
132#ifndef INTMAX_C
133#define INTMAX_C(x) __INTMAX_C(x)
134#endif
135
136#ifndef __UINTMAX_C
137#define __UINTMAX_C(x) x ## ULL
138#endif
139
140#ifndef UINTMAX_C
141#define UINTMAX_C(x) __UINTMAX_C(x)
142#endif
143
144#ifndef __COUNTER__
145/* XCC (GCC-based compiler) doesn't support __COUNTER__
146 * but this should be good enough
147 */
148#define __COUNTER__ __LINE__
149#endif
150
151#ifndef __GCC_LINKER_CMD__
152#include <xtensa/config/core.h>
153
154/*
155 * XCC does not define the following macros with the expected names, but the
156 * HAL defines similar ones. Thus we include it and define the missing macros
157 * ourselves.
158 */
159#if XCHAL_MEMORY_ORDER == XTHAL_BIGENDIAN
160#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
161#elif XCHAL_MEMORY_ORDER == XTHAL_LITTLEENDIAN
162#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
163#else
164#error "Cannot determine __BYTE_ORDER__"
165#endif
166
167#endif /* __GCC_LINKER_CMD__ */
168
169#define __builtin_unreachable() __builtin_trap()
170
171/* Not a full barrier, just a SW barrier */
172#define __sync_synchronize() do { __asm__ __volatile__ ("" ::: "memory"); } \
173 while (false)
174
175#endif
GCC toolchain abstraction.