Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
 4.1.99
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
35#define TOOLCHAIN_DISABLE_CLANG_WARNING(warning) _TOOLCHAIN_DISABLE_WARNING(clang, warning)
36#define TOOLCHAIN_ENABLE_CLANG_WARNING(warning) _TOOLCHAIN_ENABLE_WARNING(clang, warning)
37
38/*
39 * Provide these definitions only when minimal libc is used.
40 * Avoid collision with defines from include/zephyr/toolchain/zephyr_stdint.h
41 */
42#ifdef CONFIG_MINIMAL_LIBC
43
44#define __int_c(v, suffix) v ## suffix
45#define int_c(v, suffix) __int_c(v, suffix)
46#define uint_c(v, suffix) __int_c(v ## U, suffix)
47
48#ifndef CONFIG_ENFORCE_ZEPHYR_STDINT
49
50#ifdef __INT64_TYPE__
51#undef __int_least64_c_suffix__
52#undef __int_least32_c_suffix__
53#undef __int_least16_c_suffix__
54#undef __int_least8_c_suffix__
55#ifdef __INT64_C_SUFFIX__
56#define __int_least64_c_suffix__ __INT64_C_SUFFIX__
57#define __int_least32_c_suffix__ __INT64_C_SUFFIX__
58#define __int_least16_c_suffix__ __INT64_C_SUFFIX__
59#define __int_least8_c_suffix__ __INT64_C_SUFFIX__
60#endif /* __INT64_C_SUFFIX__ */
61#endif /* __INT64_TYPE__ */
62
63#ifdef __INT_LEAST64_TYPE__
64#ifdef __int_least64_c_suffix__
65#define __INT64_C(x) int_c(x, __int_least64_c_suffix__)
66#define __UINT64_C(x) uint_c(x, __int_least64_c_suffix__)
67#else
68#define __INT64_C(x) x
69#define __UINT64_C(x) x ## U
70#endif /* __int_least64_c_suffix__ */
71#endif /* __INT_LEAST64_TYPE__ */
72
73#ifdef __INT32_TYPE__
74#undef __int_least32_c_suffix__
75#undef __int_least16_c_suffix__
76#undef __int_least8_c_suffix__
77#ifdef __INT32_C_SUFFIX__
78#define __int_least32_c_suffix__ __INT32_C_SUFFIX__
79#define __int_least16_c_suffix__ __INT32_C_SUFFIX__
80#define __int_least8_c_suffix__ __INT32_C_SUFFIX__
81#endif /* __INT32_C_SUFFIX__ */
82#endif /* __INT32_TYPE__ */
83
84#ifdef __INT_LEAST32_TYPE__
85#ifdef __int_least32_c_suffix__
86#define __INT32_C(x) int_c(x, __int_least32_c_suffix__)
87#define __UINT32_C(x) uint_c(x, __int_least32_c_suffix__)
88#else
89#define __INT32_C(x) x
90#define __UINT32_C(x) x ## U
91#endif /* __int_least32_c_suffix__ */
92#endif /* __INT_LEAST32_TYPE__ */
93
94#endif /* !CONFIG_ENFORCE_ZEPHYR_STDINT */
95
96#ifdef __INT16_TYPE__
97#undef __int_least16_c_suffix__
98#undef __int_least8_c_suffix__
99#ifdef __INT16_C_SUFFIX__
100#define __int_least16_c_suffix__ __INT16_C_SUFFIX__
101#define __int_least8_c_suffix__ __INT16_C_SUFFIX__
102#endif /* __INT16_C_SUFFIX__ */
103#endif /* __INT16_TYPE__ */
104
105#ifdef __INT_LEAST16_TYPE__
106#ifdef __int_least16_c_suffix__
107#define __INT16_C(x) int_c(x, __int_least16_c_suffix__)
108#define __UINT16_C(x) uint_c(x, __int_least16_c_suffix__)
109#else
110#define __INT16_C(x) x
111#define __UINT16_C(x) x ## U
112#endif /* __int_least16_c_suffix__ */
113#endif /* __INT_LEAST16_TYPE__ */
114
115#ifdef __INT8_TYPE__
116#undef __int_least8_c_suffix__
117#ifdef __INT8_C_SUFFIX__
118#define __int_least8_c_suffix__ __INT8_C_SUFFIX__
119#endif /* __INT8_C_SUFFIX__ */
120#endif /* __INT8_TYPE__ */
121
122#ifdef __INT_LEAST8_TYPE__
123#ifdef __int_least8_c_suffix__
124#define __INT8_C(x) int_c(x, __int_least8_c_suffix__)
125#define __UINT8_C(x) uint_c(x, __int_least8_c_suffix__)
126#else
127#define __INT8_C(x) x
128#define __UINT8_C(x) x ## U
129#endif /* __int_least8_c_suffix__ */
130#endif /* __INT_LEAST8_TYPE__ */
131
132#define __INTMAX_C(x) int_c(x, __INTMAX_C_SUFFIX__)
133#define __UINTMAX_C(x) int_c(x, __UINTMAX_C_SUFFIX__)
134
135#endif /* CONFIG_MINIMAL_LIBC */
136
137#endif /* ZEPHYR_INCLUDE_TOOLCHAIN_LLVM_H_ */
GCC toolchain abstraction.