Zephyr Project API 4.4.99
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
16#ifndef ZEPHYR_INCLUDE_TOOLCHAIN_H_
17#define ZEPHYR_INCLUDE_TOOLCHAIN_H_
18
23
27
38#ifdef __has_builtin
39#define HAS_BUILTIN(x) __has_builtin(x)
40#else
41/*
42 * The compiler doesn't provide the __has_builtin() macro, so instead we depend
43 * on the toolchain-specific headers to define HAS_BUILTIN_x for the builtins
44 * supported.
45 */
46#define HAS_BUILTIN(x) HAS_BUILTIN_##x
47#endif
48
49#if defined(__TOOLCHAIN_CUSTOM__)
50/* This include line exists for off-tree definitions of compilers,
51 * and therefore this header is not meant to exist in-tree
52 */
53#include <toolchain/other.h>
54#elif defined(__XCC__)
56#elif defined(__CCAC__)
58#elif defined(__ARMCOMPILER_VERSION)
60#elif defined(__IAR_SYSTEMS_ICC__)
62#elif defined(__llvm__) || (defined(_LINKER) && defined(__LLD_LINKER_CMD__))
64#elif defined(__GNUC__) || (defined(_LINKER) && defined(__GCC_LINKER_CMD__))
66#else
67#error "Invalid/unknown toolchain configuration"
68#endif
69
81#ifndef __noasan
82#define __noasan /**/
83#endif
84
89#ifndef TOOLCHAIN_GCC_VERSION
90#define TOOLCHAIN_GCC_VERSION 0
91#endif
92
97#ifndef TOOLCHAIN_CLANG_VERSION
98#define TOOLCHAIN_CLANG_VERSION 0
99#endif
100
105#ifndef TOOLCHAIN_HAS_PRAGMA_DIAG
106#define TOOLCHAIN_HAS_PRAGMA_DIAG 0
107#endif
108
113#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
114/* _Generic is introduced in C11, so it is supported. */
115# ifdef TOOLCHAIN_HAS_C_GENERIC
116# undef TOOLCHAIN_HAS_C_GENERIC
117# endif
118# define TOOLCHAIN_HAS_C_GENERIC 1
119#else
120# ifndef TOOLCHAIN_HAS_C_GENERIC
121# define TOOLCHAIN_HAS_C_GENERIC 0
122# endif
123#endif
124
129#ifndef TOOLCHAIN_HAS_C_AUTO_TYPE
130#define TOOLCHAIN_HAS_C_AUTO_TYPE 0
131#endif
132
137#ifndef TOOLCHAIN_HAS_ZLA
138#define TOOLCHAIN_HAS_ZLA 0
139#endif
140
147#ifdef TOOLCHAIN_HAS_PRAGMA_DIAG
148#define TOOLCHAIN_PRAGMA(x) _Pragma(#x)
149#else
150#define TOOLCHAIN_PRAGMA(x)
151#endif
152
154
158
166#ifndef TOOLCHAIN_WARNING_ADDRESS_OF_PACKED_MEMBER
167#define TOOLCHAIN_WARNING_ADDRESS_OF_PACKED_MEMBER
168#endif
169
177#ifndef TOOLCHAIN_WARNING_ARRAY_BOUNDS
178#define TOOLCHAIN_WARNING_ARRAY_BOUNDS
179#endif
180
188#ifndef TOOLCHAIN_WARNING_ATTRIBUTES
189#define TOOLCHAIN_WARNING_ATTRIBUTES
190#endif
191
200#ifndef TOOLCHAIN_WARNING_DELETE_NON_VIRTUAL_DTOR
201#define TOOLCHAIN_WARNING_DELETE_NON_VIRTUAL_DTOR
202#endif
203
211#ifndef TOOLCHAIN_WARNING_EXTRA
212#define TOOLCHAIN_WARNING_EXTRA
213#endif
214
223#ifndef TOOLCHAIN_WARNING_ARM_INTERRUPT_VFP_CLOBBER
224#define TOOLCHAIN_WARNING_ARM_INTERRUPT_VFP_CLOBBER
225#endif
226
234#ifndef TOOLCHAIN_WARNING_NONNULL
235#define TOOLCHAIN_WARNING_NONNULL
236#endif
237
245#ifndef TOOLCHAIN_WARNING_POINTER_ARITH
246#define TOOLCHAIN_WARNING_POINTER_ARITH
247#endif
248
256#ifndef TOOLCHAIN_WARNING_SHADOW
257#define TOOLCHAIN_WARNING_SHADOW
258#endif
259
267#ifndef TOOLCHAIN_WARNING_UNUSED_LABEL
268#define TOOLCHAIN_WARNING_UNUSED_LABEL
269#endif
270
278#ifndef TOOLCHAIN_WARNING_UNUSED_VARIABLE
279#define TOOLCHAIN_WARNING_UNUSED_VARIABLE
280#endif
281
289#ifndef TOOLCHAIN_WARNING_ALWAYS_INLINE
290#define TOOLCHAIN_WARNING_ALWAYS_INLINE
291#endif
292
300#ifndef TOOLCHAIN_WARNING_CAST_QUAL
301#define TOOLCHAIN_WARNING_CAST_QUAL
302#endif
303
305
309
316#ifndef TOOLCHAIN_DISABLE_WARNING
317#define TOOLCHAIN_DISABLE_WARNING(warning)
318#endif
319
328#ifndef TOOLCHAIN_ENABLE_WARNING
329#define TOOLCHAIN_ENABLE_WARNING(warning)
330#endif
331
338#ifndef TOOLCHAIN_DISABLE_CLANG_WARNING
339#define TOOLCHAIN_DISABLE_CLANG_WARNING(warning)
340#endif
341
350#ifndef TOOLCHAIN_ENABLE_CLANG_WARNING
351#define TOOLCHAIN_ENABLE_CLANG_WARNING(warning)
352#endif
353
360#ifndef TOOLCHAIN_DISABLE_GCC_WARNING
361#define TOOLCHAIN_DISABLE_GCC_WARNING(warning)
362#endif
363
372#ifndef TOOLCHAIN_ENABLE_GCC_WARNING
373#define TOOLCHAIN_ENABLE_GCC_WARNING(warning)
374#endif
375
382#ifndef TOOLCHAIN_DISABLE_IAR_WARNING
383#define TOOLCHAIN_DISABLE_IAR_WARNING(warning)
384#endif
385
394#ifndef TOOLCHAIN_ENABLE_IAR_WARNING
395#define TOOLCHAIN_ENABLE_IAR_WARNING(warning)
396#endif
397
399
400/*
401 * Ensure that __BYTE_ORDER__ and related preprocessor definitions are defined,
402 * and that they match the Kconfig option that is used in the code itself to
403 * check for endianness.
404 */
405#ifndef _LINKER
406#if !defined(__BYTE_ORDER__) || !defined(__ORDER_BIG_ENDIAN__) || \
407 !defined(__ORDER_LITTLE_ENDIAN__)
408
409/*
410 * Displaying values unfortunately requires #pragma message which can't
411 * be taken for granted + STRINGIFY() which is not available in this .h
412 * file.
413 */
414#error "At least one byte _ORDER_ macro is not defined"
415
416#else
417
418#if (defined(CONFIG_BIG_ENDIAN) && (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__)) || \
419 (defined(CONFIG_LITTLE_ENDIAN) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__))
420
421# error "Kconfig/toolchain endianness mismatch:"
422
423# if (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
424# error "Unknown __BYTE_ORDER__ value"
425# else
426# ifdef CONFIG_BIG_ENDIAN
427# error "CONFIG_BIG_ENDIAN but __ORDER_LITTLE_ENDIAN__"
428# endif
429# ifdef CONFIG_LITTLE_ENDIAN
430# error "CONFIG_LITTLE_ENDIAN but __ORDER_BIG_ENDIAN__"
431# endif
432# endif
433
434#endif /* Endianness mismatch */
435
436#endif /* all _ORDER_ macros defined */
437
438#endif /* !_LINKER */
439
441
442#endif /* ZEPHYR_INCLUDE_TOOLCHAIN_H_ */
GCC toolchain abstraction.