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 already defined
35 #if !defined(ETL_USING_BUILTIN_IS_ASSIGNABLE)
36 #define ETL_USING_BUILTIN_IS_ASSIGNABLE 1
37 #endif
38
39 #if !defined(ETL_USING_BUILTIN_IS_CONSTRUCTIBLE)
40 #define ETL_USING_BUILTIN_IS_CONSTRUCTIBLE 1
41 #endif
42
43 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE)
44 #define ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE 1
45 #endif
46
47 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE)
48 #define ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE 1
49 #endif
50
51 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE)
52 #define ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE 1
53 #endif
54
55 #if !defined(ETL_USING_BUILTIN_UNDERLYING_TYPE)
56 #define ETL_USING_BUILTIN_UNDERLYING_TYPE 1
57 #endif
58
59 #if !defined(ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED)
60 #define ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED 1
61 #endif
62
63 #if !defined(ETL_USING_BUILTIN_MEMCPY)
64 #define ETL_USING_BUILTIN_MEMCPY 1
65 #endif
66
67 #if !defined(ETL_USING_BUILTIN_MEMMOVE)
68 #define ETL_USING_BUILTIN_MEMMOVE 1
69 #endif
70
71 #if !defined(ETL_USING_BUILTIN_MEMSET)
72 #define ETL_USING_BUILTIN_MEMSET 1
73 #endif
74
75 #if !defined(ETL_USING_BUILTIN_MEMCMP)
76 #define ETL_USING_BUILTIN_MEMCMP 1
77 #endif
78
79 #if !defined(ETL_USING_BUILTIN_MEMCHR)
80 #define ETL_USING_BUILTIN_MEMCHR 1
81 #endif
82#endif
83
84#if defined(__has_builtin) && !defined(ETL_COMPILER_MICROSOFT) // Use __has_builtin to check for existence of builtin functions? Fix VS2022 intellisense issue.
85 #if !defined(ETL_USING_BUILTIN_IS_ASSIGNABLE)
86 #define ETL_USING_BUILTIN_IS_ASSIGNABLE __has_builtin(__is_assignable)
87 #endif
88
89 #if !defined(ETL_USING_BUILTIN_IS_CONSTRUCTIBLE)
90 #define ETL_USING_BUILTIN_IS_CONSTRUCTIBLE __has_builtin(__is_constructible)
91 #endif
92
93 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE)
94 #define ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE (__has_builtin(__has_trivial_constructor) || __has_builtin(__is_trivially_constructible))
95 #endif
96
97 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE)
98 #define ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE (__has_builtin(__has_trivial_destructor) || __has_builtin(__is_trivially_destructible))
99 #endif
100
101 #if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE)
102 #define ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE (__has_builtin(__has_trivial_copy) || __has_builtin(__is_trivially_copyable))
103 #endif
104
105 #if !defined(ETL_USING_BUILTIN_UNDERLYING_TYPE)
106 #define ETL_USING_BUILTIN_UNDERLYING_TYPE __has_builtin(__underlying_type)
107 #endif
108
109 #if !defined(ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED)
110 #define ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED __has_builtin(__builtin_is_constant_evaluated)
111 #endif
112
113 #if !defined(ETL_USING_BUILTIN_MEMCPY)
114 #define ETL_USING_BUILTIN_MEMCPY __has_builtin(__builtin_memcpy)
115 #endif
116
117 #if !defined(ETL_USING_BUILTIN_MEMMOVE)
118 #define ETL_USING_BUILTIN_MEMMOVE __has_builtin(__builtin_memmove)
119 #endif
120
121 #if !defined(ETL_USING_BUILTIN_MEMSET)
122 #define ETL_USING_BUILTIN_MEMSET __has_builtin(__builtin_memset)
123 #endif
124
125 #if !defined(ETL_USING_BUILTIN_MEMCMP)
126 #define ETL_USING_BUILTIN_MEMCMP __has_builtin(__builtin_memcmp)
127 #endif
128
129 #if !defined(ETL_USING_BUILTIN_MEMCHR)
130 #define ETL_USING_BUILTIN_MEMCHR __has_builtin(__builtin_memchr)
131 #endif
132#endif
133
134// The default. Set to 0, if not already set.
135#if !defined(ETL_USING_BUILTIN_IS_ASSIGNABLE)
136 #define ETL_USING_BUILTIN_IS_ASSIGNABLE 0
137#endif
138
139#if !defined(ETL_USING_BUILTIN_IS_CONSTRUCTIBLE)
140 #define ETL_USING_BUILTIN_IS_CONSTRUCTIBLE 0
141#endif
142
143#if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE)
144 #define ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE 0
145#endif
146
147#if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE)
148 #define ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE 0
149#endif
150
151#if !defined(ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE)
152 #define ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE 0
153#endif
154
155#if !defined(ETL_USING_BUILTIN_UNDERLYING_TYPE)
156 #define ETL_USING_BUILTIN_UNDERLYING_TYPE 0
157#endif
158
159#if !defined(ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED)
160 #define ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED 0
161#endif
162
163#if !defined(ETL_USING_BUILTIN_MEMCPY)
164 #define ETL_USING_BUILTIN_MEMCPY 0
165#endif
166
167#if !defined(ETL_USING_BUILTIN_MEMMOVE)
168 #define ETL_USING_BUILTIN_MEMMOVE 0
169#endif
170
171#if !defined(ETL_USING_BUILTIN_MEMSET)
172 #define ETL_USING_BUILTIN_MEMSET 0
173#endif
174
175#if !defined(ETL_USING_BUILTIN_MEMCMP)
176 #define ETL_USING_BUILTIN_MEMCMP 0
177#endif
178
179#if !defined(ETL_USING_BUILTIN_MEMCHR)
180 #define ETL_USING_BUILTIN_MEMCHR 0
181#endif
182
183namespace etl
184{
185 namespace traits
186 {
187 // Documentation: https://www.etlcpp.com/etl_traits.html
188
189 static ETL_CONSTANT bool using_builtin_is_assignable = (ETL_USING_BUILTIN_IS_ASSIGNABLE == 1);
190 static ETL_CONSTANT bool using_builtin_is_constructible = (ETL_USING_BUILTIN_IS_CONSTRUCTIBLE == 1);
191 static ETL_CONSTANT bool using_builtin_is_trivially_constructible = (ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE == 1);
192 static ETL_CONSTANT bool using_builtin_is_trivially_destructible = (ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE == 1);
193 static ETL_CONSTANT bool using_builtin_is_trivially_copyable = (ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE == 1);
194 static ETL_CONSTANT bool using_builtin_underlying_type = (ETL_USING_BUILTIN_UNDERLYING_TYPE == 1);
195 static ETL_CONSTANT bool using_builtin_is_constant_evaluated = (ETL_USING_BUILTIN_IS_CONSTANT_EVALUATED == 1);
196 static ETL_CONSTANT bool using_builtin_memcpy = (ETL_USING_BUILTIN_MEMCPY == 1);
197 static ETL_CONSTANT bool using_builtin_memmove = (ETL_USING_BUILTIN_MEMMOVE == 1);
198 static ETL_CONSTANT bool using_builtin_memset = (ETL_USING_BUILTIN_MEMSET == 1);
199 static ETL_CONSTANT bool using_builtin_memcmp = (ETL_USING_BUILTIN_MEMCMP == 1);
200 static ETL_CONSTANT bool using_builtin_memchr = (ETL_USING_BUILTIN_MEMCHR == 1);
201 }
202}
203
204#endif
bitset_ext
Definition absolute.h:39