Zephyr Project API 4.1.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
toolchain.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010-2014, Wind River Systems, Inc.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
15#ifndef ZEPHYR_INCLUDE_TOOLCHAIN_H_
16#define ZEPHYR_INCLUDE_TOOLCHAIN_H_
17
25#ifdef __has_builtin
26#define HAS_BUILTIN(x) __has_builtin(x)
27#else
28/*
29 * The compiler doesn't provide the __has_builtin() macro, so instead we depend
30 * on the toolchain-specific headers to define HAS_BUILTIN_x for the builtins
31 * supported.
32 */
33#define HAS_BUILTIN(x) HAS_BUILTIN_##x
34#endif
35
36#if defined(__TOOLCHAIN_CUSTOM__)
37/* This include line exists for off-tree definitions of compilers,
38 * and therefore this header is not meant to exist in-tree
39 */
40#include <toolchain/other.h>
41#elif defined(__XCC__)
43#elif defined(__CCAC__)
45#elif defined(__ARMCOMPILER_VERSION)
47#elif defined(__IAR_SYSTEMS_ICC__)
49#elif defined(__llvm__) || (defined(_LINKER) && defined(__LLD_LINKER_CMD__))
51#elif defined(__GNUC__) || (defined(_LINKER) && defined(__GCC_LINKER_CMD__))
53#else
54#error "Invalid/unknown toolchain configuration"
55#endif
56
68#ifndef __noasan
69#define __noasan
70#endif
71
76#ifndef TOOLCHAIN_GCC_VERSION
77#define TOOLCHAIN_GCC_VERSION 0
78#endif
79
84#ifndef TOOLCHAIN_CLANG_VERSION
85#define TOOLCHAIN_CLANG_VERSION 0
86#endif
87
92#ifndef TOOLCHAIN_HAS_PRAGMA_DIAG
93#define TOOLCHAIN_HAS_PRAGMA_DIAG 0
94#endif
95
100#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
101/* _Generic is introduced in C11, so it is supported. */
102# ifdef TOOLCHAIN_HAS_C_GENERIC
103# undef TOOLCHAIN_HAS_C_GENERIC
104# endif
105# define TOOLCHAIN_HAS_C_GENERIC 1
106#else
107# ifndef TOOLCHAIN_HAS_C_GENERIC
108# define TOOLCHAIN_HAS_C_GENERIC 0
109# endif
110#endif
111
116#ifndef TOOLCHAIN_HAS_C_AUTO_TYPE
117#define TOOLCHAIN_HAS_C_AUTO_TYPE 0
118#endif
119
124#ifndef TOOLCHAIN_HAS_ZLA
125#define TOOLCHAIN_HAS_ZLA 0
126#endif
127
135#ifndef TOOLCHAIN_IGNORE_WSHADOW_BEGIN
136#define TOOLCHAIN_IGNORE_WSHADOW_BEGIN
137#endif
138
146#ifndef TOOLCHAIN_IGNORE_WSHADOW_END
147#define TOOLCHAIN_IGNORE_WSHADOW_END
148#endif
149
154#ifdef TOOLCHAIN_HAS_PRAGMA_DIAG
155#define TOOLCHAIN_PRAGMA(x) _Pragma(#x)
156#else
157#define TOOLCHAIN_PRAGMA(x)
158#endif
159
164#ifndef TOOLCHAIN_DISABLE_WARNING
165#define TOOLCHAIN_DISABLE_WARNING(warning)
166#endif
167
174#ifndef TOOLCHAIN_ENABLE_WARNING
175#define TOOLCHAIN_ENABLE_WARNING(warning)
176#endif
177
182#ifndef TOOLCHAIN_DISABLE_CLANG_WARNING
183#define TOOLCHAIN_DISABLE_CLANG_WARNING(warning)
184#endif
185
192#ifndef TOOLCHAIN_ENABLE_CLANG_WARNING
193#define TOOLCHAIN_ENABLE_CLANG_WARNING(warning)
194#endif
195
200#ifndef TOOLCHAIN_DISABLE_GCC_WARNING
201#define TOOLCHAIN_DISABLE_GCC_WARNING(warning)
202#endif
203
210#ifndef TOOLCHAIN_ENABLE_GCC_WARNING
211#define TOOLCHAIN_ENABLE_GCC_WARNING(warning)
212#endif
213
214/*
215 * Ensure that __BYTE_ORDER__ and related preprocessor definitions are defined,
216 * and that they match the Kconfig option that is used in the code itself to
217 * check for endianness.
218 */
219#ifndef _LINKER
220#if !defined(__BYTE_ORDER__) || !defined(__ORDER_BIG_ENDIAN__) || \
221 !defined(__ORDER_LITTLE_ENDIAN__)
222
223/*
224 * Displaying values unfortunately requires #pragma message which can't
225 * be taken for granted + STRINGIFY() which is not available in this .h
226 * file.
227 */
228#error "At least one byte _ORDER_ macro is not defined"
229
230#else
231
232#if (defined(CONFIG_BIG_ENDIAN) && (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__)) || \
233 (defined(CONFIG_LITTLE_ENDIAN) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__))
234
235# error "Kconfig/toolchain endianness mismatch:"
236
237# if (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
238# error "Unknown __BYTE_ORDER__ value"
239# else
240# ifdef CONFIG_BIG_ENDIAN
241# error "CONFIG_BIG_ENDIAN but __ORDER_LITTLE_ENDIAN__"
242# endif
243# ifdef CONFIG_LITTLE_ENDIAN
244# error "CONFIG_LITTLE_ENDIAN but __ORDER_BIG_ENDIAN__"
245# endif
246# endif
247
248#endif /* Endianness mismatch */
249
250#endif /* all _ORDER_ macros defined */
251
252#endif /* !_LINKER */
253
254#endif /* ZEPHYR_INCLUDE_TOOLCHAIN_H_ */
GCC toolchain abstraction.