Zephyr API Documentation 4.3.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
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
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
256#ifndef TOOLCHAIN_WARNING_ALWAYS_INLINE
257#define TOOLCHAIN_WARNING_ALWAYS_INLINE
258#endif
259
267#ifndef TOOLCHAIN_WARNING_CAST_QUAL
268#define TOOLCHAIN_WARNING_CAST_QUAL
269#endif
270
275#ifndef TOOLCHAIN_DISABLE_WARNING
276#define TOOLCHAIN_DISABLE_WARNING(warning)
277#endif
278
285#ifndef TOOLCHAIN_ENABLE_WARNING
286#define TOOLCHAIN_ENABLE_WARNING(warning)
287#endif
288
293#ifndef TOOLCHAIN_DISABLE_CLANG_WARNING
294#define TOOLCHAIN_DISABLE_CLANG_WARNING(warning)
295#endif
296
303#ifndef TOOLCHAIN_ENABLE_CLANG_WARNING
304#define TOOLCHAIN_ENABLE_CLANG_WARNING(warning)
305#endif
306
311#ifndef TOOLCHAIN_DISABLE_GCC_WARNING
312#define TOOLCHAIN_DISABLE_GCC_WARNING(warning)
313#endif
314
321#ifndef TOOLCHAIN_ENABLE_GCC_WARNING
322#define TOOLCHAIN_ENABLE_GCC_WARNING(warning)
323#endif
324
329#ifndef TOOLCHAIN_DISABLE_IAR_WARNING
330#define TOOLCHAIN_DISABLE_IAR_WARNING(warning)
331#endif
332
339#ifndef TOOLCHAIN_ENABLE_IAR_WARNING
340#define TOOLCHAIN_ENABLE_IAR_WARNING(warning)
341#endif
342
343/*
344 * Ensure that __BYTE_ORDER__ and related preprocessor definitions are defined,
345 * and that they match the Kconfig option that is used in the code itself to
346 * check for endianness.
347 */
348#ifndef _LINKER
349#if !defined(__BYTE_ORDER__) || !defined(__ORDER_BIG_ENDIAN__) || \
350 !defined(__ORDER_LITTLE_ENDIAN__)
351
352/*
353 * Displaying values unfortunately requires #pragma message which can't
354 * be taken for granted + STRINGIFY() which is not available in this .h
355 * file.
356 */
357#error "At least one byte _ORDER_ macro is not defined"
358
359#else
360
361#if (defined(CONFIG_BIG_ENDIAN) && (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__)) || \
362 (defined(CONFIG_LITTLE_ENDIAN) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__))
363
364# error "Kconfig/toolchain endianness mismatch:"
365
366# if (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
367# error "Unknown __BYTE_ORDER__ value"
368# else
369# ifdef CONFIG_BIG_ENDIAN
370# error "CONFIG_BIG_ENDIAN but __ORDER_LITTLE_ENDIAN__"
371# endif
372# ifdef CONFIG_LITTLE_ENDIAN
373# error "CONFIG_LITTLE_ENDIAN but __ORDER_BIG_ENDIAN__"
374# endif
375# endif
376
377#endif /* Endianness mismatch */
378
379#endif /* all _ORDER_ macros defined */
380
381#endif /* !_LINKER */
382
383#endif /* ZEPHYR_INCLUDE_TOOLCHAIN_H_ */
GCC toolchain abstraction.