Zephyr Project API 4.1.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
llvm.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Intel Corporation.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_TOOLCHAIN_LLVM_H_
8#define ZEPHYR_INCLUDE_TOOLCHAIN_LLVM_H_
9
10#ifndef ZEPHYR_INCLUDE_TOOLCHAIN_H_
11#error Please do not include toolchain-specific headers directly, use <zephyr/toolchain.h> instead
12#endif
13
14#define __no_optimization __attribute__((optnone))
15
16#if __clang_major__ >= 10
17#define __fallthrough __attribute__((fallthrough))
18#endif
19
20#define TOOLCHAIN_CLANG_VERSION \
21 ((__clang_major__ * 10000) + (__clang_minor__ * 100) + \
22 __clang_patchlevel__)
23
24#define TOOLCHAIN_HAS_PRAGMA_DIAG 1
25
26#if TOOLCHAIN_CLANG_VERSION >= 30800
27#define TOOLCHAIN_HAS_C_GENERIC 1
28#define TOOLCHAIN_HAS_C_AUTO_TYPE 1
29#endif
30
32
33#define TOOLCHAIN_WARNING_SIZEOF_ARRAY_DECAY "-Wsizeof-array-decay"
34#define TOOLCHAIN_WARNING_UNNEEDED_INTERNAL_DECLARATION "-Wunneeded-internal-declaration"
35
36#define TOOLCHAIN_DISABLE_CLANG_WARNING(warning) _TOOLCHAIN_DISABLE_WARNING(clang, warning)
37#define TOOLCHAIN_ENABLE_CLANG_WARNING(warning) _TOOLCHAIN_ENABLE_WARNING(clang, warning)
38
39/*
40 * Provide these definitions only when minimal libc is used.
41 * Avoid collision with defines from include/zephyr/toolchain/zephyr_stdint.h
42 */
43#ifdef CONFIG_MINIMAL_LIBC
44
45/*
46 * Predefined __INTN_C/__UINTN_C macros are provided by clang starting in version 20.1.
47 * Avoid redefining these macros if a sufficiently modern clang is being used.
48 */
49#if TOOLCHAIN_CLANG_VERSION < 200100
50
51#define __int_c(v, suffix) v ## suffix
52#define int_c(v, suffix) __int_c(v, suffix)
53#define uint_c(v, suffix) __int_c(v ## U, suffix)
54
55#ifndef CONFIG_ENFORCE_ZEPHYR_STDINT
56
57#ifdef __INT64_TYPE__
58#undef __int_least64_c_suffix__
59#undef __int_least32_c_suffix__
60#undef __int_least16_c_suffix__
61#undef __int_least8_c_suffix__
62#ifdef __INT64_C_SUFFIX__
63#define __int_least64_c_suffix__ __INT64_C_SUFFIX__
64#define __int_least32_c_suffix__ __INT64_C_SUFFIX__
65#define __int_least16_c_suffix__ __INT64_C_SUFFIX__
66#define __int_least8_c_suffix__ __INT64_C_SUFFIX__
67#endif /* __INT64_C_SUFFIX__ */
68#endif /* __INT64_TYPE__ */
69
70#ifdef __INT_LEAST64_TYPE__
71#ifdef __int_least64_c_suffix__
72#define __INT64_C(x) int_c(x, __int_least64_c_suffix__)
73#define __UINT64_C(x) uint_c(x, __int_least64_c_suffix__)
74#else
75#define __INT64_C(x) x
76#define __UINT64_C(x) x ## U
77#endif /* __int_least64_c_suffix__ */
78#endif /* __INT_LEAST64_TYPE__ */
79
80#ifdef __INT32_TYPE__
81#undef __int_least32_c_suffix__
82#undef __int_least16_c_suffix__
83#undef __int_least8_c_suffix__
84#ifdef __INT32_C_SUFFIX__
85#define __int_least32_c_suffix__ __INT32_C_SUFFIX__
86#define __int_least16_c_suffix__ __INT32_C_SUFFIX__
87#define __int_least8_c_suffix__ __INT32_C_SUFFIX__
88#endif /* __INT32_C_SUFFIX__ */
89#endif /* __INT32_TYPE__ */
90
91#ifdef __INT_LEAST32_TYPE__
92#ifdef __int_least32_c_suffix__
93#define __INT32_C(x) int_c(x, __int_least32_c_suffix__)
94#define __UINT32_C(x) uint_c(x, __int_least32_c_suffix__)
95#else
96#define __INT32_C(x) x
97#define __UINT32_C(x) x ## U
98#endif /* __int_least32_c_suffix__ */
99#endif /* __INT_LEAST32_TYPE__ */
100
101#endif /* !CONFIG_ENFORCE_ZEPHYR_STDINT */
102
103#ifdef __INT16_TYPE__
104#undef __int_least16_c_suffix__
105#undef __int_least8_c_suffix__
106#ifdef __INT16_C_SUFFIX__
107#define __int_least16_c_suffix__ __INT16_C_SUFFIX__
108#define __int_least8_c_suffix__ __INT16_C_SUFFIX__
109#endif /* __INT16_C_SUFFIX__ */
110#endif /* __INT16_TYPE__ */
111
112#ifdef __INT_LEAST16_TYPE__
113#ifdef __int_least16_c_suffix__
114#define __INT16_C(x) int_c(x, __int_least16_c_suffix__)
115#define __UINT16_C(x) uint_c(x, __int_least16_c_suffix__)
116#else
117#define __INT16_C(x) x
118#define __UINT16_C(x) x ## U
119#endif /* __int_least16_c_suffix__ */
120#endif /* __INT_LEAST16_TYPE__ */
121
122#ifdef __INT8_TYPE__
123#undef __int_least8_c_suffix__
124#ifdef __INT8_C_SUFFIX__
125#define __int_least8_c_suffix__ __INT8_C_SUFFIX__
126#endif /* __INT8_C_SUFFIX__ */
127#endif /* __INT8_TYPE__ */
128
129#ifdef __INT_LEAST8_TYPE__
130#ifdef __int_least8_c_suffix__
131#define __INT8_C(x) int_c(x, __int_least8_c_suffix__)
132#define __UINT8_C(x) uint_c(x, __int_least8_c_suffix__)
133#else
134#define __INT8_C(x) x
135#define __UINT8_C(x) x ## U
136#endif /* __int_least8_c_suffix__ */
137#endif /* __INT_LEAST8_TYPE__ */
138
139#define __INTMAX_C(x) int_c(x, __INTMAX_C_SUFFIX__)
140#define __UINTMAX_C(x) int_c(x, __UINTMAX_C_SUFFIX__)
141
142#endif /* TOOLCHAIN_CLANG_VERSION < 200100 */
143
144#endif /* CONFIG_MINIMAL_LIBC */
145
146#endif /* ZEPHYR_INCLUDE_TOOLCHAIN_LLVM_H_ */
GCC toolchain abstraction.