Embedded Template Library 1.0
Loading...
Searching...
No Matches
determine_builtin_support.h
Go to the documentation of this file.
1
2
3/******************************************************************************
4The MIT License(MIT)
5
6Embedded Template Library.
7https://github.com/ETLCPP/etl
8https://www.etlcpp.com
9
10Copyright(c) 2021 John Wellbelove
11
12Permission is hereby granted, free of charge, to any person obtaining a copy
13of this software and associated documentation files(the "Software"), to deal
14in the Software without restriction, including without limitation the rights
15to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16copies of the Software, and to permit persons to whom the Software is
17furnished to do so, subject to the following conditions :
18
19The above copyright notice and this permission notice shall be included in all
20copies or substantial portions of the Software.
21
22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28SOFTWARE.
29******************************************************************************/
30
31#ifndef ETL_DETERMINE_BUILTIN_SUPPORT_H_INCLUDED
32#define ETL_DETERMINE_BUILTIN_SUPPORT_H_INCLUDED
33
34#if defined(ETL_USE_TYPE_TRAITS_BUILTINS) // Set all of them to be true if not
35 // already defined
36 #if !defined(ETL_USING_BUILTIN_IS_ASSIGNABLE)
37 #define ETL_USING_BUILTIN_IS_ASSIGNABLE 1
38 #endif
39
40 #if !defined(ETL_USING_BUILTIN_IS_CONSTRUCTIBLE)
41 #define ETL_USING_BUILTIN_IS_CONSTRUCTIBLE 1
42 #endif
43
44 #if !defined(ETL_USING_BUILTIN_IS_NOTHROW_CONSTRUCTIBLE)
45 #define ETL_USING_BUILTIN_IS_NOTHROW_CONSTRUCTIBLE 1
46 #endif
47
48 #if !defined(ETL_USING_BUILTIN_IS_NOTHROW_ASSIGNABLE)
49 #define ETL_USING_BUILTIN_IS_NOTHROW_ASSIGNABLE 1
50 #endif
51
52 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE)
53 #define ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE 1
54 #endif
55
56 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE)
57 #define ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE 1
58 #endif
59
60 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE)
61 #define ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE 1
62 #endif
63
64 #if !defined(ETL_USING_BUILTIN_UNDERLYING_TYPE)
65 #define ETL_USING_BUILTIN_UNDERLYING_TYPE 1
66 #endif
67
68 #if !defined(ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED)
69 #define ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED 1
70 #endif
71#endif
72
73#if defined(ETL_USE_BUILTIN_MEM_FUNCTIONS) // Set all of them to be true if not
74 // already defined
75 #if !defined(ETL_USING_BUILTIN_MEMCPY)
76 #define ETL_USING_BUILTIN_MEMCPY 1
77 #endif
78
79 #if !defined(ETL_USING_BUILTIN_MEMMOVE)
80 #define ETL_USING_BUILTIN_MEMMOVE 1
81 #endif
82
83 #if !defined(ETL_USING_BUILTIN_MEMSET)
84 #define ETL_USING_BUILTIN_MEMSET 1
85 #endif
86
87 #if !defined(ETL_USING_BUILTIN_MEMCMP)
88 #define ETL_USING_BUILTIN_MEMCMP 1
89 #endif
90
91 #if !defined(ETL_USING_BUILTIN_MEMCHR)
92 #define ETL_USING_BUILTIN_MEMCHR 1
93 #endif
94#endif
95
96#if defined(__has_builtin) && !defined(ETL_COMPILER_MICROSOFT) // Use __has_builtin to check for
97 // existence of builtin functions?
98 // Fix VS2022 intellisense issue.
99 #if !defined(ETL_USING_BUILTIN_IS_ASSIGNABLE)
100 #define ETL_USING_BUILTIN_IS_ASSIGNABLE __has_builtin(__is_assignable)
101 #endif
102
103 #if !defined(ETL_USING_BUILTIN_IS_CONSTRUCTIBLE)
104 #define ETL_USING_BUILTIN_IS_CONSTRUCTIBLE __has_builtin(__is_constructible)
105 #endif
106
107 #if !defined(ETL_USING_BUILTIN_IS_NOTHROW_CONSTRUCTIBLE)
108 #define ETL_USING_BUILTIN_IS_NOTHROW_CONSTRUCTIBLE __has_builtin(__is_nothrow_constructible)
109 #endif
110
111 #if !defined(ETL_USING_BUILTIN_IS_NOTHROW_ASSIGNABLE)
112 #define ETL_USING_BUILTIN_IS_NOTHROW_ASSIGNABLE __has_builtin(__is_nothrow_assignable)
113 #endif
114
115 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE)
116 #define ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE (__has_builtin(__has_trivial_constructor) || __has_builtin(__is_trivially_constructible))
117 #endif
118
119 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE)
120 #define ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE (__has_builtin(__has_trivial_destructor) || __has_builtin(__is_trivially_destructible))
121 #endif
122
123 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE)
124 #define ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE (__has_builtin(__has_trivial_copy) || __has_builtin(__is_trivially_copyable))
125 #endif
126
127 #if !defined(ETL_USING_BUILTIN_UNDERLYING_TYPE)
128 #define ETL_USING_BUILTIN_UNDERLYING_TYPE __has_builtin(__underlying_type)
129 #endif
130
131 #if !defined(ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED)
132 #define ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED __has_builtin(__builtin_is_constant_evaluated)
133 #endif
134
135 #if !defined(ETL_USING_BUILTIN_MEMCPY)
136 #define ETL_USING_BUILTIN_MEMCPY __has_builtin(__builtin_memcpy)
137 #endif
138
139 #if !defined(ETL_USING_BUILTIN_MEMMOVE)
140 #define ETL_USING_BUILTIN_MEMMOVE __has_builtin(__builtin_memmove)
141 #endif
142
143 #if !defined(ETL_USING_BUILTIN_MEMSET)
144 #define ETL_USING_BUILTIN_MEMSET __has_builtin(__builtin_memset)
145 #endif
146
147 #if !defined(ETL_USING_BUILTIN_MEMCMP)
148 #define ETL_USING_BUILTIN_MEMCMP __has_builtin(__builtin_memcmp)
149 #endif
150
151 #if !defined(ETL_USING_BUILTIN_MEMCHR)
152 #define ETL_USING_BUILTIN_MEMCHR __has_builtin(__builtin_memchr)
153 #endif
154
155 #if !defined(ETL_USING_BUILTIN_IS_VIRTUAL_BASE_OF)
156 #define ETL_USING_BUILTIN_IS_VIRTUAL_BASE_OF __has_builtin(__is_virtual_base_of)
157 #endif
158
159 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_RELOCATABLE)
160 #define ETL_USING_BUILTIN_IS_TRIVIALLY_RELOCATABLE __has_builtin(__is_trivially_relocatable)
161 #endif
162
163 // __builtin_is_cpp_trivially_relocatable replaces __is_trivially_relocatable by an
164 // effort of standardization for newer C++ standards
165 #if !defined(ETL_USING_BUILTIN_BUILTIN_IS_CPP_TRIVIALLY_RELOCATABLE)
166 #define ETL_USING_BUILTIN_BUILTIN_IS_CPP_TRIVIALLY_RELOCATABLE __has_builtin(__builtin_is_cpp_trivially_relocatable)
167 #endif
168#endif
169
170#if defined(ETL_COMPILER_MICROSOFT) // The Microsoft compiler supports the __is_trivially_copyable
171 // intrinsic directly. __has_builtin is not used for Microsoft
172 // (see above) to avoid a VS2022 intellisense issue, so the
173 // intrinsic is enabled here for the no-STL configuration.
174 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE)
175 #define ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE 1
176 #endif
177#endif
178
179// The default. Set to 0, if not already set.
180#if !defined(ETL_USING_BUILTIN_IS_ASSIGNABLE)
181 #define ETL_USING_BUILTIN_IS_ASSIGNABLE 0
182#endif
183
184#if !defined(ETL_USING_BUILTIN_IS_CONSTRUCTIBLE)
185 #define ETL_USING_BUILTIN_IS_CONSTRUCTIBLE 0
186#endif
187
188#if !defined(ETL_USING_BUILTIN_IS_NOTHROW_CONSTRUCTIBLE)
189 #define ETL_USING_BUILTIN_IS_NOTHROW_CONSTRUCTIBLE 0
190#endif
191
192#if !defined(ETL_USING_BUILTIN_IS_NOTHROW_ASSIGNABLE)
193 #define ETL_USING_BUILTIN_IS_NOTHROW_ASSIGNABLE 0
194#endif
195
196#if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE)
197 #define ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE 0
198#endif
199
200#if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE)
201 #define ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE 0
202#endif
203
204#if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE)
205 #define ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE 0
206#endif
207
208#if !defined(ETL_USING_BUILTIN_UNDERLYING_TYPE)
209 #define ETL_USING_BUILTIN_UNDERLYING_TYPE 0
210#endif
211
212#if !defined(ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED)
213 #define ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED 0
214#endif
215
216#if !defined(ETL_USING_BUILTIN_MEMCPY)
217 #define ETL_USING_BUILTIN_MEMCPY 0
218#endif
219
220#if !defined(ETL_USING_BUILTIN_MEMMOVE)
221 #define ETL_USING_BUILTIN_MEMMOVE 0
222#endif
223
224#if !defined(ETL_USING_BUILTIN_MEMSET)
225 #define ETL_USING_BUILTIN_MEMSET 0
226#endif
227
228#if !defined(ETL_USING_BUILTIN_MEMCMP)
229 #define ETL_USING_BUILTIN_MEMCMP 0
230#endif
231
232#if !defined(ETL_USING_BUILTIN_MEMCHR)
233 #define ETL_USING_BUILTIN_MEMCHR 0
234#endif
235
236#if !defined(ETL_USING_BUILTIN_IS_VIRTUAL_BASE_OF)
237 #define ETL_USING_BUILTIN_IS_VIRTUAL_BASE_OF 0
238#endif
239
240#if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_RELOCATABLE)
241 #define ETL_USING_BUILTIN_IS_TRIVIALLY_RELOCATABLE 0
242#endif
243
244#if !defined(ETL_USING_BUILTIN_BUILTIN_IS_CPP_TRIVIALLY_RELOCATABLE)
245 #define ETL_USING_BUILTIN_BUILTIN_IS_CPP_TRIVIALLY_RELOCATABLE 0
246#endif
247
248namespace etl
249{
250 namespace traits
251 {
252 // Documentation: https://www.etlcpp.com/etl_traits.html
253
254 static ETL_CONSTANT bool using_builtin_is_assignable = (ETL_USING_BUILTIN_IS_ASSIGNABLE == 1);
255 static ETL_CONSTANT bool using_builtin_is_constructible = (ETL_USING_BUILTIN_IS_CONSTRUCTIBLE == 1);
256 static ETL_CONSTANT bool using_builtin_is_nothrow_constructible = (ETL_USING_BUILTIN_IS_NOTHROW_CONSTRUCTIBLE == 1);
257 static ETL_CONSTANT bool using_builtin_is_nothrow_assignable = (ETL_USING_BUILTIN_IS_NOTHROW_ASSIGNABLE == 1);
258 static ETL_CONSTANT bool using_builtin_is_trivially_constructible = (ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE == 1);
259 static ETL_CONSTANT bool using_builtin_is_trivially_destructible = (ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE == 1);
260 static ETL_CONSTANT bool using_builtin_is_trivially_copyable = (ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE == 1);
261 static ETL_CONSTANT bool using_builtin_underlying_type = (ETL_USING_BUILTIN_UNDERLYING_TYPE == 1);
262 static ETL_CONSTANT bool using_builtin_is_constant_evaluated = (ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED == 1);
263 static ETL_CONSTANT bool using_builtin_memcpy = (ETL_USING_BUILTIN_MEMCPY == 1);
264 static ETL_CONSTANT bool using_builtin_memmove = (ETL_USING_BUILTIN_MEMMOVE == 1);
265 static ETL_CONSTANT bool using_builtin_memset = (ETL_USING_BUILTIN_MEMSET == 1);
266 static ETL_CONSTANT bool using_builtin_memcmp = (ETL_USING_BUILTIN_MEMCMP == 1);
267 static ETL_CONSTANT bool using_builtin_memchr = (ETL_USING_BUILTIN_MEMCHR == 1);
268 static ETL_CONSTANT bool using_builtin_is_virtual_base_of = (ETL_USING_BUILTIN_IS_VIRTUAL_BASE_OF == 1);
269 static ETL_CONSTANT bool using_builtin_is_trivially_relocatable = (ETL_USING_BUILTIN_IS_TRIVIALLY_RELOCATABLE == 1);
270 static ETL_CONSTANT bool using_builtin_builtin_is_cpp_trivially_relocatable = (ETL_USING_BUILTIN_BUILTIN_IS_CPP_TRIVIALLY_RELOCATABLE == 1);
271 } // namespace traits
272} // namespace etl
273
274#endif
Definition absolute.h:40