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
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
132#ifdef TOOLCHAIN_HAS_PRAGMA_DIAG
133#define TOOLCHAIN_PRAGMA(x) _Pragma(#x)
134#else
135#define TOOLCHAIN_PRAGMA(x)
136#endif
137
145#ifndef TOOLCHAIN_WARNING_ADDRESS_OF_PACKED_MEMBER
146#define TOOLCHAIN_WARNING_ADDRESS_OF_PACKED_MEMBER
147#endif
148
156#ifndef TOOLCHAIN_WARNING_ARRAY_BOUNDS
157#define TOOLCHAIN_WARNING_ARRAY_BOUNDS
158#endif
159
167#ifndef TOOLCHAIN_WARNING_ATTRIBUTES
168#define TOOLCHAIN_WARNING_ATTRIBUTES
169#endif
170
179#ifndef TOOLCHAIN_WARNING_DELETE_NON_VIRTUAL_DTOR
180#define TOOLCHAIN_WARNING_DELETE_NON_VIRTUAL_DTOR
181#endif
182
190#ifndef TOOLCHAIN_WARNING_EXTRA
191#define TOOLCHAIN_WARNING_EXTRA
192#endif
193
201#ifndef TOOLCHAIN_WARNING_NONNULL
202#define TOOLCHAIN_WARNING_NONNULL
203#endif
204
212#ifndef TOOLCHAIN_WARNING_POINTER_ARITH
213#define TOOLCHAIN_WARNING_POINTER_ARITH
214#endif
215
223#ifndef TOOLCHAIN_WARNING_SHADOW
224#define TOOLCHAIN_WARNING_SHADOW
225#endif
226
234#ifndef TOOLCHAIN_WARNING_UNUSED_LABEL
235#define TOOLCHAIN_WARNING_UNUSED_LABEL
236#endif
237
245#ifndef TOOLCHAIN_WARNING_UNUSED_VARIABLE
246#define TOOLCHAIN_WARNING_UNUSED_VARIABLE
247#endif
248
253#ifndef TOOLCHAIN_DISABLE_WARNING
254#define TOOLCHAIN_DISABLE_WARNING(warning)
255#endif
256
263#ifndef TOOLCHAIN_ENABLE_WARNING
264#define TOOLCHAIN_ENABLE_WARNING(warning)
265#endif
266
271#ifndef TOOLCHAIN_DISABLE_CLANG_WARNING
272#define TOOLCHAIN_DISABLE_CLANG_WARNING(warning)
273#endif
274
281#ifndef TOOLCHAIN_ENABLE_CLANG_WARNING
282#define TOOLCHAIN_ENABLE_CLANG_WARNING(warning)
283#endif
284
289#ifndef TOOLCHAIN_DISABLE_GCC_WARNING
290#define TOOLCHAIN_DISABLE_GCC_WARNING(warning)
291#endif
292
299#ifndef TOOLCHAIN_ENABLE_GCC_WARNING
300#define TOOLCHAIN_ENABLE_GCC_WARNING(warning)
301#endif
302
307#ifndef TOOLCHAIN_DISABLE_IAR_WARNING
308#define TOOLCHAIN_DISABLE_IAR_WARNING(warning)
309#endif
310
317#ifndef TOOLCHAIN_ENABLE_IAR_WARNING
318#define TOOLCHAIN_ENABLE_IAR_WARNING(warning)
319#endif
320
321/*
322 * Ensure that __BYTE_ORDER__ and related preprocessor definitions are defined,
323 * and that they match the Kconfig option that is used in the code itself to
324 * check for endianness.
325 */
326#ifndef _LINKER
327#if !defined(__BYTE_ORDER__) || !defined(__ORDER_BIG_ENDIAN__) || \
328 !defined(__ORDER_LITTLE_ENDIAN__)
329
330/*
331 * Displaying values unfortunately requires #pragma message which can't
332 * be taken for granted + STRINGIFY() which is not available in this .h
333 * file.
334 */
335#error "At least one byte _ORDER_ macro is not defined"
336
337#else
338
339#if (defined(CONFIG_BIG_ENDIAN) && (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__)) || \
340 (defined(CONFIG_LITTLE_ENDIAN) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__))
341
342# error "Kconfig/toolchain endianness mismatch:"
343
344# if (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
345# error "Unknown __BYTE_ORDER__ value"
346# else
347# ifdef CONFIG_BIG_ENDIAN
348# error "CONFIG_BIG_ENDIAN but __ORDER_LITTLE_ENDIAN__"
349# endif
350# ifdef CONFIG_LITTLE_ENDIAN
351# error "CONFIG_LITTLE_ENDIAN but __ORDER_BIG_ENDIAN__"
352# endif
353# endif
354
355#endif /* Endianness mismatch */
356
357#endif /* all _ORDER_ macros defined */
358
359#endif /* !_LINKER */
360
361#endif /* ZEPHYR_INCLUDE_TOOLCHAIN_H_ */
GCC toolchain abstraction.