Embedded Template Library 1.0
Loading...
Searching...
No Matches
platform.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) 2016 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_PLATFORM_INCLUDED
32#define ETL_PLATFORM_INCLUDED
33
34//*************************************
35// Enable all limit macros
36// Note: This macro must be defined before the first include of stdint.h
37#if !defined(__STDC_LIMIT_MACROS)
38 #define __STDC_LIMIT_MACROS
39#endif
40
41//*************************************
42// Enable all constant macros
43// Note: This macro must be defined before the first include of stdint.h
44#if !defined(__STDC_CONSTANT_MACROS)
45 #define __STDC_CONSTANT_MACROS
46#endif
47
48#include <stddef.h>
49#include <stdint.h>
50#include <limits.h>
51
52#include "file_error_numbers.h"
53
54//*************************************
55// Include the user's profile definition.
56#if !defined(ETL_NO_PROFILE_HEADER) && defined(__has_include)
57 #if !__has_include("etl_profile.h")
58 #define ETL_NO_PROFILE_HEADER
59 #endif
60#endif
61
62#if !defined(ETL_NO_PROFILE_HEADER)
63 #include "etl_profile.h"
64#endif
65
66// Null statement
67#define ETL_DO_NOTHING static_cast<void>(0)
68
69// Determine the bit width of the platform.
70#define ETL_PLATFORM_16BIT (UINT16_MAX == UINTPTR_MAX)
71#define ETL_PLATFORM_32BIT (UINT32_MAX == UINTPTR_MAX)
72#define ETL_PLATFORM_64BIT (UINT64_MAX == UINTPTR_MAX)
73
74//*************************************
75// Define debug macros.
76#if (defined(_DEBUG) || defined(DEBUG)) && !defined(ETL_DEBUG)
77 #define ETL_DEBUG
78#endif
79
80#if defined(ETL_DEBUG)
81 #define ETL_IS_DEBUG_BUILD 1
82#else
83 #define ETL_IS_DEBUG_BUILD 0
84#endif
85
86//*************************************
87// Helper macros, so we don't have to use double negatives.
88// The ETL will use the STL, unless ETL_NO_STL is defined.
89// With this macro we can use '#if ETL_USING_STL' instead of '#if !ETL_NO_STL' in the code.
90#if defined(ETL_NO_STL)
91 #define ETL_USING_STL 0
92 #define ETL_NOT_USING_STL 1
93#else
94 #define ETL_USING_STL 1
95 #define ETL_NOT_USING_STL 0
96#endif
97
98//*************************************
99// Helper macros for ETL_STLPORT.
100#if defined(ETL_STLPORT)
101 #define ETL_USING_STLPORT 1
102 #define ETL_NOT_USING_STLPORT 0
103#else
104 #define ETL_USING_STLPORT 0
105 #define ETL_NOT_USING_STLPORT 1
106#endif
107
108//*************************************
109// Some targets do not support 8bit types.
110#if (CHAR_BIT == 8)
111 #define ETL_USING_8BIT_TYPES 1
112 #define ETL_NOT_USING_8BIT_TYPES 0
113#else
114 #define ETL_USING_8BIT_TYPES 0
115 #define ETL_NOT_USING_8BIT_TYPES 1
116#endif
117
118#define ETL_8BIT_SUPPORT (CHAR_BIT == 8) // Deprecated
119
120//*************************************
121// Some targets support 20bit types.
122#if defined(ETL_USE_20BIT_TYPES)
123 #define ETL_USING_20BIT_TYPES 1
124 #define ETL_NOT_USING_20BIT_TYPES 0
125#else
126 #define ETL_USING_20BIT_TYPES 0
127 #define ETL_NOT_USING_20BIT_TYPES 1
128#endif
129
130
131//*************************************
132// Helper macro for ETL_NO_64BIT_TYPES.
133#if defined(ETL_NO_64BIT_TYPES)
134 #define ETL_USING_64BIT_TYPES 0
135 #define ETL_NOT_USING_64BIT_TYPES 1
136#else
137 #define ETL_USING_64BIT_TYPES 1
138 #define ETL_NOT_USING_64BIT_TYPES 0
139#endif
140
141//*************************************
142// For when the runtime library is compiled without wchar_t support.
143#if defined(ETL_NO_WIDE_CHARACTERS)
144 #define ETL_USING_WIDE_CHARACTERS 0
145 #define ETL_NOT_USING_WIDE_CHARACTERS 1
146#else
147 #define ETL_USING_WIDE_CHARACTERS 1
148 #define ETL_NOT_USING_WIDE_CHARACTERS 0
149#endif
150
151//*************************************
152// Figure out things about the compiler, if haven't already done so in etl_profile.h
155
156//*************************************
157// See if we can determine the OS we're compiling on, if haven't already done so in etl_profile.h
159
160//*************************************
161// Helper macro for choosing the variant type.
162#if !ETL_USING_CPP11 || defined(ETL_USE_LEGACY_VARIANT)
163 #define ETL_USING_LEGACY_VARIANT 1
164 #define ETL_NOT_USING_LEGACY_VARIANT 0
165#else
166 #define ETL_USING_LEGACY_VARIANT 0
167 #define ETL_NOT_USING_LEGACY_VARIANT 1
168#endif
169
170//*************************************
171// Check WCHAR_MIN and WCHAR_MAX
172#if !defined(WCHAR_MIN)
173 #define WCHAR_MIN 0x0000
174#endif
175
176#if !defined(WCHAR_MAX)
177 #define WCHAR_MAX 0xFFFF
178#endif
179
180//*************************************
181// Option to force string construction from a character pointer to be explicit.
182#if defined(ETL_FORCE_EXPLICIT_STRING_CONVERSION_FROM_CHAR)
183 #define ETL_EXPLICIT_STRING_FROM_CHAR explicit
184#else
185 #define ETL_EXPLICIT_STRING_FROM_CHAR
186#endif
187
188//*************************************
189// Option to disable truncation checks for strings.
190#if defined(ETL_DISABLE_STRING_TRUNCATION_CHECKS)
191 #define ETL_HAS_STRING_TRUNCATION_CHECKS 0
192#else
193 #define ETL_HAS_STRING_TRUNCATION_CHECKS 1
194#endif
195
196//*************************************
197// Option to disable clear-after-use functionality for strings.
198#if defined(ETL_DISABLE_STRING_CLEAR_AFTER_USE)
199 #define ETL_HAS_STRING_CLEAR_AFTER_USE 0
200#else
201 #define ETL_HAS_STRING_CLEAR_AFTER_USE 1
202#endif
203
204//*************************************
205// Option to make string truncation an error.
206#if defined(ETL_ENABLE_ERROR_ON_STRING_TRUNCATION)
207 #define ETL_HAS_ERROR_ON_STRING_TRUNCATION 1
208#else
209 #define ETL_HAS_ERROR_ON_STRING_TRUNCATION 0
210#endif
211
212//*************************************
213// Option to enable repair-after-memcpy for istrings.
214#if defined(ETL_ISTRING_REPAIR_ENABLE)
215 #define ETL_HAS_ISTRING_REPAIR 1
216#else
217 #define ETL_HAS_ISTRING_REPAIR 0
218#endif
219
220//*************************************
221// Option to enable repair-after-memcpy for ivector.
222#if defined(ETL_IVECTOR_REPAIR_ENABLE)
223 #define ETL_HAS_IVECTOR_REPAIR 1
224#else
225 #define ETL_HAS_IVECTOR_REPAIR 0
226#endif
227
228//*************************************
229// Option to enable repair-after-memcpy for ideque.
230#if defined(ETL_IDEQUE_REPAIR_ENABLE)
231 #define ETL_HAS_IDEQUE_REPAIR 1
232#else
233 #define ETL_HAS_IDEQUE_REPAIR 0
234#endif
235
236//*************************************
237// Option to enable repair-after-memcpy for icircular_buffer.
238#if defined(ETL_ICIRCULAR_BUFFER_REPAIR_ENABLE)
239#define ETL_HAS_ICIRCULAR_BUFFER_REPAIR 1
240#else
241#define ETL_HAS_ICIRCULAR_BUFFER_REPAIR 0
242#endif
243
244//*************************************
245// Indicate if C++ exceptions within the ETL are enabled.
246#if defined(ETL_THROW_EXCEPTIONS)
247 #define ETL_USING_EXCEPTIONS 1
248 #define ETL_NOT_USING_EXCEPTIONS 0
249#else
250 #define ETL_USING_EXCEPTIONS 0
251 #define ETL_NOT_USING_EXCEPTIONS 1
252#endif
253
254//*************************************
255// Indicate if C++ exceptions are enabled for debug asserts.
256#if ETL_IS_DEBUG_BUILD && defined(ETL_DEBUG_THROW_EXCEPTIONS)
257 #define ETL_DEBUG_USING_EXCEPTIONS 1
258 #define ETL_DEBUG_NOT_USING_EXCEPTIONS 0
259#else
260 #define ETL_DEBUG_USING_EXCEPTIONS 0
261 #define ETL_DEBUG_NOT_USING_EXCEPTIONS 1
262#endif
263
264//*************************************
265// Indicate if nullptr is used.
266#if ETL_NO_NULLPTR_SUPPORT
267 #define ETL_HAS_NULLPTR 0
268#else
269 #define ETL_HAS_NULLPTR 1
270#endif
271
272//*************************************
273// Indicate if legacy bitset is used.
274#if defined(ETL_USE_LEGACY_BITSET)
275 #define ETL_USING_LEGACY_BITSET 1
276#else
277 #define ETL_USING_LEGACY_BITSET 0
278#endif
279
280//*************************************
281// Indicate if array_view is mutable.
282#if defined(ETL_ARRAY_VIEW_IS_MUTABLE)
283 #define ETL_HAS_MUTABLE_ARRAY_VIEW 1
284#else
285 #define ETL_HAS_MUTABLE_ARRAY_VIEW 0
286#endif
287
288//*************************************
289// Indicate if etl::imassage is to be non-virtual.
290#if defined(ETL_MESSAGES_ARE_NOT_VIRTUAL)
291 #define ETL_HAS_VIRTUAL_MESSAGES 0
292#else
293 #define ETL_HAS_VIRTUAL_MESSAGES 1
294#endif
295
296//*************************************
297// Indicate if etl::literals::chrono_literals uses ETL verbose style.
298#if defined(ETL_USE_VERBOSE_CHRONO_LITERALS) && ETL_USING_CPP11
299#define ETL_USING_VERBOSE_CHRONO_LITERALS 1
300#else
301#define ETL_USING_VERBOSE_CHRONO_LITERALS 0
302#endif
303
304//*************************************
305// Indicate if etl::literals::chrono_literals has days (_days)
306#if defined(ETL_DISABLE_CHRONO_LITERALS_DAY) && ETL_USING_CPP11
307 #define ETL_HAS_CHRONO_LITERALS_DAY 0
308#else
309 #define ETL_HAS_CHRONO_LITERALS_DAY 1
310#endif
311
312//*************************************
313// Indicate if etl::literals::chrono_literals has year (_years)
314#if defined(ETL_DISABLE_CHRONO_LITERALS_YEAR) && ETL_USING_CPP11
315 #define ETL_HAS_CHRONO_LITERALS_YEAR 0
316#else
317 #define ETL_HAS_CHRONO_LITERALS_YEAR 1
318#endif
319
320//*************************************
321// Indicate if etl::literals::chrono_literals has year (_hours, _minutes, _seconds, _milliseconds, _microseconds, _nanoseconds)
322#if defined(ETL_DISABLE_CHRONO_LITERALS_DURATION) && ETL_USING_CPP11
323#define ETL_HAS_CHRONO_LITERALS_DURATION 0
324#else
325#define ETL_HAS_CHRONO_LITERALS_DURATION 1
326#endif
327
328//*************************************
329// Indicate if noexcept is part of the function type.
330#if !defined(ETL_HAS_NOEXCEPT_FUNCTION_TYPE)
331 #if defined(__cpp_noexcept_function_type) && (__cpp_noexcept_function_type >= 201510)
332 #define ETL_HAS_NOEXCEPT_FUNCTION_TYPE 1
333 #else
334 #define ETL_HAS_NOEXCEPT_FUNCTION_TYPE 0
335 #endif
336#endif
337
338//*************************************
339// The macros below are dependent on the profile.
340// C++11
341#if ETL_USING_CPP11
342 #define ETL_CONSTEXPR constexpr
343 #define ETL_CONSTEXPR11 constexpr // Synonym for ETL_CONSTEXPR
344 #define ETL_CONSTANT constexpr
345 #define ETL_DELETE = delete
346 #define ETL_EXPLICIT explicit
347 #define ETL_OVERRIDE override
348 #define ETL_FINAL final
349 #define ETL_NORETURN [[noreturn]]
350 #define ETL_MOVE(x) etl::move(x)
351 #define ETL_ENUM_CLASS(name) enum class name
352 #define ETL_ENUM_CLASS_TYPE(name, type) enum class name : type
353 #define ETL_LVALUE_REF_QUALIFIER &
354 #if ETL_USING_EXCEPTIONS
355 #define ETL_NOEXCEPT noexcept
356 #define ETL_NOEXCEPT_EXPR(...) noexcept(__VA_ARGS__)
357 #define ETL_NOEXCEPT_FROM(x) noexcept(noexcept(x))
358 #else
359 #define ETL_NOEXCEPT
360 #define ETL_NOEXCEPT_EXPR(...)
361 #define ETL_NOEXCEPT_FROM(x)
362 #endif
363#else
364 #define ETL_CONSTEXPR
365 #define ETL_CONSTEXPR11
366 #define ETL_CONSTANT const
367 #define ETL_DELETE
368 #define ETL_EXPLICIT
369 #define ETL_OVERRIDE
370 #define ETL_FINAL
371 #define ETL_NORETURN
372 #define ETL_NOEXCEPT
373 #define ETL_NOEXCEPT_EXPR(...)
374 #define ETL_NOEXCEPT_FROM(x)
375 #define ETL_MOVE(x) x
376 #define ETL_ENUM_CLASS(name) enum name
377 #define ETL_ENUM_CLASS_TYPE(name, type) enum name
378 #define ETL_LVALUE_REF_QUALIFIER
379#endif
380
381//*************************************
382// C++14
383#if ETL_USING_CPP14
384 #define ETL_CONSTEXPR14 constexpr
385
386 #if !defined(ETL_IN_UNIT_TEST)
387 #define ETL_DEPRECATED [[deprecated]]
388 #define ETL_DEPRECATED_REASON(reason) [[deprecated(reason)]]
389 #else
390 #define ETL_DEPRECATED
391 #define ETL_DEPRECATED_REASON(reason)
392 #endif
393#else
394 #define ETL_CONSTEXPR14
395 #define ETL_DEPRECATED
396 #define ETL_DEPRECATED_REASON(reason)
397#endif
398
399//*************************************
400// C++17
401#if ETL_USING_CPP17
402 #define ETL_CONSTEXPR17 constexpr
403 #define ETL_IF_CONSTEXPR constexpr
404 #define ETL_NODISCARD [[nodiscard]]
405 #define ETL_MAYBE_UNUSED [[maybe_unused]]
406 #define ETL_FALLTHROUGH [[fallthrough]]
407 #define ETL_INLINE_VAR inline
408#else
409 #define ETL_CONSTEXPR17
410 #define ETL_IF_CONSTEXPR
411 #define ETL_NODISCARD
412 #define ETL_MAYBE_UNUSED
413 #define ETL_FALLTHROUGH
414 #define ETL_INLINE_VAR
415#endif
416
417//*************************************
418// C++20
419#if ETL_USING_CPP20
420 #define ETL_LIKELY [[likely]]
421 #define ETL_UNLIKELY [[unlikely]]
422 #define ETL_CONSTEXPR20 constexpr
423 #define ETL_CONSTEVAL consteval
424 #define ETL_CONSTINIT constinit
425 #define ETL_NO_UNIQUE_ADDRESS [[no_unique_address]]
426 #define ETL_EXPLICIT_EXPR(...) explicit(__VA_ARGS__)
427#else
428 #define ETL_LIKELY
429 #define ETL_UNLIKELY
430 #define ETL_CONSTEXPR20
431 #define ETL_CONSTEVAL
432 #define ETL_CONSTINIT
433 #define ETL_NO_UNIQUE_ADDRESS
434 #define ETL_EXPLICIT_EXPR(...) explicit
435#endif
436
437#if ETL_USING_CPP20 && ETL_USING_STL
438 #define ETL_CONSTEXPR20_STL constexpr
439#else
440 #define ETL_CONSTEXPR20_STL
441#endif
442
443//*************************************
444// C++23
445#if ETL_USING_CPP23
446 #define ETL_ASSUME(expression) [[assume(expression)]]
447#else
448 #define ETL_ASSUME ETL_DO_NOTHING
449#endif
450
451//*************************************
452// Determine if the ETL can use char8_t type.
453#if ETL_NO_SMALL_CHAR_SUPPORT
455 typedef uint_least8_t char8_t;
456 #define ETL_HAS_CHAR8_T 1
457 #define ETL_HAS_NATIVE_CHAR8_T 0
459#else
460 #define ETL_HAS_CHAR8_T 1
461 #define ETL_HAS_NATIVE_CHAR8_T 1
462#endif
463
464//*************************************
465// Define the large character types if necessary.
466#if ETL_NO_LARGE_CHAR_SUPPORT
467 typedef uint_least16_t char16_t;
468 typedef uint_least32_t char32_t;
469 #define ETL_HAS_NATIVE_CHAR16_T 0
470 #define ETL_HAS_NATIVE_CHAR32_T 0
471#else
472 #define ETL_HAS_NATIVE_CHAR16_T 1
473 #define ETL_HAS_NATIVE_CHAR32_T 1
474#endif
475
476//*************************************
477// Determine if the ETL can use std::array
478#if !defined(ETL_HAS_STD_ARRAY)
479 #if ETL_USING_STL && ETL_USING_CPP11
480 #define ETL_HAS_STD_ARRAY 1
481 #else
482 #define ETL_HAS_STD_ARRAY 0
483 #endif
484#endif
485
486//*************************************
487// Determine if the ETL can use libc's wchar.h
488#if !defined(ETL_NO_LIBC_WCHAR_H)
489 #if defined(__has_include)
490 #if !__has_include(<wchar.h>)
491 #define ETL_NO_LIBC_WCHAR_H
492 #endif
493 #endif
494#endif
495
496#if defined(ETL_NO_LIBC_WCHAR_H)
497 #define ETL_USING_LIBC_WCHAR_H 0
498 #define ETL_NOT_USING_LIBC_WCHAR_H 1
499#else
500 #define ETL_USING_LIBC_WCHAR_H 1
501 #define ETL_NOT_USING_LIBC_WCHAR_H 0
502#endif
503
504//*************************************
505// Determine if the ETL can use STL ostream
506#if !defined(ETL_NO_STD_OSTREAM) && ETL_USING_STL
507 #if defined(__has_include)
508 #if !__has_include(<ostream>)
509 #define ETL_NO_STD_OSTREAM
510 #endif
511 #endif
512#endif
513
514#if defined(ETL_NO_STD_OSTREAM) || (ETL_NOT_USING_STL && !defined(ETL_IN_UNIT_TEST))
515 #define ETL_USING_STD_OSTREAM 0
516 #define ETL_NOT_USING_STD_OSTREAM 1
517#else
518 #define ETL_USING_STD_OSTREAM 1
519 #define ETL_NOT_USING_STD_OSTREAM 0
520#endif
521
522//*************************************
523// Determine if the ETL should support atomics.
524#if defined(ETL_NO_ATOMICS) || \
525 defined(ETL_TARGET_DEVICE_ARM_CORTEX_M0) || \
526 defined(ETL_TARGET_DEVICE_ARM_CORTEX_M0_PLUS) || \
527 defined(__STDC_NO_ATOMICS__)
528 #define ETL_HAS_ATOMIC 0
529 #define ETL_HAS_ATOMIC_ALWAYS_LOCK_FREE 0
530#else
531 #if ((ETL_USING_CPP11 && (ETL_USING_STL || defined(ETL_IN_UNIT_TEST))) || \
532 defined(ETL_COMPILER_ARM5) || \
533 defined(ETL_COMPILER_ARM6) || \
534 defined(ETL_COMPILER_GCC) || \
535 defined(ETL_COMPILER_CLANG))
536 #define ETL_HAS_ATOMIC 1
537 #else
538 #define ETL_HAS_ATOMIC 0
539 #endif
540 #if ((ETL_USING_CPP17 && (ETL_USING_STL || defined(ETL_IN_UNIT_TEST))) || \
541 defined(ETL_COMPILER_ARM5) || \
542 defined(ETL_COMPILER_ARM6) || \
543 defined(ETL_COMPILER_GCC) || \
544 defined(ETL_COMPILER_CLANG))
545 #define ETL_HAS_ATOMIC_ALWAYS_LOCK_FREE 1
546 #else
547 #define ETL_HAS_ATOMIC_ALWAYS_LOCK_FREE 0
548 #endif
549#endif
550
551//*************************************
552// Determine if the ETL should use std::initializer_list.
553#if (defined(ETL_FORCE_ETL_INITIALIZER_LIST) && defined(ETL_FORCE_STD_INITIALIZER_LIST))
554 #error ETL_FORCE_ETL_INITIALIZER_LIST and ETL_FORCE_STD_INITIALIZER_LIST both been defined. Choose one or neither.
555#endif
556
557#if (ETL_USING_CPP11 && !defined(ETL_NO_INITIALIZER_LIST))
558 // Use the compiler's std::initializer_list?
559 #if (ETL_USING_STL && ETL_NOT_USING_STLPORT && !defined(ETL_FORCE_ETL_INITIALIZER_LIST)) || defined(ETL_IN_UNIT_TEST) || defined(ETL_FORCE_STD_INITIALIZER_LIST)
560 #define ETL_HAS_INITIALIZER_LIST 1
561 #else
562 // Use the ETL's compatible version?
563 #if defined(ETL_COMPILER_MICROSOFT) || defined(ETL_COMPILER_GCC) || defined(ETL_COMPILER_CLANG) || \
564 defined(ETL_COMPILER_ARM6) || defined(ETL_COMPILER_ARM7) || defined(ETL_COMPILER_IAR) || \
565 defined(ETL_COMPILER_TEXAS_INSTRUMENTS) || defined(ETL_COMPILER_INTEL)
566 #define ETL_HAS_INITIALIZER_LIST 1
567 #else
568 #define ETL_HAS_INITIALIZER_LIST 0
569 #endif
570 #endif
571#else
572 #define ETL_HAS_INITIALIZER_LIST 0
573#endif
574
575//*************************************
576// Determine if the ETL should use __attribute__((packed).
577#if defined(ETL_COMPILER_CLANG) || defined(ETL_COMPILER_GCC) || defined(ETL_COMPILER_INTEL) || defined(ETL_COMPILER_ARM6)
578 #define ETL_PACKED_CLASS(class_type) class __attribute__((packed)) class_type
579 #define ETL_PACKED_STRUCT(struct_type) struct __attribute__((packed)) struct_type
580 #define ETL_END_PACKED
581 #define ETL_HAS_PACKED 1
582#elif defined(ETL_COMPILER_MICROSOFT)
583 #define ETL_PACKED_CLASS(class_type) __pragma(pack(push, 1)) class class_type
584 #define ETL_PACKED_STRUCT(struct_type) __pragma(pack(push, 1)) struct struct_type
585 #define ETL_PACKED
586 #define ETL_END_PACKED __pragma(pack(pop))
587 #define ETL_HAS_PACKED 1
588#else
589 #define ETL_PACKED_CLASS(class_type) class class_type
590 #define ETL_PACKED_STRUCT(struct_type) struct struct_type
591 #define ETL_END_PACKED
592 #define ETL_HAS_PACKED 0
593#endif
594
595//*************************************
596// Check for availability of certain builtins
598
599//*************************************
600// Sort out namespaces for STL/No STL options.
602
603namespace etl
604{
605 namespace traits
606 {
607 // Documentation: https://www.etlcpp.com/etl_traits.html
608 // General
609 static ETL_CONSTANT long cplusplus = __cplusplus;
610 static ETL_CONSTANT int language_standard = ETL_LANGUAGE_STANDARD;
611
612 // Using...
613 static ETL_CONSTANT bool using_stl = (ETL_USING_STL == 1);
614 static ETL_CONSTANT bool using_stlport = (ETL_USING_STLPORT == 1);
615 static ETL_CONSTANT bool using_cpp11 = (ETL_USING_CPP11 == 1);
616 static ETL_CONSTANT bool using_cpp14 = (ETL_USING_CPP14 == 1);
617 static ETL_CONSTANT bool using_cpp17 = (ETL_USING_CPP17 == 1);
618 static ETL_CONSTANT bool using_cpp20 = (ETL_USING_CPP20 == 1);
619 static ETL_CONSTANT bool using_cpp23 = (ETL_USING_CPP23 == 1);
620 static ETL_CONSTANT bool using_gcc_compiler = (ETL_USING_GCC_COMPILER == 1);
621 static ETL_CONSTANT bool using_microsoft_compiler = (ETL_USING_MICROSOFT_COMPILER == 1);
622 static ETL_CONSTANT bool using_arm5_compiler = (ETL_USING_ARM5_COMPILER == 1);
623 static ETL_CONSTANT bool using_arm6_compiler = (ETL_USING_ARM6_COMPILER == 1);
624 static ETL_CONSTANT bool using_arm7_compiler = (ETL_USING_ARM7_COMPILER == 1);
625 static ETL_CONSTANT bool using_clang_compiler = (ETL_USING_CLANG_COMPILER == 1);
626 static ETL_CONSTANT bool using_green_hills_compiler = (ETL_USING_GREEN_HILLS_COMPILER == 1);
627 static ETL_CONSTANT bool using_iar_compiler = (ETL_USING_IAR_COMPILER == 1);
628 static ETL_CONSTANT bool using_intel_compiler = (ETL_USING_INTEL_COMPILER == 1);
629 static ETL_CONSTANT bool using_texas_instruments_compiler = (ETL_USING_TEXAS_INSTRUMENTS_COMPILER == 1);
630 static ETL_CONSTANT bool using_generic_compiler = (ETL_USING_GENERIC_COMPILER == 1);
631 static ETL_CONSTANT bool using_legacy_bitset = (ETL_USING_LEGACY_BITSET == 1);
632 static ETL_CONSTANT bool using_exceptions = (ETL_USING_EXCEPTIONS == 1);
633 static ETL_CONSTANT bool using_libc_wchar_h = (ETL_USING_LIBC_WCHAR_H == 1);
634
635 // Has...
636 static ETL_CONSTANT bool has_initializer_list = (ETL_HAS_INITIALIZER_LIST == 1);
637 static ETL_CONSTANT bool has_8bit_types = (ETL_USING_8BIT_TYPES == 1);
638 static ETL_CONSTANT bool has_64bit_types = (ETL_USING_64BIT_TYPES == 1);
639 static ETL_CONSTANT bool has_atomic = (ETL_HAS_ATOMIC == 1);
640 static ETL_CONSTANT bool has_atomic_always_lock_free = (ETL_HAS_ATOMIC_ALWAYS_LOCK_FREE == 1);
641 static ETL_CONSTANT bool has_nullptr = (ETL_HAS_NULLPTR == 1);
642 static ETL_CONSTANT bool has_char8_t = (ETL_HAS_CHAR8_T == 1);
643 static ETL_CONSTANT bool has_native_char8_t = (ETL_HAS_NATIVE_CHAR8_T == 1);
644 static ETL_CONSTANT bool has_native_char16_t = (ETL_HAS_NATIVE_CHAR16_T == 1);
645 static ETL_CONSTANT bool has_native_char32_t = (ETL_HAS_NATIVE_CHAR32_T == 1);
646 static ETL_CONSTANT bool has_string_truncation_checks = (ETL_HAS_STRING_TRUNCATION_CHECKS == 1);
647 static ETL_CONSTANT bool has_error_on_string_truncation = (ETL_HAS_ERROR_ON_STRING_TRUNCATION == 1);
648 static ETL_CONSTANT bool has_string_clear_after_use = (ETL_HAS_STRING_CLEAR_AFTER_USE == 1);
649 static ETL_CONSTANT bool has_istring_repair = (ETL_HAS_ISTRING_REPAIR == 1);
650 static ETL_CONSTANT bool has_ivector_repair = (ETL_HAS_IVECTOR_REPAIR == 1);
651 static ETL_CONSTANT bool has_icircular_buffer_repair = (ETL_HAS_ICIRCULAR_BUFFER_REPAIR == 1);
652 static ETL_CONSTANT bool has_mutable_array_view = (ETL_HAS_MUTABLE_ARRAY_VIEW == 1);
653 static ETL_CONSTANT bool has_ideque_repair = (ETL_HAS_IDEQUE_REPAIR == 1);
654 static ETL_CONSTANT bool has_virtual_messages = (ETL_HAS_VIRTUAL_MESSAGES == 1);
655 static ETL_CONSTANT bool has_packed = (ETL_HAS_PACKED == 1);
656 static ETL_CONSTANT bool has_chrono_literals_day = (ETL_HAS_CHRONO_LITERALS_DAY == 1);
657 static ETL_CONSTANT bool has_chrono_literals_year = (ETL_HAS_CHRONO_LITERALS_YEAR == 1);
658 static ETL_CONSTANT bool has_chrono_literals_hours = (ETL_HAS_CHRONO_LITERALS_DURATION == 1);
659 static ETL_CONSTANT bool has_chrono_literals_minutes = (ETL_HAS_CHRONO_LITERALS_DURATION == 1);
660 static ETL_CONSTANT bool has_chrono_literals_seconds = (ETL_HAS_CHRONO_LITERALS_DURATION == 1);
661 static ETL_CONSTANT bool has_chrono_literals_milliseconds = (ETL_HAS_CHRONO_LITERALS_DURATION == 1);
662 static ETL_CONSTANT bool has_chrono_literals_microseconds = (ETL_HAS_CHRONO_LITERALS_DURATION == 1);
663 static ETL_CONSTANT bool has_chrono_literals_nanoseconds = (ETL_HAS_CHRONO_LITERALS_DURATION == 1);
664 static ETL_CONSTANT bool has_std_byteswap = (ETL_HAS_STD_BYTESWAP == 1);
665 static ETL_CONSTANT bool has_noexcept_function_type = (ETL_HAS_NOEXCEPT_FUNCTION_TYPE == 1);
666
667 // Is...
668 static ETL_CONSTANT bool is_debug_build = (ETL_IS_DEBUG_BUILD == 1);
669 }
670}
671
672#endif
bitset_ext
Definition absolute.h:39