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__) || \
63 (defined(_LINKER) && (defined(__LLD_LINKER_CMD__) || defined(__ELD_LINKER_CMD__)))
65#elif defined(__GNUC__) || (defined(_LINKER) && defined(__GCC_LINKER_CMD__))
67#else
68#error "Invalid/unknown toolchain configuration"
69#endif
70
82#ifndef __noasan
83#define __noasan /**/
84#endif
85
90#ifndef TOOLCHAIN_GCC_VERSION
91#define TOOLCHAIN_GCC_VERSION 0
92#endif
93
98#ifndef TOOLCHAIN_CLANG_VERSION
99#define TOOLCHAIN_CLANG_VERSION 0
100#endif
101
106#ifndef TOOLCHAIN_HAS_PRAGMA_DIAG
107#define TOOLCHAIN_HAS_PRAGMA_DIAG 0
108#endif
109
114#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
115/* _Generic is introduced in C11, so it is supported. */
116# ifdef TOOLCHAIN_HAS_C_GENERIC
117# undef TOOLCHAIN_HAS_C_GENERIC
118# endif
119# define TOOLCHAIN_HAS_C_GENERIC 1
120#else
121# ifndef TOOLCHAIN_HAS_C_GENERIC
122# define TOOLCHAIN_HAS_C_GENERIC 0
123# endif
124#endif
125
130#ifndef TOOLCHAIN_HAS_C_AUTO_TYPE
131#define TOOLCHAIN_HAS_C_AUTO_TYPE 0
132#endif
133
138#ifndef TOOLCHAIN_HAS_ZLA
139#define TOOLCHAIN_HAS_ZLA 0
140#endif
141
148#ifdef TOOLCHAIN_HAS_PRAGMA_DIAG
149#define TOOLCHAIN_PRAGMA(x) _Pragma(#x)
150#else
151#define TOOLCHAIN_PRAGMA(x)
152#endif
153
155
159
167#ifndef TOOLCHAIN_WARNING_ADDRESS_OF_PACKED_MEMBER
168#define TOOLCHAIN_WARNING_ADDRESS_OF_PACKED_MEMBER
169#endif
170
178#ifndef TOOLCHAIN_WARNING_ARRAY_BOUNDS
179#define TOOLCHAIN_WARNING_ARRAY_BOUNDS
180#endif
181
189#ifndef TOOLCHAIN_WARNING_ATTRIBUTES
190#define TOOLCHAIN_WARNING_ATTRIBUTES
191#endif
192
201#ifndef TOOLCHAIN_WARNING_DELETE_NON_VIRTUAL_DTOR
202#define TOOLCHAIN_WARNING_DELETE_NON_VIRTUAL_DTOR
203#endif
204
212#ifndef TOOLCHAIN_WARNING_EXTRA
213#define TOOLCHAIN_WARNING_EXTRA
214#endif
215
224#ifndef TOOLCHAIN_WARNING_ARM_INTERRUPT_VFP_CLOBBER
225#define TOOLCHAIN_WARNING_ARM_INTERRUPT_VFP_CLOBBER
226#endif
227
235#ifndef TOOLCHAIN_WARNING_NONNULL
236#define TOOLCHAIN_WARNING_NONNULL
237#endif
238
246#ifndef TOOLCHAIN_WARNING_POINTER_ARITH
247#define TOOLCHAIN_WARNING_POINTER_ARITH
248#endif
249
257#ifndef TOOLCHAIN_WARNING_SHADOW
258#define TOOLCHAIN_WARNING_SHADOW
259#endif
260
268#ifndef TOOLCHAIN_WARNING_UNUSED_LABEL
269#define TOOLCHAIN_WARNING_UNUSED_LABEL
270#endif
271
279#ifndef TOOLCHAIN_WARNING_UNUSED_VARIABLE
280#define TOOLCHAIN_WARNING_UNUSED_VARIABLE
281#endif
282
290#ifndef TOOLCHAIN_WARNING_ALWAYS_INLINE
291#define TOOLCHAIN_WARNING_ALWAYS_INLINE
292#endif
293
301#ifndef TOOLCHAIN_WARNING_CAST_QUAL
302#define TOOLCHAIN_WARNING_CAST_QUAL
303#endif
304
306
310
317#ifndef TOOLCHAIN_DISABLE_WARNING
318#define TOOLCHAIN_DISABLE_WARNING(warning)
319#endif
320
329#ifndef TOOLCHAIN_ENABLE_WARNING
330#define TOOLCHAIN_ENABLE_WARNING(warning)
331#endif
332
339#ifndef TOOLCHAIN_DISABLE_CLANG_WARNING
340#define TOOLCHAIN_DISABLE_CLANG_WARNING(warning)
341#endif
342
351#ifndef TOOLCHAIN_ENABLE_CLANG_WARNING
352#define TOOLCHAIN_ENABLE_CLANG_WARNING(warning)
353#endif
354
361#ifndef TOOLCHAIN_DISABLE_GCC_WARNING
362#define TOOLCHAIN_DISABLE_GCC_WARNING(warning)
363#endif
364
373#ifndef TOOLCHAIN_ENABLE_GCC_WARNING
374#define TOOLCHAIN_ENABLE_GCC_WARNING(warning)
375#endif
376
383#ifndef TOOLCHAIN_DISABLE_IAR_WARNING
384#define TOOLCHAIN_DISABLE_IAR_WARNING(warning)
385#endif
386
395#ifndef TOOLCHAIN_ENABLE_IAR_WARNING
396#define TOOLCHAIN_ENABLE_IAR_WARNING(warning)
397#endif
398
400
401/*
402 * Ensure that __BYTE_ORDER__ and related preprocessor definitions are defined,
403 * and that they match the Kconfig option that is used in the code itself to
404 * check for endianness.
405 */
406#ifndef _LINKER
407#if !defined(__BYTE_ORDER__) || !defined(__ORDER_BIG_ENDIAN__) || \
408 !defined(__ORDER_LITTLE_ENDIAN__)
409
410/*
411 * Displaying values unfortunately requires #pragma message which can't
412 * be taken for granted + STRINGIFY() which is not available in this .h
413 * file.
414 */
415#error "At least one byte _ORDER_ macro is not defined"
416
417#else
418
419#if (defined(CONFIG_BIG_ENDIAN) && (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__)) || \
420 (defined(CONFIG_LITTLE_ENDIAN) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__))
421
422# error "Kconfig/toolchain endianness mismatch:"
423
424# if (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
425# error "Unknown __BYTE_ORDER__ value"
426# else
427# ifdef CONFIG_BIG_ENDIAN
428# error "CONFIG_BIG_ENDIAN but __ORDER_LITTLE_ENDIAN__"
429# endif
430# ifdef CONFIG_LITTLE_ENDIAN
431# error "CONFIG_LITTLE_ENDIAN but __ORDER_BIG_ENDIAN__"
432# endif
433# endif
434
435#endif /* Endianness mismatch */
436
437#endif /* all _ORDER_ macros defined */
438
439#endif /* !_LINKER */
440
442
443#endif /* ZEPHYR_INCLUDE_TOOLCHAIN_H_ */
GCC toolchain abstraction.