From cc418dd08fdfeb7497bec1f4f91b9c51a35ef2d0 Mon Sep 17 00:00:00 2001 From: Heinz-Peter Liechtenecker Date: Fri, 4 Dec 2020 13:45:21 +0100 Subject: [PATCH 1/4] Include new on megaAVR Boards (Arduino Nano Every) (#313) * Change new to new.h * Only include header if ETL supports STL * Adding a flag to define placement new if necessary Co-authored-by: Heinz-Peter Liechtenecker --- include/etl/callback_timer.h | 3 +- include/etl/deque.h | 3 +- include/etl/experimental/variant_new.h | 2 +- include/etl/flat_map.h | 2 +- include/etl/flat_multimap.h | 2 +- include/etl/flat_set.h | 2 +- include/etl/forward_list.h | 2 +- .../etl/generators/message_router_generator.h | 2 +- include/etl/list.h | 2 +- include/etl/map.h | 2 +- include/etl/memory.h | 4 +- include/etl/message_router.h | 2 +- include/etl/multimap.h | 2 +- include/etl/multiset.h | 2 +- include/etl/optional.h | 2 +- include/etl/packet.h | 2 +- include/etl/pool.h | 2 +- include/etl/private/new.h | 48 +++++++++++++++++++ include/etl/queue.h | 2 +- include/etl/queue_mpmc_mutex.h | 2 +- include/etl/queue_spsc_atomic.h | 2 +- include/etl/queue_spsc_isr.h | 2 +- include/etl/queue_spsc_locked.h | 2 +- include/etl/set.h | 2 +- include/etl/stack.h | 2 +- include/etl/unordered_map.h | 2 +- include/etl/unordered_multimap.h | 2 +- include/etl/unordered_multiset.h | 2 +- include/etl/unordered_set.h | 2 +- include/etl/variant.h | 2 +- include/etl/vector.h | 2 +- 31 files changed, 80 insertions(+), 32 deletions(-) create mode 100644 include/etl/private/new.h diff --git a/include/etl/callback_timer.h b/include/etl/callback_timer.h index 7771e880..389da98a 100644 --- a/include/etl/callback_timer.h +++ b/include/etl/callback_timer.h @@ -30,7 +30,8 @@ SOFTWARE. #define ETL_CALLBACK_TIMER_INCLUDED #include -#include + +#include "private/new.h" #include "platform.h" #include "algorithm.h" diff --git a/include/etl/deque.h b/include/etl/deque.h index 75f8d4af..d68f84e7 100644 --- a/include/etl/deque.h +++ b/include/etl/deque.h @@ -34,7 +34,8 @@ SOFTWARE. #include #include -#include +#include "private/new.h" + #include "platform.h" diff --git a/include/etl/experimental/variant_new.h b/include/etl/experimental/variant_new.h index 503aa98d..160969ac 100644 --- a/include/etl/experimental/variant_new.h +++ b/include/etl/experimental/variant_new.h @@ -33,7 +33,7 @@ SOFTWARE. #include -#include +#include "private/new.h" #include "platform.h" #include "utility.h" diff --git a/include/etl/flat_map.h b/include/etl/flat_map.h index b5960133..2e69675f 100644 --- a/include/etl/flat_map.h +++ b/include/etl/flat_map.h @@ -31,7 +31,7 @@ SOFTWARE. #ifndef ETL_FLAT_MAP_INCLUDED #define ETL_FLAT_MAP_INCLUDED -#include +#include "private/new.h" #include "platform.h" #include "reference_flat_map.h" diff --git a/include/etl/flat_multimap.h b/include/etl/flat_multimap.h index e163ec67..0f97f66c 100644 --- a/include/etl/flat_multimap.h +++ b/include/etl/flat_multimap.h @@ -31,7 +31,7 @@ SOFTWARE. #ifndef ETL_FLAT_MULTMAP_INCLUDED #define ETL_FLAT_MULTMAP_INCLUDED -#include +#include "private/new.h" #include "platform.h" #include "reference_flat_multimap.h" diff --git a/include/etl/flat_set.h b/include/etl/flat_set.h index baa19791..baa26301 100644 --- a/include/etl/flat_set.h +++ b/include/etl/flat_set.h @@ -31,7 +31,7 @@ SOFTWARE. #ifndef ETL_FLAT_SET_INCLUDED #define ETL_FLAT_SET_INCLUDED -#include +#include "private/new.h" #include "platform.h" #include "reference_flat_set.h" diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index f1f25eb4..d5754ab3 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -33,7 +33,7 @@ SOFTWARE. #include -#include +#include "private/new.h" #include "platform.h" diff --git a/include/etl/generators/message_router_generator.h b/include/etl/generators/message_router_generator.h index 23eac2b2..93d68119 100644 --- a/include/etl/generators/message_router_generator.h +++ b/include/etl/generators/message_router_generator.h @@ -64,7 +64,7 @@ cog.outl("//******************************************************************** #define ETL_MESSAGE_ROUTER_INCLUDED #include -#include +#include "private/new.h" #include "platform.h" #include "message.h" diff --git a/include/etl/list.h b/include/etl/list.h index d8cb152e..12a9436d 100644 --- a/include/etl/list.h +++ b/include/etl/list.h @@ -33,7 +33,7 @@ SOFTWARE. #include -#include +#include "private/new.h" #include "platform.h" diff --git a/include/etl/map.h b/include/etl/map.h index 0efc2ef6..5cdb6b4d 100755 --- a/include/etl/map.h +++ b/include/etl/map.h @@ -33,7 +33,7 @@ SOFTWARE. #include -#include +#include "private/new.h" #include "platform.h" diff --git a/include/etl/memory.h b/include/etl/memory.h index 3c9f576c..3b5755c0 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -38,13 +38,11 @@ SOFTWARE. #include "utility.h" #include "nullptr.h" #include "alignment.h" +#include "private/new.h" #include - #include -#include - #if ETL_USING_STL #include #endif diff --git a/include/etl/message_router.h b/include/etl/message_router.h index 1f981d0e..fdb34e78 100644 --- a/include/etl/message_router.h +++ b/include/etl/message_router.h @@ -52,7 +52,7 @@ SOFTWARE. #define ETL_MESSAGE_ROUTER_INCLUDED #include -#include +#include "private/new.h" #include "platform.h" #include "message.h" diff --git a/include/etl/multimap.h b/include/etl/multimap.h index 1cde7318..a7270419 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -33,7 +33,7 @@ SOFTWARE. #include -#include +#include "private/new.h" #include "platform.h" diff --git a/include/etl/multiset.h b/include/etl/multiset.h index dd950be1..7f4fb98f 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -33,7 +33,7 @@ SOFTWARE. #include -#include +#include "private/new.h" #include "platform.h" diff --git a/include/etl/optional.h b/include/etl/optional.h index 25b4af0a..c57710c3 100644 --- a/include/etl/optional.h +++ b/include/etl/optional.h @@ -31,7 +31,7 @@ SOFTWARE. #ifndef ETL_OPTIONAL_INCLUDED #define ETL_OPTIONAL_INCLUDED -#include +#include "private/new.h" #include "platform.h" #include "alignment.h" diff --git a/include/etl/packet.h b/include/etl/packet.h index fbaf046b..f728dffc 100644 --- a/include/etl/packet.h +++ b/include/etl/packet.h @@ -31,7 +31,7 @@ SOFTWARE. #ifndef ETL_PACKET_INCLUDED #define ETL_PACKET_INCLUDED -#include +#include "private/new.h" #include "platform.h" #include "static_assert.h" diff --git a/include/etl/pool.h b/include/etl/pool.h index bb17bccb..10da919e 100644 --- a/include/etl/pool.h +++ b/include/etl/pool.h @@ -33,7 +33,7 @@ SOFTWARE. #include "platform.h" -#include +#include "private/new.h" #include "algorithm.h" #include "iterator.h" diff --git a/include/etl/private/new.h b/include/etl/private/new.h new file mode 100644 index 00000000..45dac77b --- /dev/null +++ b/include/etl/private/new.h @@ -0,0 +1,48 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2019 jwellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#ifndef ETL_NEW_INCLUDED +#define ETL_NEW_INCLUDED +///\ingroup private + +#include "../platform.h" + +#ifdef ETL_NO_NEW_HEADER_AVAILABLE +// Define placement new if no new header is available +inline void* operator new(size_t, void* const __p){ return __p; } +inline void* operator new[](size_t, void* const __p){ return __p; } + +inline void operator delete(void*, void* const){ } +inline void operator delete[](void*, void* const){ } +#else +#include +#endif + +#endif diff --git a/include/etl/queue.h b/include/etl/queue.h index 64f8eaff..92ccb594 100644 --- a/include/etl/queue.h +++ b/include/etl/queue.h @@ -34,7 +34,7 @@ SOFTWARE. #include #include -#include +#include "private/new.h" #include "platform.h" #include "container.h" diff --git a/include/etl/queue_mpmc_mutex.h b/include/etl/queue_mpmc_mutex.h index 0270e716..5dd658cb 100644 --- a/include/etl/queue_mpmc_mutex.h +++ b/include/etl/queue_mpmc_mutex.h @@ -34,7 +34,7 @@ SOFTWARE. #include #include -#include +#include "private/new.h" #include "platform.h" #include "mutex.h" diff --git a/include/etl/queue_spsc_atomic.h b/include/etl/queue_spsc_atomic.h index 1aee3f28..9f8d2546 100644 --- a/include/etl/queue_spsc_atomic.h +++ b/include/etl/queue_spsc_atomic.h @@ -34,7 +34,7 @@ SOFTWARE. #include #include -#include +#include "private/new.h" #include "platform.h" #include "alignment.h" diff --git a/include/etl/queue_spsc_isr.h b/include/etl/queue_spsc_isr.h index 0679d433..b423e06b 100644 --- a/include/etl/queue_spsc_isr.h +++ b/include/etl/queue_spsc_isr.h @@ -34,7 +34,7 @@ SOFTWARE. #include #include -#include +#include "private/new.h" #include "platform.h" #include "alignment.h" diff --git a/include/etl/queue_spsc_locked.h b/include/etl/queue_spsc_locked.h index 43b48138..cce172d6 100644 --- a/include/etl/queue_spsc_locked.h +++ b/include/etl/queue_spsc_locked.h @@ -34,7 +34,7 @@ SOFTWARE. #include #include -#include +#include "private/new.h" #include "platform.h" #include "alignment.h" diff --git a/include/etl/set.h b/include/etl/set.h index 63d3debc..2f826c49 100755 --- a/include/etl/set.h +++ b/include/etl/set.h @@ -33,7 +33,7 @@ SOFTWARE. #include -#include +#include "private/new.h" #include "platform.h" #include "container.h" diff --git a/include/etl/stack.h b/include/etl/stack.h index 8c57dbd5..2dd50c34 100644 --- a/include/etl/stack.h +++ b/include/etl/stack.h @@ -34,7 +34,7 @@ SOFTWARE. #include #include -#include +#include "private/new.h" #include "platform.h" #include "algorithm.h" diff --git a/include/etl/unordered_map.h b/include/etl/unordered_map.h index 3d72a0ea..0e7ef7f4 100644 --- a/include/etl/unordered_map.h +++ b/include/etl/unordered_map.h @@ -33,7 +33,7 @@ SOFTWARE. #include -#include +#include "private/new.h" #include "platform.h" #include "algorithm.h" diff --git a/include/etl/unordered_multimap.h b/include/etl/unordered_multimap.h index e029593e..9182fb00 100644 --- a/include/etl/unordered_multimap.h +++ b/include/etl/unordered_multimap.h @@ -33,7 +33,7 @@ SOFTWARE. #include -#include +#include "private/new.h" #include "platform.h" #include "algorithm.h" diff --git a/include/etl/unordered_multiset.h b/include/etl/unordered_multiset.h index df7e5671..34e0eee6 100644 --- a/include/etl/unordered_multiset.h +++ b/include/etl/unordered_multiset.h @@ -33,7 +33,7 @@ SOFTWARE. #include -#include +#include "private/new.h" #include "platform.h" diff --git a/include/etl/unordered_set.h b/include/etl/unordered_set.h index fd5b034e..9b3ae0d0 100644 --- a/include/etl/unordered_set.h +++ b/include/etl/unordered_set.h @@ -33,7 +33,7 @@ SOFTWARE. #include -#include +#include "private/new.h" #include "platform.h" #include "algorithm.h" diff --git a/include/etl/variant.h b/include/etl/variant.h index f0a20158..78ecaafe 100644 --- a/include/etl/variant.h +++ b/include/etl/variant.h @@ -33,7 +33,7 @@ SOFTWARE. #include -#include +#include "private/new.h" #include "platform.h" #include "utility.h" diff --git a/include/etl/vector.h b/include/etl/vector.h index 29f8fd5d..90e237b0 100644 --- a/include/etl/vector.h +++ b/include/etl/vector.h @@ -37,7 +37,7 @@ SOFTWARE. #include #include -#include +#include "private/new.h" #include "platform.h" #include "algorithm.h" From e122383d7db4596726329cb4cdb00b6312d1a2b4 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 6 Dec 2020 14:13:37 +0000 Subject: [PATCH 2/4] Updated for automatic detection of or --- include/etl/callback_timer.h | 3 +- include/etl/deque.h | 6 +-- include/etl/flat_map.h | 3 +- include/etl/flat_multimap.h | 3 +- include/etl/flat_multiset.h | 1 + include/etl/flat_set.h | 3 +- include/etl/forward_list.h | 5 +- .../etl/generators/message_router_generator.h | 2 +- include/etl/list.h | 5 +- include/etl/map.h | 5 +- include/etl/memory.h | 2 +- include/etl/message_router.h | 2 +- include/etl/multimap.h | 5 +- include/etl/multiset.h | 5 +- include/etl/optional.h | 4 +- include/etl/packet.h | 3 +- include/etl/placement_new.h | 48 +++++++++++++++++++ include/etl/platform.h | 13 +++++ include/etl/pool.h | 4 +- include/etl/queue.h | 3 +- include/etl/queue_mpmc_mutex.h | 3 +- include/etl/queue_spsc_atomic.h | 3 +- include/etl/queue_spsc_isr.h | 3 +- include/etl/queue_spsc_locked.h | 3 +- include/etl/set.h | 4 +- include/etl/stack.h | 3 +- include/etl/unordered_map.h | 3 +- include/etl/unordered_multimap.h | 3 +- include/etl/unordered_multiset.h | 5 +- include/etl/unordered_set.h | 3 +- include/etl/variant.h | 3 +- include/etl/vector.h | 3 +- test/runtests.sh | 8 ++-- test/vs2019/etl.vcxproj | 1 + test/vs2019/etl.vcxproj.filters | 3 ++ {include/etl/private => test/vs2019}/new.h | 13 +++-- wslcopy.sh | 1 + 37 files changed, 106 insertions(+), 84 deletions(-) create mode 100644 include/etl/placement_new.h rename {include/etl/private => test/vs2019}/new.h (83%) create mode 100644 wslcopy.sh diff --git a/include/etl/callback_timer.h b/include/etl/callback_timer.h index 389da98a..0e2c43a0 100644 --- a/include/etl/callback_timer.h +++ b/include/etl/callback_timer.h @@ -31,8 +31,6 @@ SOFTWARE. #include -#include "private/new.h" - #include "platform.h" #include "algorithm.h" #include "nullptr.h" @@ -41,6 +39,7 @@ SOFTWARE. #include "timer.h" #include "atomic.h" #include "error_handler.h" +#include "placement_new.h" #if ETL_CPP11_SUPPORTED #include "delegate.h" diff --git a/include/etl/deque.h b/include/etl/deque.h index d68f84e7..72bf84ef 100644 --- a/include/etl/deque.h +++ b/include/etl/deque.h @@ -34,15 +34,10 @@ SOFTWARE. #include #include -#include "private/new.h" - - #include "platform.h" - #include "algorithm.h" #include "iterator.h" #include "utility.h" - #include "container.h" #include "memory.h" #include "exception.h" @@ -51,6 +46,7 @@ SOFTWARE. #include "algorithm.h" #include "type_traits.h" #include "iterator.h" +#include "placement_new.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include diff --git a/include/etl/flat_map.h b/include/etl/flat_map.h index 2e69675f..b6168d89 100644 --- a/include/etl/flat_map.h +++ b/include/etl/flat_map.h @@ -31,11 +31,10 @@ SOFTWARE. #ifndef ETL_FLAT_MAP_INCLUDED #define ETL_FLAT_MAP_INCLUDED -#include "private/new.h" - #include "platform.h" #include "reference_flat_map.h" #include "pool.h" +#include "placement_new.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include diff --git a/include/etl/flat_multimap.h b/include/etl/flat_multimap.h index 0f97f66c..6df8143b 100644 --- a/include/etl/flat_multimap.h +++ b/include/etl/flat_multimap.h @@ -31,12 +31,11 @@ SOFTWARE. #ifndef ETL_FLAT_MULTMAP_INCLUDED #define ETL_FLAT_MULTMAP_INCLUDED -#include "private/new.h" - #include "platform.h" #include "reference_flat_multimap.h" #include "pool.h" #include "utility.h" +#include "placement_new.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include diff --git a/include/etl/flat_multiset.h b/include/etl/flat_multiset.h index 2e3ce7ae..496cf843 100644 --- a/include/etl/flat_multiset.h +++ b/include/etl/flat_multiset.h @@ -34,6 +34,7 @@ SOFTWARE. #include "platform.h" #include "reference_flat_multiset.h" #include "pool.h" +#include "placement_new.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include diff --git a/include/etl/flat_set.h b/include/etl/flat_set.h index baa26301..c4d5c7c9 100644 --- a/include/etl/flat_set.h +++ b/include/etl/flat_set.h @@ -31,11 +31,10 @@ SOFTWARE. #ifndef ETL_FLAT_SET_INCLUDED #define ETL_FLAT_SET_INCLUDED -#include "private/new.h" - #include "platform.h" #include "reference_flat_set.h" #include "pool.h" +#include "placement_new.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index d5754ab3..a870aba6 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -33,15 +33,11 @@ SOFTWARE. #include -#include "private/new.h" - #include "platform.h" - #include "algorithm.h" #include "iterator.h" #include "functional.h" #include "utility.h" - #include "pool.h" #include "container.h" #include "exception.h" @@ -52,6 +48,7 @@ SOFTWARE. #include "memory.h" #include "iterator.h" #include "static_assert.h" +#include "placement_new.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include diff --git a/include/etl/generators/message_router_generator.h b/include/etl/generators/message_router_generator.h index 93d68119..aa4b208b 100644 --- a/include/etl/generators/message_router_generator.h +++ b/include/etl/generators/message_router_generator.h @@ -64,7 +64,6 @@ cog.outl("//******************************************************************** #define ETL_MESSAGE_ROUTER_INCLUDED #include -#include "private/new.h" #include "platform.h" #include "message.h" @@ -75,6 +74,7 @@ cog.outl("//******************************************************************** #include "exception.h" #include "largest.h" #include "nullptr.h" +#include "placement_new.h" #undef ETL_FILE #define ETL_FILE "35" diff --git a/include/etl/list.h b/include/etl/list.h index 12a9436d..7c472738 100644 --- a/include/etl/list.h +++ b/include/etl/list.h @@ -33,14 +33,10 @@ SOFTWARE. #include -#include "private/new.h" - #include "platform.h" - #include "algorithm.h" #include "iterator.h" #include "functional.h" - #include "container.h" #include "pool.h" #include "exception.h" @@ -52,6 +48,7 @@ SOFTWARE. #include "memory.h" #include "iterator.h" #include "static_assert.h" +#include "placement_new.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include diff --git a/include/etl/map.h b/include/etl/map.h index 5cdb6b4d..49663818 100755 --- a/include/etl/map.h +++ b/include/etl/map.h @@ -33,14 +33,10 @@ SOFTWARE. #include -#include "private/new.h" - #include "platform.h" - #include "algorithm.h" #include "iterator.h" #include "functional.h" - #include "container.h" #include "pool.h" #include "exception.h" @@ -51,6 +47,7 @@ SOFTWARE. #include "parameter_type.h" #include "iterator.h" #include "utility.h" +#include "placement_new.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include diff --git a/include/etl/memory.h b/include/etl/memory.h index 3b5755c0..474cd449 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -38,7 +38,7 @@ SOFTWARE. #include "utility.h" #include "nullptr.h" #include "alignment.h" -#include "private/new.h" +#include "placement_new.h" #include #include diff --git a/include/etl/message_router.h b/include/etl/message_router.h index fdb34e78..c5b7ec1e 100644 --- a/include/etl/message_router.h +++ b/include/etl/message_router.h @@ -52,7 +52,6 @@ SOFTWARE. #define ETL_MESSAGE_ROUTER_INCLUDED #include -#include "private/new.h" #include "platform.h" #include "message.h" @@ -63,6 +62,7 @@ SOFTWARE. #include "exception.h" #include "largest.h" #include "nullptr.h" +#include "placement_new.h" #undef ETL_FILE #define ETL_FILE "35" diff --git a/include/etl/multimap.h b/include/etl/multimap.h index a7270419..81e323db 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -33,14 +33,10 @@ SOFTWARE. #include -#include "private/new.h" - #include "platform.h" - #include "algorithm.h" #include "iterator.h" #include "functional.h" - #include "container.h" #include "pool.h" #include "exception.h" @@ -51,6 +47,7 @@ SOFTWARE. #include "parameter_type.h" #include "iterator.h" #include "utility.h" +#include "placement_new.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include diff --git a/include/etl/multiset.h b/include/etl/multiset.h index 7f4fb98f..16b9d7cc 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -33,14 +33,10 @@ SOFTWARE. #include -#include "private/new.h" - #include "platform.h" - #include "algorithm.h" #include "iterator.h" #include "functional.h" - #include "parameter_type.h" #include "container.h" #include "pool.h" @@ -50,6 +46,7 @@ SOFTWARE. #include "nullptr.h" #include "type_traits.h" #include "utility.h" +#include "placement_new.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include diff --git a/include/etl/optional.h b/include/etl/optional.h index c57710c3..5ea0cd7b 100644 --- a/include/etl/optional.h +++ b/include/etl/optional.h @@ -31,15 +31,13 @@ SOFTWARE. #ifndef ETL_OPTIONAL_INCLUDED #define ETL_OPTIONAL_INCLUDED -#include "private/new.h" - #include "platform.h" #include "alignment.h" #include "type_traits.h" #include "exception.h" #include "error_handler.h" - #include "utility.h" +#include "placement_new.h" namespace etl { diff --git a/include/etl/packet.h b/include/etl/packet.h index f728dffc..5802ec35 100644 --- a/include/etl/packet.h +++ b/include/etl/packet.h @@ -31,12 +31,11 @@ SOFTWARE. #ifndef ETL_PACKET_INCLUDED #define ETL_PACKET_INCLUDED -#include "private/new.h" - #include "platform.h" #include "static_assert.h" #include "alignment.h" #include "utility.h" +#include "placement_new.h" #undef ETL_FILE #define ETL_FILE "38" diff --git a/include/etl/placement_new.h b/include/etl/placement_new.h new file mode 100644 index 00000000..15f5533f --- /dev/null +++ b/include/etl/placement_new.h @@ -0,0 +1,48 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2019 jwellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#ifndef ETL_NEW_INCLUDED +#define ETL_NEW_INCLUDED +///\ingroup private + +#include "platform.h" + +#if ETL_USING_STD_NEW + #include +#else +// Define placement new if no new header is available +inline void* operator new(size_t, void* p) { return p; } +inline void* operator new[](size_t, void* p) { return p; } + +inline void operator delete(void*, void*) ETL_NOEXCEPT {} +inline void operator delete[](void*, void*) ETL_NOEXCEPT {} +#endif + +#endif diff --git a/include/etl/platform.h b/include/etl/platform.h index ac20d4a8..58156e19 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -102,6 +102,19 @@ SOFTWARE. // See if we can determine the OS we're compiling on, if haven't already done so in etl_profile.h #include "profiles/determine_development_os.h" +#include + +// Figure out if we can use the standard library header, if haven't already done so in etl_profile.h +#if !defined(ETL_USING_STD_NEW) + #if defined(__has_include) + #define ETL_USING_STD_NEW (__has_include() || __has_include()) + #elif ETL_NOT_USING_STL || (defined(ARDUINO) && defined(__AVR__)) + #define ETL_USING_STD_NEW 0 + #else + #define ETL_USING_STD_NEW 1 + #endif +#endif + // Option to force string construction from a character pointer to be explicit. #if defined(ETL_FORCE_EXPLICIT_STRING_CONVERSION_FROM_CHAR) #define ETL_EXPLICIT_STRING_FROM_CHAR explicit diff --git a/include/etl/pool.h b/include/etl/pool.h index 10da919e..5c7b83c1 100644 --- a/include/etl/pool.h +++ b/include/etl/pool.h @@ -32,9 +32,6 @@ SOFTWARE. #define ETL_POOL_INCLUDED #include "platform.h" - -#include "private/new.h" - #include "algorithm.h" #include "iterator.h" #include "utility.h" @@ -47,6 +44,7 @@ SOFTWARE. #include "alignment.h" #include "static_assert.h" #include "algorithm.h" +#include "placement_new.h" #undef ETL_FILE #define ETL_FILE "11" diff --git a/include/etl/queue.h b/include/etl/queue.h index 92ccb594..e2760418 100644 --- a/include/etl/queue.h +++ b/include/etl/queue.h @@ -34,8 +34,6 @@ SOFTWARE. #include #include -#include "private/new.h" - #include "platform.h" #include "container.h" #include "alignment.h" @@ -48,6 +46,7 @@ SOFTWARE. #include "memory_model.h" #include "integral_limits.h" #include "utility.h" +#include "placement_new.h" #undef ETL_FILE #define ETL_FILE "13" diff --git a/include/etl/queue_mpmc_mutex.h b/include/etl/queue_mpmc_mutex.h index 5dd658cb..5b422351 100644 --- a/include/etl/queue_mpmc_mutex.h +++ b/include/etl/queue_mpmc_mutex.h @@ -34,8 +34,6 @@ SOFTWARE. #include #include -#include "private/new.h" - #include "platform.h" #include "mutex.h" @@ -46,6 +44,7 @@ SOFTWARE. #include "memory_model.h" #include "integral_limits.h" #include "utility.h" +#include "placement_new.h" #undef ETL_FILE #define ETL_FILE "48" diff --git a/include/etl/queue_spsc_atomic.h b/include/etl/queue_spsc_atomic.h index 9f8d2546..7acbfa47 100644 --- a/include/etl/queue_spsc_atomic.h +++ b/include/etl/queue_spsc_atomic.h @@ -34,8 +34,6 @@ SOFTWARE. #include #include -#include "private/new.h" - #include "platform.h" #include "alignment.h" #include "parameter_type.h" @@ -43,6 +41,7 @@ SOFTWARE. #include "memory_model.h" #include "integral_limits.h" #include "utility.h" +#include "placement_new.h" #undef ETL_FILE #define ETL_FILE "47" diff --git a/include/etl/queue_spsc_isr.h b/include/etl/queue_spsc_isr.h index b423e06b..6da073d5 100644 --- a/include/etl/queue_spsc_isr.h +++ b/include/etl/queue_spsc_isr.h @@ -34,14 +34,13 @@ SOFTWARE. #include #include -#include "private/new.h" - #include "platform.h" #include "alignment.h" #include "parameter_type.h" #include "memory_model.h" #include "integral_limits.h" #include "utility.h" +#include "placement_new.h" #undef ETL_FILE #define ETL_FILE "46" diff --git a/include/etl/queue_spsc_locked.h b/include/etl/queue_spsc_locked.h index cce172d6..e4e4bdb1 100644 --- a/include/etl/queue_spsc_locked.h +++ b/include/etl/queue_spsc_locked.h @@ -34,8 +34,6 @@ SOFTWARE. #include #include -#include "private/new.h" - #include "platform.h" #include "alignment.h" #include "parameter_type.h" @@ -43,6 +41,7 @@ SOFTWARE. #include "integral_limits.h" #include "function.h" #include "utility.h" +#include "placement_new.h" #undef ETL_FILE #define ETL_FILE "54" diff --git a/include/etl/set.h b/include/etl/set.h index 2f826c49..f6e1699c 100755 --- a/include/etl/set.h +++ b/include/etl/set.h @@ -33,8 +33,6 @@ SOFTWARE. #include -#include "private/new.h" - #include "platform.h" #include "container.h" #include "pool.h" @@ -46,10 +44,10 @@ SOFTWARE. #include "parameter_type.h" #include "iterator.h" #include "utility.h" - #include "algorithm.h" #include "iterator.h" #include "functional.h" +#include "placement_new.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include diff --git a/include/etl/stack.h b/include/etl/stack.h index 2dd50c34..cd80d921 100644 --- a/include/etl/stack.h +++ b/include/etl/stack.h @@ -34,8 +34,6 @@ SOFTWARE. #include #include -#include "private/new.h" - #include "platform.h" #include "algorithm.h" #include "utility.h" @@ -46,6 +44,7 @@ SOFTWARE. #include "error_handler.h" #include "debug_count.h" #include "type_traits.h" +#include "placement_new.h" #undef ETL_FILE #define ETL_FILE "15" diff --git a/include/etl/unordered_map.h b/include/etl/unordered_map.h index 0e7ef7f4..ad4ef776 100644 --- a/include/etl/unordered_map.h +++ b/include/etl/unordered_map.h @@ -33,8 +33,6 @@ SOFTWARE. #include -#include "private/new.h" - #include "platform.h" #include "algorithm.h" #include "iterator.h" @@ -53,6 +51,7 @@ SOFTWARE. #include "exception.h" #include "debug_count.h" #include "iterator.h" +#include "placement_new.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include diff --git a/include/etl/unordered_multimap.h b/include/etl/unordered_multimap.h index 9182fb00..c7b5d63a 100644 --- a/include/etl/unordered_multimap.h +++ b/include/etl/unordered_multimap.h @@ -33,8 +33,6 @@ SOFTWARE. #include -#include "private/new.h" - #include "platform.h" #include "algorithm.h" #include "iterator.h" @@ -53,6 +51,7 @@ SOFTWARE. #include "exception.h" #include "debug_count.h" #include "iterator.h" +#include "placement_new.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include diff --git a/include/etl/unordered_multiset.h b/include/etl/unordered_multiset.h index 34e0eee6..a36ed6bc 100644 --- a/include/etl/unordered_multiset.h +++ b/include/etl/unordered_multiset.h @@ -33,15 +33,11 @@ SOFTWARE. #include -#include "private/new.h" - #include "platform.h" - #include "algorithm.h" #include "iterator.h" #include "functional.h" #include "utility.h" - #include "container.h" #include "pool.h" #include "vector.h" @@ -54,6 +50,7 @@ SOFTWARE. #include "exception.h" #include "debug_count.h" #include "iterator.h" +#include "placement_new.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include diff --git a/include/etl/unordered_set.h b/include/etl/unordered_set.h index 9b3ae0d0..b69d801f 100644 --- a/include/etl/unordered_set.h +++ b/include/etl/unordered_set.h @@ -33,8 +33,6 @@ SOFTWARE. #include -#include "private/new.h" - #include "platform.h" #include "algorithm.h" #include "iterator.h" @@ -53,6 +51,7 @@ SOFTWARE. #include "error_handler.h" #include "debug_count.h" #include "iterator.h" +#include "placement_new.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include diff --git a/include/etl/variant.h b/include/etl/variant.h index 78ecaafe..7bfea8eb 100644 --- a/include/etl/variant.h +++ b/include/etl/variant.h @@ -33,8 +33,6 @@ SOFTWARE. #include -#include "private/new.h" - #include "platform.h" #include "utility.h" #include "array.h" @@ -46,6 +44,7 @@ SOFTWARE. #include "alignment.h" #include "error_handler.h" #include "null_type.h" +#include "placement_new.h" #if defined(ETL_COMPILER_KEIL) #pragma diag_suppress 940 diff --git a/include/etl/vector.h b/include/etl/vector.h index 90e237b0..dd2caea1 100644 --- a/include/etl/vector.h +++ b/include/etl/vector.h @@ -37,8 +37,6 @@ SOFTWARE. #include #include -#include "private/new.h" - #include "platform.h" #include "algorithm.h" #include "type_traits.h" @@ -53,6 +51,7 @@ SOFTWARE. #include "iterator.h" #include "functional.h" #include "static_assert.h" +#include "placement_new.h" #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL #include diff --git a/test/runtests.sh b/test/runtests.sh index a4a06e0b..6265495e 100644 --- a/test/runtests.sh +++ b/test/runtests.sh @@ -5,23 +5,23 @@ echo "********** GCC **********" >> etl_test_log.txt gcc --version | grep gcc >> etl_test_log.txt cmake --cmake-clean-cache -DNO_STL=OFF .. make -./etl_tests >> etl_test_log.txt +./etl_tests | tee etl_test_log.txt echo "********** GCC - No STL **********" >> etl_test_log.txt gcc --version | grep gcc >> etl_test_log.txt cmake --cmake-clean-cache -DNO_STL=ON .. make -./etl_tests >> etl_test_log.txt +./etl_tests | tee etl_test_log.txt echo "********** Clang **********" >> etl_test_log.txt clang --version | grep clang >> etl_test_log.txt export CC=clang export CXX=clang++ cmake --cmake-clean-cache -DNO_STL=OFF .. make -./etl_tests >> etl_test_log.txt +./etl_tests | tee etl_test_log.txt echo "********** Clang - No STL **********" >> etl_test_log.txt clang --version | grep clang >> etl_test_log.txt export CC=clang export CXX=clang++ cmake --cmake-clean-cache -DNO_STL=ON .. make -./etl_tests >> etl_test_log.txt +./etl_tests | tee etl_test_log.txt diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 7fae2640..d1736446 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -1293,6 +1293,7 @@ + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 2c69e527..36753b17 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -894,6 +894,9 @@ ETL\Containers + + ETL\Utilities + diff --git a/include/etl/private/new.h b/test/vs2019/new.h similarity index 83% rename from include/etl/private/new.h rename to test/vs2019/new.h index 45dac77b..d9161320 100644 --- a/include/etl/private/new.h +++ b/test/vs2019/new.h @@ -30,19 +30,18 @@ SOFTWARE. #ifndef ETL_NEW_INCLUDED #define ETL_NEW_INCLUDED -///\ingroup private -#include "../platform.h" +#include "platform.h" #ifdef ETL_NO_NEW_HEADER_AVAILABLE // Define placement new if no new header is available -inline void* operator new(size_t, void* const __p){ return __p; } -inline void* operator new[](size_t, void* const __p){ return __p; } +inline void* operator new(size_t, void* const __p) { return __p; } +inline void* operator new[](size_t, void* const __p) { return __p; } -inline void operator delete(void*, void* const){ } -inline void operator delete[](void*, void* const){ } +inline void operator delete(void*, void* const) { } +inline void operator delete[](void*, void* const) {} #else -#include + #include #endif #endif diff --git a/wslcopy.sh b/wslcopy.sh new file mode 100644 index 00000000..6d61fc3b --- /dev/null +++ b/wslcopy.sh @@ -0,0 +1 @@ + rsync -av --progress . /home/ubuntu/ --exclude etl/examples --exclude test/vs2019 --exclude test/vs2017 --exclude test/codeblocks From 8cf7ab2974cbcf296887a5f1253117728cfe57a6 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 8 Dec 2020 11:39:26 +0000 Subject: [PATCH 3/4] Updated generators --- include/etl/fsm.h | 10 ++--- include/etl/generators/fsm_generator.h | 8 ++-- include/etl/generators/largest_generator.h | 38 ++++++++++++++++ include/etl/generators/smallest_generator.h | 43 ++++++++++++++++--- .../etl/generators/type_lookup_generator.h | 8 +++- .../etl/generators/type_select_generator.h | 6 ++- .../etl/generators/type_traits_generator.h | 8 +++- include/etl/platform.h | 4 +- include/etl/smallest.h | 6 +-- include/etl/type_traits.h | 2 +- include/etl/version.h | 2 +- library.json | 2 +- library.properties | 2 +- support/Release notes.txt | 5 +++ 14 files changed, 114 insertions(+), 30 deletions(-) diff --git a/include/etl/fsm.h b/include/etl/fsm.h index e97f541a..15bb636e 100644 --- a/include/etl/fsm.h +++ b/include/etl/fsm.h @@ -235,7 +235,7 @@ namespace etl template void set_states(etl::ifsm_state** p_states, TSize size) { - state_list = p_states; + state_list = p_states; number_of_states = etl::fsm_state_id_t(size); ETL_ASSERT(number_of_states > 0, ETL_ERROR(etl::fsm_state_list_exception)); @@ -281,7 +281,7 @@ namespace etl //******************************************* /// Top level message handler for the FSM. //******************************************* - void receive(const etl::imessage& message) + void receive(const etl::imessage& message) ETL_OVERRIDE { static etl::null_message_router nmr; receive(nmr, message); @@ -290,7 +290,7 @@ namespace etl //******************************************* /// Top level message handler for the FSM. //******************************************* - void receive(imessage_router& source, etl::message_router_id_t destination_router_id, const etl::imessage& message) + void receive(imessage_router& source, etl::message_router_id_t destination_router_id, const etl::imessage& message) ETL_OVERRIDE { if ((destination_router_id == get_message_router_id()) || (destination_router_id == imessage_router::ALL_MESSAGE_ROUTERS)) { @@ -301,7 +301,7 @@ namespace etl //******************************************* /// Top level message handler for the FSM. //******************************************* - void receive(etl::imessage_router& source, const etl::imessage& message) + void receive(etl::imessage_router& source, const etl::imessage& message) ETL_OVERRIDE { etl::fsm_state_id_t next_state_id = p_state->process_event(source, message); ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception)); @@ -331,7 +331,7 @@ namespace etl /// Does this FSM accept the message id? /// Yes, it accepts everything! //******************************************* - bool accepts(etl::message_id_t) const + bool accepts(etl::message_id_t) const ETL_OVERRIDE { return true; } diff --git a/include/etl/generators/fsm_generator.h b/include/etl/generators/fsm_generator.h index 8e5eeff8..7aa987b9 100644 --- a/include/etl/generators/fsm_generator.h +++ b/include/etl/generators/fsm_generator.h @@ -293,7 +293,7 @@ namespace etl //******************************************* /// Top level message handler for the FSM. //******************************************* - void receive(const etl::imessage& message) + void receive(const etl::imessage& message) ETL_OVERRIDE { static etl::null_message_router nmr; receive(nmr, message); @@ -302,7 +302,7 @@ namespace etl //******************************************* /// Top level message handler for the FSM. //******************************************* - void receive(imessage_router& source, etl::message_router_id_t destination_router_id, const etl::imessage& message) + void receive(imessage_router& source, etl::message_router_id_t destination_router_id, const etl::imessage& message) ETL_OVERRIDE { if ((destination_router_id == get_message_router_id()) || (destination_router_id == imessage_router::ALL_MESSAGE_ROUTERS)) { @@ -313,7 +313,7 @@ namespace etl //******************************************* /// Top level message handler for the FSM. //******************************************* - void receive(etl::imessage_router& source, const etl::imessage& message) + void receive(etl::imessage_router& source, const etl::imessage& message) ETL_OVERRIDE { etl::fsm_state_id_t next_state_id = p_state->process_event(source, message); ETL_ASSERT(next_state_id < number_of_states, ETL_ERROR(etl::fsm_state_id_exception)); @@ -343,7 +343,7 @@ namespace etl /// Does this FSM accept the message id? /// Yes, it accepts everything! //******************************************* - bool accepts(etl::message_id_t) const + bool accepts(etl::message_id_t) const ETL_OVERRIDE { return true; } diff --git a/include/etl/generators/largest_generator.h b/include/etl/generators/largest_generator.h index dfd05dd7..c95a7d5e 100644 --- a/include/etl/generators/largest_generator.h +++ b/include/etl/generators/largest_generator.h @@ -121,6 +121,17 @@ namespace etl size = etl::size_of::value }; }; + +#if ETL_CPP14_SUPPORTED + template + using largest_type_t = typename largest_type::type; +#endif + +#if ETL_CPP17_SUPPORTED + template + constexpr size_t largest_type_v = largest_type::size; +#endif + #else /*[[[cog import cog @@ -225,6 +236,12 @@ namespace etl value = etl::alignment_of::value }; }; + +#if ETL_CPP17_SUPPORTED + template + inline constexpr size_t largest_alignment_v = largest_alignment::value; +#endif + #else /*[[[cog import cog @@ -302,6 +319,11 @@ namespace etl typedef typename etl::smallest_int_for_bits::type>::bits + 1>::type type; }; +#if ETL_CPP14_SUPPORTED + template + using larger_int_type_t = typename larger_int_type::type; +#endif + //*************************************************************************** /// Defines a type that is as larger or larger than the specified type. /// Will return the specified type is there is not a larger type. @@ -315,6 +337,11 @@ namespace etl typedef typename etl::smallest_uint_for_bits::type>::bits + 1>::type type; }; +#if ETL_CPP14_SUPPORTED + template + using larger_uint_type_t = typename larger_uint_type::type; +#endif + //*************************************************************************** /// Defines a type that is as larger or larger than the specified type. /// Will return the specified type is there is not a larger type. @@ -340,6 +367,11 @@ namespace etl typedef typename etl::smallest_int_for_bits::bits + 1>::type type; }; +#if ETL_CPP14_SUPPORTED + template + using larger_type_t = typename larger_type::type; +#endif + #if ETL_CPP11_SUPPORTED && !defined(ETL_LARGEST_FORCE_CPP03) //*************************************************************************** /// Template to determine the largest type, size and alignment. @@ -357,6 +389,12 @@ namespace etl alignment = etl::largest_alignment::value }; }; + +#if ETL_CPP14_SUPPORTED + template + using largest_t = typename largest::type; +#endif + #else /*[[[cog import cog diff --git a/include/etl/generators/smallest_generator.h b/include/etl/generators/smallest_generator.h index 6290b65d..71b62846 100644 --- a/include/etl/generators/smallest_generator.h +++ b/include/etl/generators/smallest_generator.h @@ -121,6 +121,17 @@ namespace etl size = etl::size_of::value }; }; + +#if ETL_CPP14_SUPPORTED + template + using smallest_type_t = typename smallest_type::type; +#endif + +#if ETL_CPP17_SUPPORTED + template + constexpr size_t smallest_type_v = smallest_type::size; +#endif + #else /*[[[cog import cog @@ -303,7 +314,7 @@ namespace etl /// Defines 'type' which is the type of the smallest unsigned integer. ///\ingroup smallest //*************************************************************************** - template + template struct smallest_uint_for_bits { private: @@ -318,13 +329,18 @@ namespace etl typedef typename private_smallest::best_fit_uint_type::type type; }; +#if ETL_CPP14_SUPPORTED + template + using smallest_uint_for_bits_t = typename smallest_uint_for_bits::type; +#endif + //*************************************************************************** /// Template to determine the smallest signed int type that can contain a /// value with the specified number of bits. /// Defines 'type' which is the type of the smallest signed integer. ///\ingroup smallest //*************************************************************************** - template + template struct smallest_int_for_bits { private: @@ -339,13 +355,18 @@ namespace etl typedef typename private_smallest::best_fit_int_type::type type; }; +#if ETL_CPP14_SUPPORTED + template + using smallest_int_for_bits_t = typename smallest_int_for_bits::type; +#endif + //*************************************************************************** /// Template to determine the smallest unsigned int type that can contain the /// specified unsigned value. /// Defines 'type' which is the type of the smallest unsigned integer. ///\ingroup smallest //*************************************************************************** - template + template struct smallest_uint_for_value { private: @@ -360,6 +381,11 @@ namespace etl typedef typename private_smallest::best_fit_uint_type::type type; }; +#if ETL_CPP14_SUPPORTED + template + using smallest_uint_for_value_t = typename smallest_uint_for_value::type; +#endif + //*************************************************************************** /// Template to determine the smallest int type that can contain the /// specified signed value. @@ -372,14 +398,19 @@ namespace etl private: // Determines the index of the best signed type for the required value. - static const int TYPE_INDEX = (((VALUE > INT_LEAST8_MAX) || (VALUE < INT_LEAST8_MIN)) ? 1 : 0) + - (((VALUE > INT16_MAX) || (VALUE < INT16_MIN)) ? 1 : 0) + - (((VALUE > INT32_MAX) || (VALUE < INT32_MIN)) ? 1 : 0); + static const int TYPE_INDEX = (((VALUE > intmax_t(INT_LEAST8_MAX)) || (VALUE < intmax_t(INT_LEAST8_MIN))) ? 1 : 0) + + (((VALUE > intmax_t(INT16_MAX)) || (VALUE < intmax_t(INT16_MIN))) ? 1 : 0) + + (((VALUE > intmax_t(INT32_MAX)) || (VALUE < intmax_t(INT32_MIN))) ? 1 : 0); public: typedef typename private_smallest::best_fit_int_type::type type; }; + +#if ETL_CPP14_SUPPORTED + template + using smallest_int_for_value_t = typename smallest_int_for_value::type; +#endif } #endif diff --git a/include/etl/generators/type_lookup_generator.h b/include/etl/generators/type_lookup_generator.h index 845d2816..a16564d3 100644 --- a/include/etl/generators/type_lookup_generator.h +++ b/include/etl/generators/type_lookup_generator.h @@ -129,8 +129,10 @@ namespace etl static_assert(!(etl::is_same::value), "Invalid id"); }; +#if ETL_CPP14_SUPPORTED template using type_from_id_t = typename type_from_id::type; +#endif private: @@ -165,7 +167,7 @@ namespace etl #if ETL_CPP17_SUPPORTED template - static constexpr size_t id_from_type_v = id_from_type::value; + static constexpr size_t id_from_type_v = id_from_type::value; #endif //************************************ @@ -223,9 +225,11 @@ namespace etl static_assert(!etl::is_same::value, "Type match not found"); }; +#if ETL_CPP14_SUPPORTED // Template alias. template - using TypeFromType_t = typename type_from_type::type; + using type_from_type_t = typename type_from_type::type; +#endif }; #else diff --git a/include/etl/generators/type_select_generator.h b/include/etl/generators/type_select_generator.h index 17dd4a00..4add070c 100644 --- a/include/etl/generators/type_select_generator.h +++ b/include/etl/generators/type_select_generator.h @@ -73,8 +73,8 @@ namespace etl struct type_select_helper { using type = typename etl::conditional::type>::type; + T1, + typename type_select_helper::type>::type; }; //*********************************** @@ -94,8 +94,10 @@ namespace etl using type = typename type_select_helper::type; }; +#if ETL_CPP14_SUPPORTED template using select_t = typename select::type; +#endif }; #else diff --git a/include/etl/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index 200e267a..6377889a 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -1088,7 +1088,13 @@ namespace etl inline constexpr bool is_pod_v = std::is_standard_layout_v && std::is_trivial_v; #endif -#if !defined(ARDUINO) && ETL_NOT_USING_STLPORT && !(defined(ETL_COMPILER_GCC) && ETL_COMPILER_VERSION < 5) +#if defined(ETL_COMPILER_GCC) + #if ETL_COMPILER_VERSION >= 5 + #define ETL_GCC_V5_TYPE_TRAITS_SUPPORTED + #endif +#endif + +#if !defined(ARDUINO) && ETL_NOT_USING_STLPORT && defined(ETL_GCC_V5_TYPE_TRAITS_SUPPORTED) //*************************************************************************** /// is_trivially_constructible ///\ingroup type_traits diff --git a/include/etl/platform.h b/include/etl/platform.h index 58156e19..3912aa68 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -102,12 +102,10 @@ SOFTWARE. // See if we can determine the OS we're compiling on, if haven't already done so in etl_profile.h #include "profiles/determine_development_os.h" -#include - // Figure out if we can use the standard library header, if haven't already done so in etl_profile.h #if !defined(ETL_USING_STD_NEW) #if defined(__has_include) - #define ETL_USING_STD_NEW (__has_include() || __has_include()) + #define ETL_USING_STD_NEW __has_include() #elif ETL_NOT_USING_STL || (defined(ARDUINO) && defined(__AVR__)) #define ETL_USING_STD_NEW 0 #else diff --git a/include/etl/smallest.h b/include/etl/smallest.h index 540765e7..d6e23c2d 100644 --- a/include/etl/smallest.h +++ b/include/etl/smallest.h @@ -368,9 +368,9 @@ namespace etl private: // Determines the index of the best signed type for the required value. - static const int TYPE_INDEX = (((VALUE > intmax_t(INT_LEAST8_MAX)) || (VALUE < intmax_t(INT_LEAST8_MIN))) ? 1 : 0) + - (((VALUE > intmax_t(INT16_MAX)) || (VALUE < intmax_t(INT16_MIN))) ? 1 : 0) + - (((VALUE > intmax_t(INT32_MAX)) || (VALUE < intmax_t(INT32_MIN))) ? 1 : 0); + static const int TYPE_INDEX = (((VALUE > intmax_t(INT_LEAST8_MAX)) || (VALUE < intmax_t(INT_LEAST8_MIN))) ? 1 : 0) + + (((VALUE > intmax_t(INT16_MAX)) || (VALUE < intmax_t(INT16_MIN))) ? 1 : 0) + + (((VALUE > intmax_t(INT32_MAX)) || (VALUE < intmax_t(INT32_MIN))) ? 1 : 0); public: diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index 69c56577..3112b967 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -758,7 +758,7 @@ namespace etl /// These require compiler specific intrinsics. #if ETL_CPP11_SUPPORTED && !defined(ETL_COMPILER_ARM5) template struct alignment_of : integral_constant { }; -#elif ETL_COMPILER_MICROSOFT +#elif defined(ETL_COMPILER_MICROSOFT) template struct alignment_of : integral_constant {}; #elif defined(ETL_COMPILER_IAR) || defined(ETL_COMPILER_TI) template struct alignment_of : integral_constant {}; diff --git a/include/etl/version.h b/include/etl/version.h index fc27b601..321a42f5 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -39,7 +39,7 @@ SOFTWARE. #define ETL_VERSION_MAJOR 19 #define ETL_VERSION_MINOR 3 -#define ETL_VERSION_PATCH 1 +#define ETL_VERSION_PATCH 2 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_U16 ETL_STRINGIFY(ETL_VERSION_MAJOR) u"." ETL_STRINGIFY(ETL_VERSION_MINOR) u"." ETL_STRINGIFY(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index d9f410cf..df8ea384 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library", - "version": "19.3.1", + "version": "19.3.2", "author s": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 391e5a89..e71da2f9 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=19.3.1 +version=19.3.2 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index ff8dd86f..069de68a 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,8 @@ +=============================================================================== +19.3.2 +Added check for existance of in platform.h +Added placement_new.h which selects between and ETL definitions. + =============================================================================== 19.3.1 Fixed etl::format_spec constexpr compatibility with C++11. From 41dbae73b27000598290d9def3a866443a3a72f6 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 8 Dec 2020 12:11:54 +0000 Subject: [PATCH 4/4] Updated generators --- support/Release notes.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/support/Release notes.txt b/support/Release notes.txt index 069de68a..f5904761 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,8 +1,11 @@ =============================================================================== -19.3.2 +19.3.3 Added check for existance of in platform.h Added placement_new.h which selects between and ETL definitions. +=============================================================================== +19.3.2 + =============================================================================== 19.3.1 Fixed etl::format_spec constexpr compatibility with C++11.