Zephyr API Documentation 4.4.0-rc1
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
14
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
202#ifndef TOOLCHAIN_WARNING_ARM_INTERRUPT_VFP_CLOBBER
203#define TOOLCHAIN_WARNING_ARM_INTERRUPT_VFP_CLOBBER
204#endif
205
213#ifndef TOOLCHAIN_WARNING_NONNULL
214#define TOOLCHAIN_WARNING_NONNULL
215#endif
216
224#ifndef TOOLCHAIN_WARNING_POINTER_ARITH
225#define TOOLCHAIN_WARNING_POINTER_ARITH
226#endif
227
235#ifndef TOOLCHAIN_WARNING_SHADOW
236#define TOOLCHAIN_WARNING_SHADOW
237#endif
238
246#ifndef TOOLCHAIN_WARNING_UNUSED_LABEL
247#define TOOLCHAIN_WARNING_UNUSED_LABEL
248#endif
249
257#ifndef TOOLCHAIN_WARNING_UNUSED_VARIABLE
258#define TOOLCHAIN_WARNING_UNUSED_VARIABLE
259#endif
260
268#ifndef TOOLCHAIN_WARNING_ALWAYS_INLINE
269#define TOOLCHAIN_WARNING_ALWAYS_INLINE
270#endif
271
279#ifndef TOOLCHAIN_WARNING_CAST_QUAL
280#define TOOLCHAIN_WARNING_CAST_QUAL
281#endif
282
287#ifndef TOOLCHAIN_DISABLE_WARNING
288#define TOOLCHAIN_DISABLE_WARNING(warning)
289#endif
290
297#ifndef TOOLCHAIN_ENABLE_WARNING
298#define TOOLCHAIN_ENABLE_WARNING(warning)
299#endif
300
305#ifndef TOOLCHAIN_DISABLE_CLANG_WARNING
306#define TOOLCHAIN_DISABLE_CLANG_WARNING(warning)
307#endif
308
315#ifndef TOOLCHAIN_ENABLE_CLANG_WARNING
316#define TOOLCHAIN_ENABLE_CLANG_WARNING(warning)
317#endif
318
323#ifndef TOOLCHAIN_DISABLE_GCC_WARNING
324#define TOOLCHAIN_DISABLE_GCC_WARNING(warning)
325#endif
326
333#ifndef TOOLCHAIN_ENABLE_GCC_WARNING
334#define TOOLCHAIN_ENABLE_GCC_WARNING(warning)
335#endif
336
341#ifndef TOOLCHAIN_DISABLE_IAR_WARNING
342#define TOOLCHAIN_DISABLE_IAR_WARNING(warning)
343#endif
344
351#ifndef TOOLCHAIN_ENABLE_IAR_WARNING
352#define TOOLCHAIN_ENABLE_IAR_WARNING(warning)
353#endif
354
355/*
356 * Ensure that __BYTE_ORDER__ and related preprocessor definitions are defined,
357 * and that they match the Kconfig option that is used in the code itself to
358 * check for endianness.
359 */
360#ifndef _LINKER
361#if !defined(__BYTE_ORDER__) || !defined(__ORDER_BIG_ENDIAN__) || \
362 !defined(__ORDER_LITTLE_ENDIAN__)
363
364/*
365 * Displaying values unfortunately requires #pragma message which can't
366 * be taken for granted + STRINGIFY() which is not available in this .h
367 * file.
368 */
369#error "At least one byte _ORDER_ macro is not defined"
370
371#else
372
373#if (defined(CONFIG_BIG_ENDIAN) && (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__)) || \
374 (defined(CONFIG_LITTLE_ENDIAN) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__))
375
376# error "Kconfig/toolchain endianness mismatch:"
377
378# if (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
379# error "Unknown __BYTE_ORDER__ value"
380# else
381# ifdef CONFIG_BIG_ENDIAN
382# error "CONFIG_BIG_ENDIAN but __ORDER_LITTLE_ENDIAN__"
383# endif
384# ifdef CONFIG_LITTLE_ENDIAN
385# error "CONFIG_LITTLE_ENDIAN but __ORDER_BIG_ENDIAN__"
386# endif
387# endif
388
389#endif /* Endianness mismatch */
390
391#endif /* all _ORDER_ macros defined */
392
393#endif /* !_LINKER */
394
395#endif /* ZEPHYR_INCLUDE_TOOLCHAIN_H_ */
GCC toolchain abstraction.