From ea9a1e51c9d1cddcbae353b0287f0c80bc780dd7 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 16 Apr 2018 19:17:41 +0100 Subject: [PATCH 01/14] More efficient implementations of sign_extend --- include/etl/binary.h | 56 ++++++++++++++------------------------------ 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/include/etl/binary.h b/include/etl/binary.h index df7f73b9..7a363d1c 100644 --- a/include/etl/binary.h +++ b/include/etl/binary.h @@ -270,16 +270,12 @@ namespace etl STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); STATIC_ASSERT(NBITS <= std::numeric_limits::digits, "NBITS too large for return type"); - const TReturn negative = (TReturn(1) << (NBITS - 1)); - TReturn signed_value = value & ((1 << NBITS) - 1); - - if ((signed_value & negative) != 0) + struct S { - const TReturn sign_bits = ~((TReturn(1) << NBITS) - 1); - signed_value |= sign_bits; - } + signed value : NBITS; + } s; - return signed_value; + return (s.value = value); } //*************************************************************************** @@ -290,22 +286,18 @@ namespace etl template TReturn sign_extend(TValue value) { - STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); + STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); STATIC_ASSERT(etl::is_integral::value, "TReturn not an integral type"); - STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); + STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); STATIC_ASSERT(NBITS <= std::numeric_limits::digits, "NBITS too large for return type"); STATIC_ASSERT(SHIFT <= std::numeric_limits::digits, "SHIFT too large"); - const TReturn negative = (TReturn(1) << (NBITS - 1)); - TReturn signed_value = (value >> SHIFT) & ((1 << NBITS) - 1); - - if ((signed_value & negative) != 0) + struct S { - const TReturn sign_bits = ~((TReturn(1) << NBITS) - 1); - signed_value |= sign_bits; - } + signed value : NBITS; + } s; - return signed_value; + return (s.value = (value >> SHIFT)); } //*************************************************************************** @@ -320,16 +312,10 @@ namespace etl STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); assert(NBITS <= std::numeric_limits::digits); - const TReturn negative = (TReturn(1) << (NBITS - 1)); - TReturn signed_value = value & ((1 << NBITS) - 1); + TReturn mask = TReturn(1U) << (NBITS - 1); + value = value & ((1U << NBITS) - 1); - if ((signed_value & negative) != 0) - { - const TReturn sign_bits = ~((TReturn(1) << NBITS) - 1); - signed_value |= sign_bits; - } - - return signed_value; + return TReturn((value ^ mask) - mask); } //*************************************************************************** @@ -340,21 +326,15 @@ namespace etl template TReturn sign_extend(TValue value, const size_t NBITS, const size_t SHIFT) { - STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); + STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); STATIC_ASSERT(etl::is_integral::value, "TReturn not an integral type"); - STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); + STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); assert(NBITS <= std::numeric_limits::digits); - const TReturn negative = (TReturn(1) << (NBITS - 1)); - TReturn signed_value = (value >> SHIFT) & ((1 << NBITS) - 1); + TReturn mask = TReturn(1U) << (NBITS - 1); + value = (value >> SHIFT) & ((1U << NBITS) - 1); - if ((signed_value & negative) != 0) - { - const TReturn sign_bits = ~((TReturn(1) << NBITS) - 1); - signed_value |= sign_bits; - } - - return signed_value; + return TReturn((value ^ mask) - mask); } //*************************************************************************** From f2416da7eaf6ce972e27e410ad7875877f1e2b52 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 21 Apr 2018 09:24:45 +0100 Subject: [PATCH 02/14] Changed header guards to be GCC compliant. --- include/etl/algorithm.h | 4 +-- include/etl/alignment.h | 10 ++++---- include/etl/array.h | 4 +-- include/etl/array_view.h | 8 +++--- include/etl/array_wrapper.h | 6 ++--- include/etl/atomic.h | 4 +-- include/etl/atomic/atomic_arm.h | 4 +-- include/etl/atomic/atomic_gcc_sync.h | 4 +-- include/etl/atomic/atomic_std.h | 4 +-- include/etl/basic_string.h | 4 +-- include/etl/binary.h | 4 +-- include/etl/bitset.h | 4 +-- include/etl/bloom_filter.h | 12 ++++----- include/etl/c/ecl_timer.h | 4 +-- include/etl/callback_timer.h | 8 +++--- include/etl/char_traits.h | 4 +-- include/etl/checksum.h | 4 +-- include/etl/combinations.h | 4 +-- include/etl/compare.h | 4 +-- include/etl/constant.h | 4 +-- include/etl/container.h | 4 +-- include/etl/crc16.h | 4 +-- include/etl/crc16_ccitt.h | 4 +-- include/etl/crc16_kermit.h | 4 +-- include/etl/crc32.h | 4 +-- include/etl/crc64_ecma.h | 4 +-- include/etl/crc8_ccitt.h | 4 +-- include/etl/cstring.h | 8 +++--- include/etl/cyclic_value.h | 4 +-- include/etl/debounce.h | 14 +++++------ include/etl/debug_count.h | 4 +-- include/etl/deque.h | 4 +-- include/etl/endianness.h | 4 +-- include/etl/enum_type.h | 4 +-- include/etl/error_handler.h | 4 +-- include/etl/exception.h | 4 +-- include/etl/factorial.h | 4 +-- include/etl/fibonacci.h | 4 +-- include/etl/fixed_iterator.h | 4 +-- include/etl/flat_map.h | 4 +-- include/etl/flat_multimap.h | 4 +-- include/etl/flat_multiset.h | 4 +-- include/etl/flat_set.h | 4 +-- include/etl/fnv_1.h | 4 +-- include/etl/forward_list.h | 4 +-- include/etl/fsm.h | 4 +-- include/etl/fsm_generator.h | 4 +-- include/etl/function.h | 4 +-- include/etl/functional.h | 4 +-- include/etl/hash.h | 22 ++++++++--------- include/etl/ihash.h | 4 +-- include/etl/instance_count.h | 4 +-- include/etl/integral_limits.h | 4 +-- include/etl/intrusive_forward_list.h | 4 +-- include/etl/intrusive_links.h | 4 +-- include/etl/intrusive_list.h | 4 +-- include/etl/intrusive_queue.h | 4 +-- include/etl/intrusive_stack.h | 4 +-- include/etl/io_port.h | 4 +-- include/etl/iterator.h | 4 +-- include/etl/jenkins.h | 4 +-- include/etl/largest.h | 4 +-- include/etl/largest_generator.h | 4 +-- include/etl/list.h | 4 +-- include/etl/log.h | 4 +-- include/etl/map.h | 6 ++--- include/etl/memory.h | 4 +-- include/etl/message.h | 4 +-- include/etl/message_bus.h | 4 +-- include/etl/message_router.h | 4 +-- include/etl/message_router_generator.h | 4 +-- include/etl/message_timer.h | 8 +++--- include/etl/message_types.h | 4 +-- include/etl/multimap.h | 6 ++--- include/etl/multiset.h | 6 ++--- include/etl/murmur3.h | 4 +-- include/etl/mutex.h | 4 +-- include/etl/mutex/mutex_arm.h | 4 +-- include/etl/mutex/mutex_gcc_sync.h | 4 +-- include/etl/mutex/mutex_std.h | 4 +-- include/etl/nullptr.h | 4 +-- include/etl/numeric.h | 4 +-- include/etl/observer.h | 4 +-- include/etl/optional.h | 4 +-- include/etl/packet.h | 4 +-- include/etl/parameter_type.h | 4 +-- include/etl/pearson.h | 4 +-- include/etl/permutations.h | 4 +-- include/etl/platform.h | 4 +-- include/etl/pool.h | 4 +-- include/etl/power.h | 4 +-- include/etl/priority_queue.h | 4 +-- include/etl/private/ivectorpointer.h | 6 ++--- include/etl/private/pvoidvector.h | 8 +++--- include/etl/private/vector_base.h | 6 ++--- include/etl/profiles/arduino_arm.h | 4 +-- include/etl/profiles/armv5.h | 4 +-- include/etl/profiles/armv6.h | 4 +-- include/etl/profiles/cpp03.h | 4 +-- include/etl/profiles/cpp11.h | 4 +-- include/etl/profiles/cpp14.h | 4 +-- include/etl/profiles/gcc_generic.h | 4 +-- include/etl/profiles/gcc_linux_x86.h | 4 +-- include/etl/profiles/gcc_windows_x86.h | 4 +-- include/etl/profiles/msvc_x86.h | 4 +-- include/etl/profiles/ticc.h | 4 +-- include/etl/queue.h | 4 +-- include/etl/queue_mpmc_mutex.h | 4 +-- include/etl/queue_spsc_atomic.h | 4 +-- include/etl/queue_spsc_isr.h | 4 +-- include/etl/radix.h | 4 +-- include/etl/random.h | 4 +-- include/etl/reference_flat_map.h | 4 +-- include/etl/reference_flat_multimap.h | 4 +-- include/etl/reference_flat_multiset.h | 4 +-- include/etl/reference_flat_set.h | 4 +-- include/etl/scheduler.h | 4 +-- include/etl/set.h | 6 ++--- include/etl/smallest.h | 14 +++++------ include/etl/smallest_generator.h | 14 +++++------ include/etl/sqrt.h | 4 +-- include/etl/stack.h | 4 +-- include/etl/static_assert.h | 4 +-- include/etl/string_view.h | 12 ++++----- include/etl/task.h | 4 +-- include/etl/timer.h | 4 +-- include/etl/type_def.h | 4 +-- include/etl/type_lookup.h | 4 +-- include/etl/type_lookup_generator.h | 4 +-- include/etl/type_traits.h | 4 +-- include/etl/type_traits_generator.h | 4 +-- include/etl/u16string.h | 8 +++--- include/etl/u32string.h | 8 +++--- include/etl/unordered_map.h | 4 +-- include/etl/unordered_multimap.h | 4 +-- include/etl/unordered_multiset.h | 4 +-- include/etl/unordered_set.h | 4 +-- include/etl/user_type.h | 4 +-- include/etl/utility.h | 4 +-- include/etl/variant.h | 34 +++++++++++++------------- include/etl/variant_pool.h | 4 +-- include/etl/variant_pool_generator.h | 4 +-- include/etl/vector.h | 6 ++--- include/etl/version.h | 4 +-- include/etl/visitor.h | 4 +-- include/etl/wstring.h | 8 +++--- test/data.h | 4 +-- test/ecl_user.h | 4 +-- test/etl_profile.h | 4 +-- test/test_array_view.cpp | 2 +- test/test_array_wrapper.cpp | 2 +- test/test_string_char.cpp | 2 +- test/test_string_u16.cpp | 2 +- test/test_string_u32.cpp | 2 +- test/test_string_wchar_t.cpp | 2 +- 155 files changed, 378 insertions(+), 378 deletions(-) diff --git a/include/etl/algorithm.h b/include/etl/algorithm.h index 463dfd32..67917e26 100644 --- a/include/etl/algorithm.h +++ b/include/etl/algorithm.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ALGORITHM__ -#define __ETL_ALGORITHM__ +#ifndef ETL_ALGORITHM_INCLUDED +#define ETL_ALGORITHM_INCLUDED ///\defgroup algorithm algorithm /// Reverse engineered algorithms from C++ 0x11 diff --git a/include/etl/alignment.h b/include/etl/alignment.h index 39565c3a..1867874b 100644 --- a/include/etl/alignment.h +++ b/include/etl/alignment.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ALIGNEMENT__ -#define __ETL_ALIGNEMENT__ +#ifndef ETL_ALIGNEMENT_INCLUDED +#define ETL_ALIGNEMENT_INCLUDED #include @@ -43,7 +43,7 @@ SOFTWARE. namespace etl { - namespace __private_alignment__ + namespace private_alignment { //*************************************************************************** // Matcher. @@ -99,7 +99,7 @@ namespace etl { public: - typedef typename __private_alignment__::type_with_alignment_helper::type type; + typedef typename private_alignment::type_with_alignment_helper::type type; }; //*************************************************************************** @@ -183,7 +183,7 @@ namespace etl union { char data[LENGTH]; - typename etl::type_with_alignment::type __etl_alignment_type__; // A POD type that has the same alignment as ALIGNMENT. + typename etl::type_with_alignment::type etl_alignment_type; // A POD type that has the same alignment as ALIGNMENT. }; }; }; diff --git a/include/etl/array.h b/include/etl/array.h index d36af55b..06c096a7 100644 --- a/include/etl/array.h +++ b/include/etl/array.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ARRAY__ -#define __ETL_ARRAY__ +#ifndef ETL_ARRAY_INCLUDED +#define ETL_ARRAY_INCLUDED #include #include diff --git a/include/etl/array_view.h b/include/etl/array_view.h index c3e1ff46..7a9722c7 100644 --- a/include/etl/array_view.h +++ b/include/etl/array_view.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ARRAY_VIEW__ -#define __ETL_ARRAY_VIEW__ +#ifndef ETL_ARRAY_VIEW_INCLUDED +#define ETL_ARRAY_VIEW_INCLUDED #include "platform.h" #include "memory.h" @@ -832,7 +832,7 @@ namespace etl { size_t operator()(const etl::array_view& view) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&view[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&view[0]), reinterpret_cast(&view[view.size()])); } }; @@ -842,7 +842,7 @@ namespace etl { size_t operator()(const etl::const_array_view& view) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&view[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&view[0]), reinterpret_cast(&view[view.size()])); } }; diff --git a/include/etl/array_wrapper.h b/include/etl/array_wrapper.h index ba839c38..ec840350 100644 --- a/include/etl/array_wrapper.h +++ b/include/etl/array_wrapper.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ARRAY_WRAPPER__ -#define __ETL_ARRAY_WRAPPER__ +#ifndef ETL_ARRAY_WRAPPER_INCLUDED +#define ETL_ARRAY_WRAPPER_INCLUDED #include "platform.h" #include "iterator.h" @@ -396,7 +396,7 @@ namespace etl { size_t operator()(const etl::array_wrapper& aw) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&aw[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&aw[0]), reinterpret_cast(&aw[aw.size()])); } }; diff --git a/include/etl/atomic.h b/include/etl/atomic.h index 98a11efd..166c3e0b 100644 --- a/include/etl/atomic.h +++ b/include/etl/atomic.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ATOMIC__ -#define __ETL_ATOMIC__ +#ifndef ETL_ATOMIC_INCLUDED +#define ETL_ATOMIC_INCLUDED #include "platform.h" diff --git a/include/etl/atomic/atomic_arm.h b/include/etl/atomic/atomic_arm.h index 9a21ac25..9893fee2 100644 --- a/include/etl/atomic/atomic_arm.h +++ b/include/etl/atomic/atomic_arm.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ATOMIC_ARM__ -#define __ETL_ATOMIC_ARM__ +#ifndef ETL_ATOMIC_ARM_INCLUDED +#define ETL_ATOMIC_ARM_INCLUDED #include "atomic_gcc_sync.h" diff --git a/include/etl/atomic/atomic_gcc_sync.h b/include/etl/atomic/atomic_gcc_sync.h index 493b9803..d77046c2 100644 --- a/include/etl/atomic/atomic_gcc_sync.h +++ b/include/etl/atomic/atomic_gcc_sync.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ATOMIC_GCC_SYNC__ -#define __ETL_ATOMIC_GCC_SYNC__ +#ifndef ETL_ATOMIC_GCC_SYNC_INCLUDED +#define ETL_ATOMIC_GCC_SYNC_INCLUDED #include "../platform.h" #include "../type_traits.h" diff --git a/include/etl/atomic/atomic_std.h b/include/etl/atomic/atomic_std.h index 3970a290..7c957cab 100644 --- a/include/etl/atomic/atomic_std.h +++ b/include/etl/atomic/atomic_std.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ATOMIC_STD__ -#define __ETL_ATOMIC_STD__ +#ifndef ETL_ATOMIC_STD_INCLUDED +#define ETL_ATOMIC_STD_INCLUDED #include "../platform.h" #include "../nullptr.h" diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index f6741eea..b58e9599 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_BASIC_STRING__ -#define __ETL_BASIC_STRING__ +#ifndef ETL_BASIC_STRING_INCLUDED +#define ETL_BASIC_STRING_INCLUDED #include #include diff --git a/include/etl/binary.h b/include/etl/binary.h index 7a363d1c..7029c3fc 100644 --- a/include/etl/binary.h +++ b/include/etl/binary.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_BINARY__ -#define __ETL_BINARY__ +#ifndef ETL_BINARY_INCLUDED +#define ETL_BINARY_INCLUDED ///\defgroup binary binary /// Binary utilities diff --git a/include/etl/bitset.h b/include/etl/bitset.h index bb61db38..3e42bd86 100644 --- a/include/etl/bitset.h +++ b/include/etl/bitset.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_BITSET__ -#define __ETL_BITSET__ +#ifndef ETL_BITSET_INCLUDED +#define ETL_BITSET_INCLUDED #include #include diff --git a/include/etl/bloom_filter.h b/include/etl/bloom_filter.h index cb2cb48a..0ec97c38 100644 --- a/include/etl/bloom_filter.h +++ b/include/etl/bloom_filter.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_BLOOM_FILTER__ -#define __ETL_BLOOM_FILTER__ +#ifndef ETL_BLOOM_FILTER_INCLUDED +#define ETL_BLOOM_FILTER_INCLUDED #include "platform.h" #include "parameter_type.h" @@ -45,7 +45,7 @@ SOFTWARE. namespace etl { - namespace __private_bloom_filter__ + namespace private_bloom_filter { // Placeholder null hash for defaulted template parameters. struct null_hash @@ -71,14 +71,14 @@ namespace etl //*************************************************************************** template + typename THash2 = private_bloom_filter::null_hash, + typename THash3 = private_bloom_filter::null_hash> class bloom_filter { private: typedef typename etl::parameter_type::type parameter_t; - typedef __private_bloom_filter__::null_hash null_hash; + typedef private_bloom_filter::null_hash null_hash; public: diff --git a/include/etl/c/ecl_timer.h b/include/etl/c/ecl_timer.h index 0d5e33e9..d2c48dc8 100644 --- a/include/etl/c/ecl_timer.h +++ b/include/etl/c/ecl_timer.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_C_TIMER_FRAMEWORK__ -#define __ETL_C_TIMER_FRAMEWORK__ +#ifndef ETL_C_TIMER_FRAMEWORK_INCLUDED +#define ETL_C_TIMER_FRAMEWORK_INCLUDED #include diff --git a/include/etl/callback_timer.h b/include/etl/callback_timer.h index 5634b37a..c0b4c72d 100644 --- a/include/etl/callback_timer.h +++ b/include/etl/callback_timer.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CALLBACK_TIMER__ -#define __ETL_CALLBACK_TIMER__ +#ifndef ETL_CALLBACK_TIMER_INCLUDED +#define ETL_CALLBACK_TIMER_INCLUDED #include #include @@ -153,7 +153,7 @@ namespace etl callback_timer_data& operator =(const callback_timer_data& other); }; - namespace __private_callback_timer__ + namespace private_callback_timer { //************************************************************************* /// A specialised intrusive linked list for timer data. @@ -647,7 +647,7 @@ namespace etl callback_timer_data* const timer_array; // The list of active timers. - __private_callback_timer__::list active_list; + private_callback_timer::list active_list; volatile bool enabled; #if defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK) diff --git a/include/etl/char_traits.h b/include/etl/char_traits.h index 9470fa40..25ee662b 100644 --- a/include/etl/char_traits.h +++ b/include/etl/char_traits.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CHAR_TRAITS__ -#define __ETL_CHAR_TRAITS__ +#ifndef ETL_CHAR_TRAITS_INCLUDED +#define ETL_CHAR_TRAITS_INCLUDED #include diff --git a/include/etl/checksum.h b/include/etl/checksum.h index 9a2a6069..4809f346 100644 --- a/include/etl/checksum.h +++ b/include/etl/checksum.h @@ -24,8 +24,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CHECKSUM__ -#define __ETL_CHECKSUM__ +#ifndef ETL_CHECKSUM_INCLUDED +#define ETL_CHECKSUM_INCLUDED #include diff --git a/include/etl/combinations.h b/include/etl/combinations.h index 3ecb8a5e..ef868471 100644 --- a/include/etl/combinations.h +++ b/include/etl/combinations.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_COMBINATIONS__ -#define __ETL_COMBINATIONS__ +#ifndef ETL_COMBINATIONS_INCLUDED +#define ETL_COMBINATIONS_INCLUDED #include "platform.h" #include "permutations.h" diff --git a/include/etl/compare.h b/include/etl/compare.h index e6345e45..fdf864ce 100644 --- a/include/etl/compare.h +++ b/include/etl/compare.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_COMPARE__ -#define __ETL_COMPARE__ +#ifndef ETL_COMPARE_INCLUDED +#define ETL_COMPARE_INCLUDED #include diff --git a/include/etl/constant.h b/include/etl/constant.h index d9bb8302..633b5522 100644 --- a/include/etl/constant.h +++ b/include/etl/constant.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CONSTANT__ -#define __ETL_CONSTANT__ +#ifndef ETL_CONSTANT_INCLUDED +#define ETL_CONSTANT_INCLUDED #include "platform.h" diff --git a/include/etl/container.h b/include/etl/container.h index 5fffc7b7..51d66c30 100644 --- a/include/etl/container.h +++ b/include/etl/container.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CONTAINER__ -#define __ETL_CONTAINER__ +#ifndef ETL_CONTAINER_INCLUDED +#define ETL_CONTAINER_INCLUDED #include #include diff --git a/include/etl/crc16.h b/include/etl/crc16.h index 18dc88e6..1f535d1d 100644 --- a/include/etl/crc16.h +++ b/include/etl/crc16.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CRC16__ -#define __ETL_CRC16__ +#ifndef ETL_CRC16_INCLUDED +#define ETL_CRC16_INCLUDED #include #include diff --git a/include/etl/crc16_ccitt.h b/include/etl/crc16_ccitt.h index 3cedd827..90ce365e 100644 --- a/include/etl/crc16_ccitt.h +++ b/include/etl/crc16_ccitt.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CRC16_CCITT__ -#define __ETL_CRC16_CCITT__ +#ifndef ETL_CRC16_CCITT_INCLUDED +#define ETL_CRC16_CCITT_INCLUDED #include #include diff --git a/include/etl/crc16_kermit.h b/include/etl/crc16_kermit.h index 146b8504..4691c9ab 100644 --- a/include/etl/crc16_kermit.h +++ b/include/etl/crc16_kermit.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CRC16_KERMIT__ -#define __ETL_CRC16_KERMIT__ +#ifndef ETL_CRC16_KERMIT_INCLUDED +#define ETL_CRC16_KERMIT_INCLUDED #include #include diff --git a/include/etl/crc32.h b/include/etl/crc32.h index 477fdfa6..35af1545 100644 --- a/include/etl/crc32.h +++ b/include/etl/crc32.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CRC32__ -#define __ETL_CRC32__ +#ifndef ETL_CRC32_INCLUDED +#define ETL_CRC32_INCLUDED #include #include diff --git a/include/etl/crc64_ecma.h b/include/etl/crc64_ecma.h index c098d611..a1532ddc 100644 --- a/include/etl/crc64_ecma.h +++ b/include/etl/crc64_ecma.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CRC64_ECMA__ -#define __ETL_CRC64_ECMA__ +#ifndef ETL_CRC64_ECMA_INCLUDED +#define ETL_CRC64_ECMA_INCLUDED #include #include diff --git a/include/etl/crc8_ccitt.h b/include/etl/crc8_ccitt.h index 112b2945..61c3a140 100644 --- a/include/etl/crc8_ccitt.h +++ b/include/etl/crc8_ccitt.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CRC8_CCITT__ -#define __ETL_CRC8_CCITT__ +#ifndef ETL_CRC8_CCITT_INCLUDED +#define ETL_CRC8_CCITT_INCLUDED #include #include diff --git a/include/etl/cstring.h b/include/etl/cstring.h index d9f69f16..f2a0ee9a 100644 --- a/include/etl/cstring.h +++ b/include/etl/cstring.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_STRING__ -#define __ETL_STRING__ +#ifndef ETL_STRING_INCLUDED +#define ETL_STRING_INCLUDED #include "platform.h" #include "basic_string.h" @@ -210,7 +210,7 @@ namespace etl { size_t operator()(const etl::istring& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; @@ -220,7 +220,7 @@ namespace etl { size_t operator()(const etl::string& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; diff --git a/include/etl/cyclic_value.h b/include/etl/cyclic_value.h index e3f6ac66..9df9efb6 100644 --- a/include/etl/cyclic_value.h +++ b/include/etl/cyclic_value.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CYCLIC_VALUE__ -#define __ETL_CYCLIC_VALUE__ +#ifndef ETL_CYCLIC_VALUE_INCLUDED +#define ETL_CYCLIC_VALUE_INCLUDED #include diff --git a/include/etl/debounce.h b/include/etl/debounce.h index bb0db44a..ef0907c4 100644 --- a/include/etl/debounce.h +++ b/include/etl/debounce.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_DEBOUNCE__ -#define __ETL_DEBOUNCE__ +#ifndef ETL_DEBOUNCE_INCLUDED +#define ETL_DEBOUNCE_INCLUDED #include @@ -38,7 +38,7 @@ SOFTWARE. namespace etl { - namespace __private_debounce__ + namespace private_debounce { class debounce_base { @@ -431,7 +431,7 @@ namespace etl /// Fixed Valid/Hold/Repeating values. //*************************************************************************** template - class debounce : public __private_debounce__::debounce4 + class debounce : public private_debounce::debounce4 { public: @@ -460,7 +460,7 @@ namespace etl /// Fixed Valid/Hold values. //*************************************************************************** template - class debounce : public __private_debounce__::debounce3 + class debounce : public private_debounce::debounce3 { public: @@ -492,7 +492,7 @@ namespace etl /// Fixed Valid value. //*************************************************************************** template - class debounce : public __private_debounce__::debounce2 + class debounce : public private_debounce::debounce2 { public: @@ -523,7 +523,7 @@ namespace etl /// Variable Valid/Hold/Repeating values. //*************************************************************************** template <> - class debounce<0, 0, 0> : public __private_debounce__::debounce4 + class debounce<0, 0, 0> : public private_debounce::debounce4 { public: diff --git a/include/etl/debug_count.h b/include/etl/debug_count.h index 48ad3f97..41370c40 100644 --- a/include/etl/debug_count.h +++ b/include/etl/debug_count.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_DEBUG_COUNT__ -#define __ETL_DEBUG_COUNT__ +#ifndef ETL_DEBUG_COUNT_INCLUDED +#define ETL_DEBUG_COUNT_INCLUDED #include #include diff --git a/include/etl/deque.h b/include/etl/deque.h index dd487002..3a10a4e3 100644 --- a/include/etl/deque.h +++ b/include/etl/deque.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_DEQUE__ -#define __ETL_DEQUE__ +#ifndef ETL_DEQUE_INCLUDED +#define ETL_DEQUE_INCLUDED #include #include diff --git a/include/etl/endianness.h b/include/etl/endianness.h index 5dd3dcfc..f779b65e 100644 --- a/include/etl/endianness.h +++ b/include/etl/endianness.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ENDIAN__ -#define __ETL_ENDIAN__ +#ifndef ETL_ENDIAN_INCLUDED +#define ETL_ENDIAN_INCLUDED #include diff --git a/include/etl/enum_type.h b/include/etl/enum_type.h index 6f3da8d2..6a0bae8e 100644 --- a/include/etl/enum_type.h +++ b/include/etl/enum_type.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ENUM_TYPE__ -#define __ETL_ENUM_TYPE__ +#ifndef ETL_ENUM_TYPE_INCLUDED +#define ETL_ENUM_TYPE_INCLUDED #include "platform.h" diff --git a/include/etl/error_handler.h b/include/etl/error_handler.h index 421be222..12c9ff3e 100644 --- a/include/etl/error_handler.h +++ b/include/etl/error_handler.h @@ -29,8 +29,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ERROR_HANDLER__ -#define __ETL_ERROR_HANDLER__ +#ifndef ETL_ERROR_HANDLER_INCLUDED +#define ETL_ERROR_HANDLER_INCLUDED ///\defgroup error_handler error_handler /// Error handler for when throwing exceptions is not required. diff --git a/include/etl/exception.h b/include/etl/exception.h index 271139a4..d3c779b8 100644 --- a/include/etl/exception.h +++ b/include/etl/exception.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_EXCEPTION__ -#define __ETL_EXCEPTION__ +#ifndef ETL_EXCEPTION_INCLUDED +#define ETL_EXCEPTION_INCLUDED #include "platform.h" diff --git a/include/etl/factorial.h b/include/etl/factorial.h index 688ae817..c42342f0 100644 --- a/include/etl/factorial.h +++ b/include/etl/factorial.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FACTORIAL__ -#define __ETL_FACTORIAL__ +#ifndef ETL_FACTORIAL_INCLUDED +#define ETL_FACTORIAL_INCLUDED #include diff --git a/include/etl/fibonacci.h b/include/etl/fibonacci.h index 70930633..9e3a5656 100644 --- a/include/etl/fibonacci.h +++ b/include/etl/fibonacci.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FIBONACCI__ -#define __ETL_FIBONACCI__ +#ifndef ETL_FIBONACCI_INCLUDED +#define ETL_FIBONACCI_INCLUDED #include diff --git a/include/etl/fixed_iterator.h b/include/etl/fixed_iterator.h index b09aba26..c981320b 100644 --- a/include/etl/fixed_iterator.h +++ b/include/etl/fixed_iterator.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FIXED_ITERATOR__ -#define __ETL_FIXED_ITERATOR__ +#ifndef ETL_FIXED_ITERATOR_INCLUDED +#define ETL_FIXED_ITERATOR_INCLUDED #include diff --git a/include/etl/flat_map.h b/include/etl/flat_map.h index abd423b4..087b792c 100644 --- a/include/etl/flat_map.h +++ b/include/etl/flat_map.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FLAT_MAP__ -#define __ETL_FLAT_MAP__ +#ifndef ETL_FLAT_MAP_INCLUDED +#define ETL_FLAT_MAP_INCLUDED #include "platform.h" #include "reference_flat_map.h" diff --git a/include/etl/flat_multimap.h b/include/etl/flat_multimap.h index 25b6a36d..4611f8af 100644 --- a/include/etl/flat_multimap.h +++ b/include/etl/flat_multimap.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FLAT_MULTMAP__ -#define __ETL_FLAT_MULTMAP__ +#ifndef ETL_FLAT_MULTMAP_INCLUDED +#define ETL_FLAT_MULTMAP_INCLUDED #include "platform.h" #include "reference_flat_multimap.h" diff --git a/include/etl/flat_multiset.h b/include/etl/flat_multiset.h index c47dff0d..243c9ddb 100644 --- a/include/etl/flat_multiset.h +++ b/include/etl/flat_multiset.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FLAT_MULTISET__ -#define __ETL_FLAT_MULTISET__ +#ifndef ETL_FLAT_MULTISET_INCLUDED +#define ETL_FLAT_MULTISET_INCLUDED #include "platform.h" #include "reference_flat_multiset.h" diff --git a/include/etl/flat_set.h b/include/etl/flat_set.h index 5366c0e8..c2f0f4c2 100644 --- a/include/etl/flat_set.h +++ b/include/etl/flat_set.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FLAT_SET__ -#define __ETL_FLAT_SET__ +#ifndef ETL_FLAT_SET_INCLUDED +#define ETL_FLAT_SET_INCLUDED #include "platform.h" #include "reference_flat_set.h" diff --git a/include/etl/fnv_1.h b/include/etl/fnv_1.h index c9799196..c5704454 100644 --- a/include/etl/fnv_1.h +++ b/include/etl/fnv_1.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FNV_1__ -#define __ETL_FNV_1__ +#ifndef ETL_FNV_1_INCLUDED +#define ETL_FNV_1_INCLUDED #include diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index eaf5fcd0..0d32dfe5 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FORWARD_LIST__ -#define __ETL_FORWARD_LIST__ +#ifndef ETL_FORWARD_LIST_INCLUDED +#define ETL_FORWARD_LIST_INCLUDED #include #include diff --git a/include/etl/fsm.h b/include/etl/fsm.h index 179ee0b3..54a06c36 100644 --- a/include/etl/fsm.h +++ b/include/etl/fsm.h @@ -48,8 +48,8 @@ SOFTWARE. // See generate.bat //*************************************************************************** -#ifndef __ETL_FSM__ -#define __ETL_FSM__ +#ifndef ETL_FSM_INCLUDED +#define ETL_FSM_INCLUDED #include diff --git a/include/etl/fsm_generator.h b/include/etl/fsm_generator.h index 4f50006e..a6f9fbcb 100644 --- a/include/etl/fsm_generator.h +++ b/include/etl/fsm_generator.h @@ -60,8 +60,8 @@ cog.outl("//******************************************************************** // See generate.bat //*************************************************************************** -#ifndef __ETL_FSM__ -#define __ETL_FSM__ +#ifndef ETL_FSM_INCLUDED +#define ETL_FSM_INCLUDED #include diff --git a/include/etl/function.h b/include/etl/function.h index 2e07390b..502efd8e 100644 --- a/include/etl/function.h +++ b/include/etl/function.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FUNCTION__ -#define __ETL_FUNCTION__ +#ifndef ETL_FUNCTION_INCLUDED +#define ETL_FUNCTION_INCLUDED #include "platform.h" diff --git a/include/etl/functional.h b/include/etl/functional.h index a2187d5c..eb0e85b4 100644 --- a/include/etl/functional.h +++ b/include/etl/functional.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_FUNCTIONAL__ -#define __ETL_FUNCTIONAL__ +#ifndef ETL_FUNCTIONAL_INCLUDED +#define ETL_FUNCTIONAL_INCLUDED #include "platform.h" diff --git a/include/etl/hash.h b/include/etl/hash.h index 891b8518..61b19b81 100644 --- a/include/etl/hash.h +++ b/include/etl/hash.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_HASH__ -#define __ETL_HASH__ +#ifndef ETL_HASH_INCLUDED +#define ETL_HASH_INCLUDED #include #include @@ -46,7 +46,7 @@ SOFTWARE. namespace etl { - namespace __private_hash__ + namespace private_hash { //************************************************************************* /// Hash to use when size_t is 16 bits. @@ -242,7 +242,7 @@ namespace etl else { uint8_t* p = reinterpret_cast(&v); - return __private_hash__::generic_hash(p, p + sizeof(v)); + return private_hash::generic_hash(p, p + sizeof(v)); } } }; @@ -264,7 +264,7 @@ namespace etl else { uint8_t* p = reinterpret_cast(&v); - return __private_hash__::generic_hash(p, p + sizeof(v)); + return private_hash::generic_hash(p, p + sizeof(v)); } } }; @@ -286,7 +286,7 @@ namespace etl else { uint8_t* p = reinterpret_cast(&v); - return __private_hash__::generic_hash(p, p + sizeof(v)); + return private_hash::generic_hash(p, p + sizeof(v)); } } }; @@ -308,7 +308,7 @@ namespace etl else { uint8_t* p = reinterpret_cast(&v); - return __private_hash__::generic_hash(p, p + sizeof(v)); + return private_hash::generic_hash(p, p + sizeof(v)); } } }; @@ -338,7 +338,7 @@ namespace etl else { uint8_t* p = reinterpret_cast(&v); - return __private_hash__::generic_hash(p, p + sizeof(v)); + return private_hash::generic_hash(p, p + sizeof(v)); } } }; @@ -368,7 +368,7 @@ namespace etl else { uint8_t* p = reinterpret_cast(&v); - return __private_hash__::generic_hash(p, p + sizeof(v)); + return private_hash::generic_hash(p, p + sizeof(v)); } } }; @@ -398,7 +398,7 @@ namespace etl else { uint8_t* p = reinterpret_cast(&v); - return __private_hash__::generic_hash(p, p + sizeof(v)); + return private_hash::generic_hash(p, p + sizeof(v)); } } }; @@ -428,7 +428,7 @@ namespace etl else { uint8_t* p = reinterpret_cast(&v); - return __private_hash__::generic_hash(p, p + sizeof(v)); + return private_hash::generic_hash(p, p + sizeof(v)); } } }; diff --git a/include/etl/ihash.h b/include/etl/ihash.h index db154233..e0ccf2b5 100644 --- a/include/etl/ihash.h +++ b/include/etl/ihash.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_IHASH__ -#define __ETL_IHASH__ +#ifndef ETL_IHASH_INCLUDED +#define ETL_IHASH_INCLUDED #include #include diff --git a/include/etl/instance_count.h b/include/etl/instance_count.h index 262510df..2d94f317 100644 --- a/include/etl/instance_count.h +++ b/include/etl/instance_count.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_INSTANCE_COUNT__ -#define __ETL_INSTANCE_COUNT__ +#ifndef ETL_INSTANCE_COUNT_INCLUDED +#define ETL_INSTANCE_COUNT_INCLUDED #include diff --git a/include/etl/integral_limits.h b/include/etl/integral_limits.h index f231bf48..4277d939 100644 --- a/include/etl/integral_limits.h +++ b/include/etl/integral_limits.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_INTEGRAL_LIMITS__ -#define __ETL_INTEGRAL_LIMITS__ +#ifndef ETL_INTEGRAL_LIMITS_INCLUDED +#define ETL_INTEGRAL_LIMITS_INCLUDED #include #include diff --git a/include/etl/intrusive_forward_list.h b/include/etl/intrusive_forward_list.h index 1ac767dd..9c8e0224 100644 --- a/include/etl/intrusive_forward_list.h +++ b/include/etl/intrusive_forward_list.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_INTRUSIVE_FORWARD_LIST__ -#define __ETL_INTRUSIVE_FORWARD_LIST__ +#ifndef ETL_INTRUSIVE_FORWARD_LIST_INCLUDED +#define ETL_INTRUSIVE_FORWARD_LIST_INCLUDED #include "platform.h" diff --git a/include/etl/intrusive_links.h b/include/etl/intrusive_links.h index d4a19cf5..65353e7b 100644 --- a/include/etl/intrusive_links.h +++ b/include/etl/intrusive_links.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_INTRUSIVE_LINKS__ -#define __ETL_INTRUSIVE_LINKS__ +#ifndef ETL_INTRUSIVE_LINKS_INCLUDED +#define ETL_INTRUSIVE_LINKS_INCLUDED #include #include diff --git a/include/etl/intrusive_list.h b/include/etl/intrusive_list.h index e78a2669..2d0e764c 100644 --- a/include/etl/intrusive_list.h +++ b/include/etl/intrusive_list.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_INTRUSIVE_LIST__ -#define __ETL_INTRUSIVE_LIST__ +#ifndef ETL_INTRUSIVE_LIST_INCLUDED +#define ETL_INTRUSIVE_LIST_INCLUDED #include "platform.h" diff --git a/include/etl/intrusive_queue.h b/include/etl/intrusive_queue.h index 315e25ee..48885fac 100644 --- a/include/etl/intrusive_queue.h +++ b/include/etl/intrusive_queue.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_INTRUSIVE_QUEUE__ -#define __ETL_INTRUSIVE_QUEUE__ +#ifndef ETL_INTRUSIVE_QUEUE_INCLUDED +#define ETL_INTRUSIVE_QUEUE_INCLUDED #include diff --git a/include/etl/intrusive_stack.h b/include/etl/intrusive_stack.h index 9ead1175..8f7bfe40 100644 --- a/include/etl/intrusive_stack.h +++ b/include/etl/intrusive_stack.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_INTRUSIVE_STACK__ -#define __ETL_INTRUSIVE_STACK__ +#ifndef ETL_INTRUSIVE_STACK_INCLUDED +#define ETL_INTRUSIVE_STACK_INCLUDED #include diff --git a/include/etl/io_port.h b/include/etl/io_port.h index 2577162b..053a1f78 100644 --- a/include/etl/io_port.h +++ b/include/etl/io_port.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_IO_PORT__ -#define __ETL_IO_PORT__ +#ifndef ETL_IO_PORT_INCLUDED +#define ETL_IO_PORT_INCLUDED ///\defgroup io_port io port /// IO port access diff --git a/include/etl/iterator.h b/include/etl/iterator.h index 7b17e0cc..3e1e2a0b 100644 --- a/include/etl/iterator.h +++ b/include/etl/iterator.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ITERATOR__ -#define __ETL_ITERATOR__ +#ifndef ETL_ITERATOR_INCLUDED +#define ETL_ITERATOR_INCLUDED #include diff --git a/include/etl/jenkins.h b/include/etl/jenkins.h index c9daa4e5..7135b685 100644 --- a/include/etl/jenkins.h +++ b/include/etl/jenkins.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_JENKINS__ -#define __ETL_JENKINS__ +#ifndef ETL_JENKINS_INCLUDED +#define ETL_JENKINS_INCLUDED #include #include diff --git a/include/etl/largest.h b/include/etl/largest.h index 616594f7..0bb51c11 100644 --- a/include/etl/largest.h +++ b/include/etl/largest.h @@ -50,8 +50,8 @@ SOFTWARE. // See generate.bat //*************************************************************************** -#ifndef __ETL_LARGEST__ -#define __ETL_LARGEST__ +#ifndef ETL_LARGEST_INCLUDED +#define ETL_LARGEST_INCLUDED ///\defgroup largest largest ///\ingroup utilities diff --git a/include/etl/largest_generator.h b/include/etl/largest_generator.h index b701a70c..f73661ed 100644 --- a/include/etl/largest_generator.h +++ b/include/etl/largest_generator.h @@ -62,8 +62,8 @@ cog.outl("//******************************************************************** // See generate.bat //*************************************************************************** -#ifndef __ETL_LARGEST__ -#define __ETL_LARGEST__ +#ifndef ETL_LARGEST_INCLUDED +#define ETL_LARGEST_INCLUDED ///\defgroup largest largest ///\ingroup utilities diff --git a/include/etl/list.h b/include/etl/list.h index 8ed4e267..174e2b6b 100644 --- a/include/etl/list.h +++ b/include/etl/list.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_LIST__ -#define __ETL_LIST__ +#ifndef ETL_LIST_INCLUDED +#define ETL_LIST_INCLUDED #include #include diff --git a/include/etl/log.h b/include/etl/log.h index bf9aa7ab..0971d515 100644 --- a/include/etl/log.h +++ b/include/etl/log.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_LOG__ -#define __ETL_LOG__ +#ifndef ETL_LOG_INCLUDED +#define ETL_LOG_INCLUDED #include diff --git a/include/etl/map.h b/include/etl/map.h index 19e04f43..276457f4 100644 --- a/include/etl/map.h +++ b/include/etl/map.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MAP__ -#define __ETL_MAP__ +#ifndef ETL_MAP_INCLUDED +#define ETL_MAP_INCLUDED #include #include @@ -342,7 +342,7 @@ namespace etl //************************************************************************* void rotate_3node(Node*& position, uint_least8_t dir, uint_least8_t third) { - // __A__ __E__ __A__ __D__ + // --A-- --E-- --A-- --D-- // _B_ C -> B A OR B _C_ -> A C // D E D F G C D E B F G E // F G F G diff --git a/include/etl/memory.h b/include/etl/memory.h index 1f1e0ad5..9a886af3 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MEMORY__ -#define __ETL_MEMORY__ +#ifndef ETL_MEMORY_INCLUDED +#define ETL_MEMORY_INCLUDED #include #include diff --git a/include/etl/message.h b/include/etl/message.h index 4d83fb7b..64d1bb96 100644 --- a/include/etl/message.h +++ b/include/etl/message.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MESSAGE__ -#define __ETL_MESSAGE__ +#ifndef ETL_MESSAGE_INCLUDED +#define ETL_MESSAGE_INCLUDED #include diff --git a/include/etl/message_bus.h b/include/etl/message_bus.h index 11031a8f..25046dda 100644 --- a/include/etl/message_bus.h +++ b/include/etl/message_bus.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MESSAGE_BUS_ -#define __ETL_MESSAGE_BUS_ +#ifndef ETL_MESSAGE_BUS_ +#define ETL_MESSAGE_BUS_ #include #include diff --git a/include/etl/message_router.h b/include/etl/message_router.h index 0cf4a4f7..62f591df 100644 --- a/include/etl/message_router.h +++ b/include/etl/message_router.h @@ -48,8 +48,8 @@ SOFTWARE. // See generate.bat //*************************************************************************** -#ifndef __ETL_MESSAGE_ROUTER__ -#define __ETL_MESSAGE_ROUTER__ +#ifndef ETL_MESSAGE_ROUTER_INCLUDED +#define ETL_MESSAGE_ROUTER_INCLUDED #include diff --git a/include/etl/message_router_generator.h b/include/etl/message_router_generator.h index 9b43caec..989a1619 100644 --- a/include/etl/message_router_generator.h +++ b/include/etl/message_router_generator.h @@ -60,8 +60,8 @@ cog.outl("//******************************************************************** // See generate.bat //*************************************************************************** -#ifndef __ETL_MESSAGE_ROUTER__ -#define __ETL_MESSAGE_ROUTER__ +#ifndef ETL_MESSAGE_ROUTER_INCLUDED +#define ETL_MESSAGE_ROUTER_INCLUDED #include diff --git a/include/etl/message_timer.h b/include/etl/message_timer.h index 4a570ae2..9ec27add 100644 --- a/include/etl/message_timer.h +++ b/include/etl/message_timer.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MESSAGE_TIMER__ -#define __ETL_MESSAGE_TIMER__ +#ifndef ETL_MESSAGE_TIMER_INCLUDED +#define ETL_MESSAGE_TIMER_INCLUDED #include #include @@ -148,7 +148,7 @@ namespace etl message_timer_data& operator =(const message_timer_data& other); }; - namespace __private_message_timer__ + namespace private_message_timer { //************************************************************************* /// A specialised intrusive linked list for timer data. @@ -623,7 +623,7 @@ namespace etl message_timer_data* const timer_array; // The list of active timers. - __private_message_timer__::list active_list; + private_message_timer::list active_list; volatile bool enabled; diff --git a/include/etl/message_types.h b/include/etl/message_types.h index 2e5f7b05..b5824bb7 100644 --- a/include/etl/message_types.h +++ b/include/etl/message_types.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MESSAGE_DEFS__ -#define __ETL_MESSAGE_DEFS__ +#ifndef ETL_MESSAGE_DEFS_INCLUDED +#define ETL_MESSAGE_DEFS_INCLUDED #include diff --git a/include/etl/multimap.h b/include/etl/multimap.h index fa032c0a..b855e2cd 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MULTIMAP__ -#define __ETL_MULTIMAP__ +#ifndef ETL_MULTIMAP_INCLUDED +#define ETL_MULTIMAP_INCLUDED #include #include @@ -347,7 +347,7 @@ namespace etl //************************************************************************* void rotate_3node(Node*& position, uint_least8_t dir, uint_least8_t third) { - // __A__ __E__ __A__ __D__ + // --A-- --E-- --A-- --D-- // _B_ C -> B A OR B _C_ -> A C // D E D F G C D E B F G E // F G F G diff --git a/include/etl/multiset.h b/include/etl/multiset.h index 7bb0fff2..23eed65d 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MULTISET__ -#define __ETL_MULTISET__ +#ifndef ETL_MULTISET_INCLUDED +#define ETL_MULTISET_INCLUDED #include #include @@ -555,7 +555,7 @@ namespace etl //************************************************************************* void rotate_3node(Node*& position, uint_least8_t dir, uint_least8_t third) { - // __A__ __E__ __A__ __D__ + // --A-- --E-- --A-- --D-- // _B_ C -> B A OR B _C_ -> A C // D E D F G C D E B F G E // F G F G diff --git a/include/etl/murmur3.h b/include/etl/murmur3.h index 6cd9b8ed..d417e3d5 100644 --- a/include/etl/murmur3.h +++ b/include/etl/murmur3.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MURMUR3__ -#define __ETL_MURMUR3__ +#ifndef ETL_MURMUR3_INCLUDED +#define ETL_MURMUR3_INCLUDED #include diff --git a/include/etl/mutex.h b/include/etl/mutex.h index 87ea68a8..0fb1ec10 100644 --- a/include/etl/mutex.h +++ b/include/etl/mutex.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MUTEX__ -#define __ETL_MUTEX__ +#ifndef ETL_MUTEX_INCLUDED +#define ETL_MUTEX_INCLUDED #include "platform.h" diff --git a/include/etl/mutex/mutex_arm.h b/include/etl/mutex/mutex_arm.h index 4b33bb77..c548b059 100644 --- a/include/etl/mutex/mutex_arm.h +++ b/include/etl/mutex/mutex_arm.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MUTEX_ARM__ -#define __ETL_MUTEX_ARM__ +#ifndef ETL_MUTEX_ARM_INCLUDED +#define ETL_MUTEX_ARM_INCLUDED #include "mutex_gcc_sync.h" diff --git a/include/etl/mutex/mutex_gcc_sync.h b/include/etl/mutex/mutex_gcc_sync.h index e61e08b8..3d70097f 100644 --- a/include/etl/mutex/mutex_gcc_sync.h +++ b/include/etl/mutex/mutex_gcc_sync.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MUTEX_GCC_SYNC__ -#define __ETL_MUTEX_GCC_SYNC__ +#ifndef ETL_MUTEX_GCC_SYNC_INCLUDED +#define ETL_MUTEX_GCC_SYNC_INCLUDED #include "../platform.h" diff --git a/include/etl/mutex/mutex_std.h b/include/etl/mutex/mutex_std.h index 35df0ed9..30908f8c 100644 --- a/include/etl/mutex/mutex_std.h +++ b/include/etl/mutex/mutex_std.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MUTEX_STD__ -#define __ETL_MUTEX_STD__ +#ifndef ETL_MUTEX_STD_INCLUDED +#define ETL_MUTEX_STD_INCLUDED #include "../platform.h" diff --git a/include/etl/nullptr.h b/include/etl/nullptr.h index ccac5f68..07de981b 100644 --- a/include/etl/nullptr.h +++ b/include/etl/nullptr.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_NULLPTR__ -#define __ETL_NULLPTR__ +#ifndef ETL_NULLPTR_INCLUDED +#define ETL_NULLPTR_INCLUDED #include "platform.h" diff --git a/include/etl/numeric.h b/include/etl/numeric.h index ed3a4c08..f13f7f9c 100644 --- a/include/etl/numeric.h +++ b/include/etl/numeric.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_NUMERIC__ -#define __ETL_NUMERIC__ +#ifndef ETL_NUMERIC_INCLUDED +#define ETL_NUMERIC_INCLUDED #include "platform.h" diff --git a/include/etl/observer.h b/include/etl/observer.h index c48dc7f0..b9c0dbfa 100644 --- a/include/etl/observer.h +++ b/include/etl/observer.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_OBSERVER__ -#define __ETL_OBSERVER__ +#ifndef ETL_OBSERVER_INCLUDED +#define ETL_OBSERVER_INCLUDED //***************************************************************************** ///\defgroup observer observer diff --git a/include/etl/optional.h b/include/etl/optional.h index 08cf7805..47f84004 100644 --- a/include/etl/optional.h +++ b/include/etl/optional.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_OPTIONAL__ -#define __ETL_OPTIONAL__ +#ifndef ETL_OPTIONAL_INCLUDED +#define ETL_OPTIONAL_INCLUDED #include "platform.h" #include "alignment.h" diff --git a/include/etl/packet.h b/include/etl/packet.h index ef0e2d79..bd9f28f7 100644 --- a/include/etl/packet.h +++ b/include/etl/packet.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_PACKET__ -#define __ETL_PACKET__ +#ifndef ETL_PACKET_INCLUDED +#define ETL_PACKET_INCLUDED #include "platform.h" #include "static_assert.h" diff --git a/include/etl/parameter_type.h b/include/etl/parameter_type.h index 75203c53..7d5e0dc6 100644 --- a/include/etl/parameter_type.h +++ b/include/etl/parameter_type.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_PARAMETER__ -#define __ETL_PARAMETER__ +#ifndef ETL_PARAMETER_INCLUDED +#define ETL_PARAMETER_INCLUDED #include "platform.h" #include "type_traits.h" diff --git a/include/etl/pearson.h b/include/etl/pearson.h index 7e779f44..aef15302 100644 --- a/include/etl/pearson.h +++ b/include/etl/pearson.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_PEARSON__ -#define __ETL_PEARSON__ +#ifndef ETL_PEARSON_INCLUDED +#define ETL_PEARSON_INCLUDED #include diff --git a/include/etl/permutations.h b/include/etl/permutations.h index 9a1feba4..8101f8a7 100644 --- a/include/etl/permutations.h +++ b/include/etl/permutations.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_PERMUTATIONS__ -#define __ETL_PERMUTATIONS__ +#ifndef ETL_PERMUTATIONS_INCLUDED +#define ETL_PERMUTATIONS_INCLUDED #include "platform.h" diff --git a/include/etl/platform.h b/include/etl/platform.h index dd787607..655f78bb 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -30,8 +30,8 @@ SOFTWARE. #include -#ifndef __ETL_PLATFORM__ -#define __ETL_PLATFORM__ +#ifndef ETL_PLATFORM_INCLUDED +#define ETL_PLATFORM_INCLUDED // Some targets do not support 8bit types. #define ETL_8BIT_SUPPORT (CHAR_BIT == 8) diff --git a/include/etl/pool.h b/include/etl/pool.h index 36bf99b6..8ce26fe1 100644 --- a/include/etl/pool.h +++ b/include/etl/pool.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_POOL__ -#define __ETL_POOL__ +#ifndef ETL_POOL_INCLUDED +#define ETL_POOL_INCLUDED #include "platform.h" #include "error_handler.h" diff --git a/include/etl/power.h b/include/etl/power.h index dd2435d3..aaa144d9 100644 --- a/include/etl/power.h +++ b/include/etl/power.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_POW__ -#define __ETL_POW__ +#ifndef ETL_POW_INCLUDED +#define ETL_POW_INCLUDED #include #include diff --git a/include/etl/priority_queue.h b/include/etl/priority_queue.h index c48ba358..42df8261 100644 --- a/include/etl/priority_queue.h +++ b/include/etl/priority_queue.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_PRIORITY_QUEUE__ -#define __ETL_PRIORITY_QUEUE__ +#ifndef ETL_PRIORITY_QUEUE_INCLUDED +#define ETL_PRIORITY_QUEUE_INCLUDED #include #include diff --git a/include/etl/private/ivectorpointer.h b/include/etl/private/ivectorpointer.h index 0ba80810..6dcda8f3 100644 --- a/include/etl/private/ivectorpointer.h +++ b/include/etl/private/ivectorpointer.h @@ -28,10 +28,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_IVECTOR_POINTER__ -#define __ETL_IVECTOR_POINTER__ +#ifndef ETL_IVECTOR_POINTER_INCLUDED +#define ETL_IVECTOR_POINTER_INCLUDED -#ifndef __ETL_IN_VECTOR_H__ +#ifndef ETL_IN_VECTOR_H #error This header is a private element of etl::ivector #endif diff --git a/include/etl/private/pvoidvector.h b/include/etl/private/pvoidvector.h index 664eb563..43580844 100644 --- a/include/etl/private/pvoidvector.h +++ b/include/etl/private/pvoidvector.h @@ -28,10 +28,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_PVOIDVECTOR__ -#define __ETL_PVOIDVECTOR__ +#ifndef ETL_PVOIDVECTOR_INCLUDED +#define ETL_PVOIDVECTOR_INCLUDED -#define __ETL_IN_PVOIDVECTOR__ +#define ETL_IN_PVOIDVECTOR #include #include @@ -598,6 +598,6 @@ namespace etl #define min(a,b) (((a) < (b)) ? (a) : (b)) #endif -#undef __ETL_IN_PVOIDVECTOR__ +#undef ETL_IN_PVOIDVECTOR #endif diff --git a/include/etl/private/vector_base.h b/include/etl/private/vector_base.h index bcd131ab..6839e67a 100644 --- a/include/etl/private/vector_base.h +++ b/include/etl/private/vector_base.h @@ -28,12 +28,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#if !defined(__ETL_IN_VECTOR_H__) && !defined(__ETL_IN_PVOIDVECTOR__) +#if !defined(ETL_IN_VECTOR_H) && !defined(ETL_IN_PVOIDVECTOR) #error This header is a private element of etl::vector & etl::pvoidvector #endif -#ifndef __ETL_VECTOR_BASE__ -#define __ETL_VECTOR_BASE__ +#ifndef ETL_VECTOR_BASE_INCLUDED +#define ETL_VECTOR_BASE_INCLUDED #include diff --git a/include/etl/profiles/arduino_arm.h b/include/etl/profiles/arduino_arm.h index 6390676b..ca43b901 100644 --- a/include/etl/profiles/arduino_arm.h +++ b/include/etl/profiles/arduino_arm.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ARDUINO__ -#define __ETL_ARDUINO__ +#ifndef ETL_ARDUINO_INCLUDED +#define ETL_ARDUINO_INCLUDED //***************************************************************************** // Arduino diff --git a/include/etl/profiles/armv5.h b/include/etl/profiles/armv5.h index cf9db405..cf9d601f 100644 --- a/include/etl/profiles/armv5.h +++ b/include/etl/profiles/armv5.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ARMV5__ -#define __ETL_ARMV5__ +#ifndef ETL_ARMV5_INCLUDED +#define ETL_ARMV5_INCLUDED //***************************************************************************** // ARM Compiler Version 5 diff --git a/include/etl/profiles/armv6.h b/include/etl/profiles/armv6.h index d3a1a0d3..3cafec46 100644 --- a/include/etl/profiles/armv6.h +++ b/include/etl/profiles/armv6.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_ARMV6__ -#define __ETL_ARMV6__ +#ifndef ETL_ARMV6_INCLUDED +#define ETL_ARMV6_INCLUDED //***************************************************************************** // ARM Compiler Version 6 diff --git a/include/etl/profiles/cpp03.h b/include/etl/profiles/cpp03.h index 8f6f3d90..79379628 100644 --- a/include/etl/profiles/cpp03.h +++ b/include/etl/profiles/cpp03.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CPP03__ -#define __ETL_CPP03__ +#ifndef ETL_CPP03_INCLUDED +#define ETL_CPP03_INCLUDED //***************************************************************************** // Generic C++03 diff --git a/include/etl/profiles/cpp11.h b/include/etl/profiles/cpp11.h index f392e56e..3faaa1db 100644 --- a/include/etl/profiles/cpp11.h +++ b/include/etl/profiles/cpp11.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CPP11__ -#define __ETL_CPP11__ +#ifndef ETL_CPP11_INCLUDED +#define ETL_CPP11_INCLUDED //***************************************************************************** // Generic C++11 diff --git a/include/etl/profiles/cpp14.h b/include/etl/profiles/cpp14.h index f3083565..28bc9988 100644 --- a/include/etl/profiles/cpp14.h +++ b/include/etl/profiles/cpp14.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_CPP14__ -#define __ETL_CPP14__ +#ifndef ETL_CPP14_INCLUDED +#define ETL_CPP14_INCLUDED //***************************************************************************** // Generic C++14 diff --git a/include/etl/profiles/gcc_generic.h b/include/etl/profiles/gcc_generic.h index 9bb3cb9f..68a54123 100644 --- a/include/etl/profiles/gcc_generic.h +++ b/include/etl/profiles/gcc_generic.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_GCC__ -#define __ETL_GCC__ +#ifndef ETL_GCC_INCLUDED +#define ETL_GCC_INCLUDED //***************************************************************************** // GCC diff --git a/include/etl/profiles/gcc_linux_x86.h b/include/etl/profiles/gcc_linux_x86.h index ea98ea8c..2435658a 100644 --- a/include/etl/profiles/gcc_linux_x86.h +++ b/include/etl/profiles/gcc_linux_x86.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_GCC__ -#define __ETL_GCC__ +#ifndef ETL_GCC_INCLUDED +#define ETL_GCC_INCLUDED //***************************************************************************** // GCC diff --git a/include/etl/profiles/gcc_windows_x86.h b/include/etl/profiles/gcc_windows_x86.h index 455e96be..5fa06f48 100644 --- a/include/etl/profiles/gcc_windows_x86.h +++ b/include/etl/profiles/gcc_windows_x86.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_GCC__ -#define __ETL_GCC__ +#ifndef ETL_GCC_INCLUDED +#define ETL_GCC_INCLUDED //***************************************************************************** // GCC diff --git a/include/etl/profiles/msvc_x86.h b/include/etl/profiles/msvc_x86.h index 9bc6bdd9..37910922 100644 --- a/include/etl/profiles/msvc_x86.h +++ b/include/etl/profiles/msvc_x86.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MSVC__ -#define __ETL_MSVC__ +#ifndef ETL_MSVC_INCLUDED +#define ETL_MSVC_INCLUDED //***************************************************************************** // Microsoft Visual Studio diff --git a/include/etl/profiles/ticc.h b/include/etl/profiles/ticc.h index 132071ec..11a8b583 100644 --- a/include/etl/profiles/ticc.h +++ b/include/etl/profiles/ticc.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_TICC__ -#define __ETL_TICC__ +#ifndef ETL_TICC_INCLUDED +#define ETL_TICC_INCLUDED //***************************************************************************** // Texas Instruments Code Composer diff --git a/include/etl/queue.h b/include/etl/queue.h index 52265d67..bc2ae1a9 100644 --- a/include/etl/queue.h +++ b/include/etl/queue.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_QUEUE__ -#define __ETL_QUEUE__ +#ifndef ETL_QUEUE_INCLUDED +#define ETL_QUEUE_INCLUDED #include #include diff --git a/include/etl/queue_mpmc_mutex.h b/include/etl/queue_mpmc_mutex.h index d3426cb2..03ef4005 100644 --- a/include/etl/queue_mpmc_mutex.h +++ b/include/etl/queue_mpmc_mutex.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_MPMC_QUEUE_MUTEX__ -#define __ETL_MPMC_QUEUE_MUTEX__ +#ifndef ETL_MPMC_QUEUE_MUTEX_INCLUDED +#define ETL_MPMC_QUEUE_MUTEX_INCLUDED #include #include diff --git a/include/etl/queue_spsc_atomic.h b/include/etl/queue_spsc_atomic.h index a7f7e588..cc5e6f6d 100644 --- a/include/etl/queue_spsc_atomic.h +++ b/include/etl/queue_spsc_atomic.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_SPSC_QUEUE_ATOMIC__ -#define __ETL_SPSC_QUEUE_ATOMIC__ +#ifndef ETL_SPSC_QUEUE_ATOMIC_INCLUDED +#define ETL_SPSC_QUEUE_ATOMIC_INCLUDED #include #include diff --git a/include/etl/queue_spsc_isr.h b/include/etl/queue_spsc_isr.h index 68dfb9ec..b58333d6 100644 --- a/include/etl/queue_spsc_isr.h +++ b/include/etl/queue_spsc_isr.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_SPSC_QUEUE_ISR__ -#define __ETL_SPSC_QUEUE_ISR__ +#ifndef ETL_SPSC_QUEUE_ISR_INCLUDED +#define ETL_SPSC_QUEUE_ISR_INCLUDED #include #include diff --git a/include/etl/radix.h b/include/etl/radix.h index 2e830341..a4ba926b 100644 --- a/include/etl/radix.h +++ b/include/etl/radix.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_RADIX__ -#define __ETL_RADIX__ +#ifndef ETL_RADIX_INCLUDED +#define ETL_RADIX_INCLUDED #include diff --git a/include/etl/random.h b/include/etl/random.h index f47212f4..f94774f2 100644 --- a/include/etl/random.h +++ b/include/etl/random.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_RANDOM__ -#define __ETL_RANDOM__ +#ifndef ETL_RANDOM_INCLUDED +#define ETL_RANDOM_INCLUDED #include diff --git a/include/etl/reference_flat_map.h b/include/etl/reference_flat_map.h index 0963e77f..e76ccfd6 100644 --- a/include/etl/reference_flat_map.h +++ b/include/etl/reference_flat_map.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_REFERENCE_FLAT_MAP__ -#define __ETL_REFERENCE_FLAT_MAP__ +#ifndef ETL_REFERENCE_FLAT_MAP_INCLUDED +#define ETL_REFERENCE_FLAT_MAP_INCLUDED #include diff --git a/include/etl/reference_flat_multimap.h b/include/etl/reference_flat_multimap.h index 1b428e11..3088aa75 100644 --- a/include/etl/reference_flat_multimap.h +++ b/include/etl/reference_flat_multimap.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_REFERENCE_FLAT_MULTIMAP_BASE__ -#define __ETL_REFERENCE_FLAT_MULTIMAP_BASE__ +#ifndef ETL_REFERENCE_FLAT_MULTIMAP_BASE_INCLUDED +#define ETL_REFERENCE_FLAT_MULTIMAP_BASE_INCLUDED #include diff --git a/include/etl/reference_flat_multiset.h b/include/etl/reference_flat_multiset.h index bd72dc1e..4a502e65 100644 --- a/include/etl/reference_flat_multiset.h +++ b/include/etl/reference_flat_multiset.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_REFERENCE_FLAT_MULTISET__ -#define __ETL_REFERENCE_FLAT_MULTISET__ +#ifndef ETL_REFERENCE_FLAT_MULTISET_INCLUDED +#define ETL_REFERENCE_FLAT_MULTISET_INCLUDED #include #include diff --git a/include/etl/reference_flat_set.h b/include/etl/reference_flat_set.h index 3f4f7cb5..c7c866b8 100644 --- a/include/etl/reference_flat_set.h +++ b/include/etl/reference_flat_set.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_REFERENCE_FLAT_SET__ -#define __ETL_REFERENCE_FLAT_SET__ +#ifndef ETL_REFERENCE_FLAT_SET_INCLUDED +#define ETL_REFERENCE_FLAT_SET_INCLUDED #include #include diff --git a/include/etl/scheduler.h b/include/etl/scheduler.h index 3bbe8295..21085459 100644 --- a/include/etl/scheduler.h +++ b/include/etl/scheduler.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_SCHEDULER__ -#define __ETL_SCHEDULER__ +#ifndef ETL_SCHEDULER_INCLUDED +#define ETL_SCHEDULER_INCLUDED #include diff --git a/include/etl/set.h b/include/etl/set.h index 0db42f38..33d47f84 100644 --- a/include/etl/set.h +++ b/include/etl/set.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_SET__ -#define __ETL_SET__ +#ifndef ETL_SET_INCLUDED +#define ETL_SET_INCLUDED #include #include @@ -409,7 +409,7 @@ namespace etl //************************************************************************* void rotate_3node(Node*& position, uint_least8_t dir, uint_least8_t third) { - // __A__ __E__ __A__ __D__ + // --A-- --E-- --A-- --D-- // _B_ C -> B A OR B _C_ -> A C // D E D F G C D E B F G E // F G F G diff --git a/include/etl/smallest.h b/include/etl/smallest.h index f6c8c36c..33eaaf6a 100644 --- a/include/etl/smallest.h +++ b/include/etl/smallest.h @@ -50,8 +50,8 @@ SOFTWARE. // See generate.bat //*************************************************************************** -#ifndef __ETL_SMALLEST__ -#define __ETL_SMALLEST__ +#ifndef ETL_SMALLEST_INCLUDED +#define ETL_SMALLEST_INCLUDED #include @@ -132,7 +132,7 @@ namespace etl }; }; - namespace __private_smallest__ + namespace private_smallest { //************************************************************************* // Determine the type to hold the number of bits based on the index. @@ -237,7 +237,7 @@ namespace etl public: - typedef typename __private_smallest__::best_fit_uint_type::type type; + typedef typename private_smallest::best_fit_uint_type::type type; }; //*************************************************************************** @@ -258,7 +258,7 @@ namespace etl public: - typedef typename __private_smallest__::best_fit_int_type::type type; + typedef typename private_smallest::best_fit_int_type::type type; }; //*************************************************************************** @@ -279,7 +279,7 @@ namespace etl public: - typedef typename __private_smallest__::best_fit_uint_type::type type; + typedef typename private_smallest::best_fit_uint_type::type type; }; //*************************************************************************** @@ -300,7 +300,7 @@ namespace etl public: - typedef typename __private_smallest__::best_fit_int_type::type type; + typedef typename private_smallest::best_fit_int_type::type type; }; } diff --git a/include/etl/smallest_generator.h b/include/etl/smallest_generator.h index 99923b5e..45aaba94 100644 --- a/include/etl/smallest_generator.h +++ b/include/etl/smallest_generator.h @@ -62,8 +62,8 @@ cog.outl("//******************************************************************** // See generate.bat //*************************************************************************** -#ifndef __ETL_SMALLEST__ -#define __ETL_SMALLEST__ +#ifndef ETL_SMALLEST_INCLUDED +#define ETL_SMALLEST_INCLUDED #include @@ -162,7 +162,7 @@ namespace etl ]]]*/ /*[[[end]]]*/ - namespace __private_smallest__ + namespace private_smallest { //************************************************************************* // Determine the type to hold the number of bits based on the index. @@ -267,7 +267,7 @@ namespace etl public: - typedef typename __private_smallest__::best_fit_uint_type::type type; + typedef typename private_smallest::best_fit_uint_type::type type; }; //*************************************************************************** @@ -288,7 +288,7 @@ namespace etl public: - typedef typename __private_smallest__::best_fit_int_type::type type; + typedef typename private_smallest::best_fit_int_type::type type; }; //*************************************************************************** @@ -309,7 +309,7 @@ namespace etl public: - typedef typename __private_smallest__::best_fit_uint_type::type type; + typedef typename private_smallest::best_fit_uint_type::type type; }; //*************************************************************************** @@ -330,7 +330,7 @@ namespace etl public: - typedef typename __private_smallest__::best_fit_int_type::type type; + typedef typename private_smallest::best_fit_int_type::type type; }; } diff --git a/include/etl/sqrt.h b/include/etl/sqrt.h index cbfdb2ce..9fda08bf 100644 --- a/include/etl/sqrt.h +++ b/include/etl/sqrt.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_SQRT__ -#define __ETL_SQRT__ +#ifndef ETL_SQRT_INCLUDED +#define ETL_SQRT_INCLUDED #include diff --git a/include/etl/stack.h b/include/etl/stack.h index e4a36702..57e40dde 100644 --- a/include/etl/stack.h +++ b/include/etl/stack.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_STACK__ -#define __ETL_STACK__ +#ifndef ETL_STACK_INCLUDED +#define ETL_STACK_INCLUDED #include #include diff --git a/include/etl/static_assert.h b/include/etl/static_assert.h index f6f9e28b..af3d76a1 100644 --- a/include/etl/static_assert.h +++ b/include/etl/static_assert.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_STATIC_ASSERT__ -#define __ETL_STATIC_ASSERT__ +#ifndef ETL_STATIC_ASSERT_INCLUDED +#define ETL_STATIC_ASSERT_INCLUDED #include "platform.h" diff --git a/include/etl/string_view.h b/include/etl/string_view.h index c5e95603..0b376bb5 100644 --- a/include/etl/string_view.h +++ b/include/etl/string_view.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_STRING_VIEW__ -#define __ETL_STRING_VIEW__ +#ifndef ETL_STRING_VIEW_INCLUDED +#define ETL_STRING_VIEW_INCLUDED #include "platform.h" #include "memory.h" @@ -818,7 +818,7 @@ namespace etl { size_t operator()(const etl::string_view& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; @@ -828,7 +828,7 @@ namespace etl { size_t operator()(const etl::wstring_view& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; @@ -838,7 +838,7 @@ namespace etl { size_t operator()(const etl::u16string_view& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; @@ -848,7 +848,7 @@ namespace etl { size_t operator()(const etl::u32string_view& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; diff --git a/include/etl/task.h b/include/etl/task.h index 693575fe..1e25336d 100644 --- a/include/etl/task.h +++ b/include/etl/task.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_TASK__ -#define __ETL_TASK__ +#ifndef ETL_TASK_INCLUDED +#define ETL_TASK_INCLUDED #include diff --git a/include/etl/timer.h b/include/etl/timer.h index e91d1f5e..9fdc4bdb 100644 --- a/include/etl/timer.h +++ b/include/etl/timer.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_TIMER__ -#define __ETL_TIMER__ +#ifndef ETL_TIMER_INCLUDED +#define ETL_TIMER_INCLUDED #include diff --git a/include/etl/type_def.h b/include/etl/type_def.h index f3c0907d..15065525 100644 --- a/include/etl/type_def.h +++ b/include/etl/type_def.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_TYPE_DEF__ -#define __ETL_TYPE_DEF__ +#ifndef ETL_TYPE_DEF_INCLUDED +#define ETL_TYPE_DEF_INCLUDED #include "platform.h" diff --git a/include/etl/type_lookup.h b/include/etl/type_lookup.h index 994809db..7734f336 100644 --- a/include/etl/type_lookup.h +++ b/include/etl/type_lookup.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_TYPE_LOOKUP__ -#define __ETL_TYPE_LOOKUP__ +#ifndef ETL_TYPE_LOOKUP_INCLUDED +#define ETL_TYPE_LOOKUP_INCLUDED #include diff --git a/include/etl/type_lookup_generator.h b/include/etl/type_lookup_generator.h index da849c5b..7e0d5f6e 100644 --- a/include/etl/type_lookup_generator.h +++ b/include/etl/type_lookup_generator.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_TYPE_LOOKUP__ -#define __ETL_TYPE_LOOKUP__ +#ifndef ETL_TYPE_LOOKUP_INCLUDED +#define ETL_TYPE_LOOKUP_INCLUDED #include diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index 127ee6ee..a28a2065 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -50,8 +50,8 @@ SOFTWARE. // See generate.bat //*************************************************************************** -#ifndef __ETL_TYPE_TRAITS__ -#define __ETL_TYPE_TRAITS__ +#ifndef ETL_TYPE_TRAITS_INCLUDED +#define ETL_TYPE_TRAITS_INCLUDED #include #include diff --git a/include/etl/type_traits_generator.h b/include/etl/type_traits_generator.h index b4d488de..f8595b82 100644 --- a/include/etl/type_traits_generator.h +++ b/include/etl/type_traits_generator.h @@ -62,8 +62,8 @@ cog.outl("//******************************************************************** // See generate.bat //*************************************************************************** -#ifndef __ETL_TYPE_TRAITS__ -#define __ETL_TYPE_TRAITS__ +#ifndef ETL_TYPE_TRAITS_INCLUDED +#define ETL_TYPE_TRAITS_INCLUDED #include #include diff --git a/include/etl/u16string.h b/include/etl/u16string.h index b9d81f04..7380c786 100644 --- a/include/etl/u16string.h +++ b/include/etl/u16string.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_U16STRING__ -#define __ETL_U16STRING__ +#ifndef ETL_U16STRING_INCLUDED +#define ETL_U16STRING_INCLUDED #include "platform.h" #include "basic_string.h" @@ -214,7 +214,7 @@ namespace etl { size_t operator()(const etl::iu16string& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; @@ -224,7 +224,7 @@ namespace etl { size_t operator()(const etl::u16string& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; diff --git a/include/etl/u32string.h b/include/etl/u32string.h index 8df0ccd6..a1e2086d 100644 --- a/include/etl/u32string.h +++ b/include/etl/u32string.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_U32STRING__ -#define __ETL_U32STRING__ +#ifndef ETL_U32STRING_INCLUDED +#define ETL_U32STRING_INCLUDED #include "platform.h" #include "basic_string.h" @@ -214,7 +214,7 @@ namespace etl { size_t operator()(const etl::iu32string& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; @@ -224,7 +224,7 @@ namespace etl { size_t operator()(const etl::u32string& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; diff --git a/include/etl/unordered_map.h b/include/etl/unordered_map.h index c1d4d331..c5dd51e0 100644 --- a/include/etl/unordered_map.h +++ b/include/etl/unordered_map.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_UNORDERED_MAP__ -#define __ETL_UNORDERED_MAP__ +#ifndef ETL_UNORDERED_MAP_INCLUDED +#define ETL_UNORDERED_MAP_INCLUDED #include #include diff --git a/include/etl/unordered_multimap.h b/include/etl/unordered_multimap.h index ea8c5792..1bec644d 100644 --- a/include/etl/unordered_multimap.h +++ b/include/etl/unordered_multimap.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_UNORDERED_MULTIMAP__ -#define __ETL_UNORDERED_MULTIMAP__ +#ifndef ETL_UNORDERED_MULTIMAP_INCLUDED +#define ETL_UNORDERED_MULTIMAP_INCLUDED #include #include diff --git a/include/etl/unordered_multiset.h b/include/etl/unordered_multiset.h index 829849da..1301f40a 100644 --- a/include/etl/unordered_multiset.h +++ b/include/etl/unordered_multiset.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_UNORDERED_MULTISET__ -#define __ETL_UNORDERED_MULTISET__ +#ifndef ETL_UNORDERED_MULTISET_INCLUDED +#define ETL_UNORDERED_MULTISET_INCLUDED #include #include diff --git a/include/etl/unordered_set.h b/include/etl/unordered_set.h index 5cf2bc86..d1b7000f 100644 --- a/include/etl/unordered_set.h +++ b/include/etl/unordered_set.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_UNORDERED_SET__ -#define __ETL_UNORDERED_SET__ +#ifndef ETL_UNORDERED_SET_INCLUDED +#define ETL_UNORDERED_SET_INCLUDED #include #include diff --git a/include/etl/user_type.h b/include/etl/user_type.h index 49adae7b..5b7c3e32 100644 --- a/include/etl/user_type.h +++ b/include/etl/user_type.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_USER_TYPE__ -#define __ETL_USER_TYPE__ +#ifndef ETL_USER_TYPE_INCLUDED +#define ETL_USER_TYPE_INCLUDED #include "platform.h" diff --git a/include/etl/utility.h b/include/etl/utility.h index 8c96f1be..05e4a569 100644 --- a/include/etl/utility.h +++ b/include/etl/utility.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_UTILITY__ -#define __ETL_UTILITY__ +#ifndef ETL_UTILITY_INCLUDED +#define ETL_UTILITY_INCLUDED #include "platform.h" #include "type_traits.h" diff --git a/include/etl/variant.h b/include/etl/variant.h index 429ad708..72ae6950 100644 --- a/include/etl/variant.h +++ b/include/etl/variant.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_VARIANT__ -#define __ETL_VARIANT__ +#ifndef ETL_VARIANT_INCLUDED +#define ETL_VARIANT_INCLUDED #include @@ -59,7 +59,7 @@ SOFTWARE. namespace etl { - namespace __private_variant__ + namespace private_variant { //************************************************************************* /// Placeholder for unused template parameters. @@ -103,13 +103,13 @@ namespace etl ///\ingroup variant //*************************************************************************** template , - typename T3 = __private_variant__::no_type<3>, - typename T4 = __private_variant__::no_type<4>, - typename T5 = __private_variant__::no_type<5>, - typename T6 = __private_variant__::no_type<6>, - typename T7 = __private_variant__::no_type<7>, - typename T8 = __private_variant__::no_type<8> > + typename T2 = private_variant::no_type<2>, + typename T3 = private_variant::no_type<3>, + typename T4 = private_variant::no_type<4>, + typename T5 = private_variant::no_type<5>, + typename T6 = private_variant::no_type<6>, + typename T7 = private_variant::no_type<7>, + typename T8 = private_variant::no_type<8> > class variant { public: @@ -148,13 +148,13 @@ namespace etl //*************************************************************************** /// Short form of no_type placeholders. //*************************************************************************** - typedef __private_variant__::no_type<2> no_type2; - typedef __private_variant__::no_type<3> no_type3; - typedef __private_variant__::no_type<4> no_type4; - typedef __private_variant__::no_type<5> no_type5; - typedef __private_variant__::no_type<6> no_type6; - typedef __private_variant__::no_type<7> no_type7; - typedef __private_variant__::no_type<8> no_type8; + typedef private_variant::no_type<2> no_type2; + typedef private_variant::no_type<3> no_type3; + typedef private_variant::no_type<4> no_type4; + typedef private_variant::no_type<5> no_type5; + typedef private_variant::no_type<6> no_type6; + typedef private_variant::no_type<7> no_type7; + typedef private_variant::no_type<8> no_type8; //*************************************************************************** /// Lookup the id of type. diff --git a/include/etl/variant_pool.h b/include/etl/variant_pool.h index 55e1a45a..c08dac50 100644 --- a/include/etl/variant_pool.h +++ b/include/etl/variant_pool.h @@ -48,8 +48,8 @@ SOFTWARE. // See generate.bat //*************************************************************************** -#ifndef __ETL_VARIANT_POOL__ -#define __ETL_VARIANT_POOL__ +#ifndef ETL_VARIANT_POOL_INCLUDED +#define ETL_VARIANT_POOL_INCLUDED #include #include diff --git a/include/etl/variant_pool_generator.h b/include/etl/variant_pool_generator.h index 6ca24891..45baf9fb 100644 --- a/include/etl/variant_pool_generator.h +++ b/include/etl/variant_pool_generator.h @@ -60,8 +60,8 @@ cog.outl("//******************************************************************** // See generate.bat //*************************************************************************** -#ifndef __ETL_VARIANT_POOL__ -#define __ETL_VARIANT_POOL__ +#ifndef ETL_VARIANT_POOL_INCLUDED +#define ETL_VARIANT_POOL_INCLUDED #include #include diff --git a/include/etl/vector.h b/include/etl/vector.h index 4a7a9e73..78be2370 100644 --- a/include/etl/vector.h +++ b/include/etl/vector.h @@ -28,10 +28,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_VECTOR__ -#define __ETL_VECTOR__ +#ifndef ETL_VECTOR_INCLUDED +#define ETL_VECTOR_INCLUDED -#define __ETL_IN_VECTOR_H__ +#define ETL_IN_VECTOR_H #include #include diff --git a/include/etl/version.h b/include/etl/version.h index 56981517..74abd073 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_VERSION__ -#define __ETL_VERSION__ +#ifndef ETL_VERSION_INCLUDED +#define ETL_VERSION_INCLUDED #include diff --git a/include/etl/visitor.h b/include/etl/visitor.h index b6c412d0..70e58252 100644 --- a/include/etl/visitor.h +++ b/include/etl/visitor.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_VISITOR__ -#define __ETL_VISITOR__ +#ifndef ETL_VISITOR_INCLUDED +#define ETL_VISITOR_INCLUDED #include "platform.h" diff --git a/include/etl/wstring.h b/include/etl/wstring.h index 7a2a94ce..8c7f8251 100644 --- a/include/etl/wstring.h +++ b/include/etl/wstring.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_WSTRING__ -#define __ETL_WSTRING__ +#ifndef ETL_WSTRING_INCLUDED +#define ETL_WSTRING_INCLUDED #include "platform.h" #include "basic_string.h" @@ -215,7 +215,7 @@ namespace etl { size_t operator()(const etl::iwstring& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; @@ -225,7 +225,7 @@ namespace etl { size_t operator()(const etl::wstring& text) const { - return etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), + return etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); } }; diff --git a/test/data.h b/test/data.h index 9db25ab4..0fbf9ed6 100644 --- a/test/data.h +++ b/test/data.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __test_data__ -#define __test_data__ +#ifndef ETL_TEST_DATA_INCLUDED +#define ETL_TEST_DATA_INCLUDED #include diff --git a/test/ecl_user.h b/test/ecl_user.h index 418bdee9..cc2c8f03 100644 --- a/test/ecl_user.h +++ b/test/ecl_user.h @@ -26,8 +26,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ECL_USER__ -#define __ECL_USER__ +#ifndef ECL_USER_INCLUDED +#define ECL_USER_INCLUDED #include diff --git a/test/etl_profile.h b/test/etl_profile.h index d2f02616..96636ff8 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef __ETL_PROFILE_H__ -#define __ETL_PROFILE_H__ +#ifndef ETL_PROFILE_H_INCLUDED +#define ETL_PROFILE_H_INCLUDED #define ETL_THROW_EXCEPTIONS #define ETL_VERBOSE_ERRORS diff --git a/test/test_array_view.cpp b/test/test_array_view.cpp index 9574cd23..875b4bb7 100644 --- a/test/test_array_view.cpp +++ b/test/test_array_view.cpp @@ -604,7 +604,7 @@ namespace View view(etldata.begin(), etldata.end()); CView cview(etldata.begin(), etldata.end()); - size_t hashdata = etl::__private_hash__::generic_hash(reinterpret_cast(&etldata[0]), + size_t hashdata = etl::private_hash::generic_hash(reinterpret_cast(&etldata[0]), reinterpret_cast(&etldata[etldata.size()])); size_t hashview = etl::hash()(view); diff --git a/test/test_array_wrapper.cpp b/test/test_array_wrapper.cpp index c084f72c..b803575a 100644 --- a/test/test_array_wrapper.cpp +++ b/test/test_array_wrapper.cpp @@ -559,7 +559,7 @@ namespace size_t hash = etl::hash()(aw5); - size_t compare_hash = etl::__private_hash__::generic_hash(reinterpret_cast(&data5[0]), reinterpret_cast(&data5[5])); + size_t compare_hash = etl::private_hash::generic_hash(reinterpret_cast(&data5[0]), reinterpret_cast(&data5[5])); CHECK_EQUAL(compare_hash, hash); diff --git a/test/test_string_char.cpp b/test/test_string_char.cpp index bcf1f356..9d0404f0 100644 --- a/test/test_string_char.cpp +++ b/test/test_string_char.cpp @@ -3032,7 +3032,7 @@ namespace // Test with actual string type. Text text(STR("ABCDEFHIJKL")); size_t hash = etl::hash()(text); - size_t compare_hash = etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); + size_t compare_hash = etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); CHECK_EQUAL(compare_hash, hash); // Test with interface string type. diff --git a/test/test_string_u16.cpp b/test/test_string_u16.cpp index 0d1a2e5d..6d23555c 100644 --- a/test/test_string_u16.cpp +++ b/test/test_string_u16.cpp @@ -3031,7 +3031,7 @@ namespace // Test with actual string type. Text text(STR("ABCDEFHIJKL")); size_t hash = etl::hash()(text); - size_t compare_hash = etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); + size_t compare_hash = etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); CHECK_EQUAL(compare_hash, hash); // Test with interface string type. diff --git a/test/test_string_u32.cpp b/test/test_string_u32.cpp index eb4db72f..8a608d4f 100644 --- a/test/test_string_u32.cpp +++ b/test/test_string_u32.cpp @@ -3031,7 +3031,7 @@ namespace // Test with actual string type. Text text(STR("ABCDEFHIJKL")); size_t hash = etl::hash()(text); - size_t compare_hash = etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); + size_t compare_hash = etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); CHECK_EQUAL(compare_hash, hash); // Test with interface string type. diff --git a/test/test_string_wchar_t.cpp b/test/test_string_wchar_t.cpp index 47e8ce9f..c0c28a98 100644 --- a/test/test_string_wchar_t.cpp +++ b/test/test_string_wchar_t.cpp @@ -3031,7 +3031,7 @@ namespace // Test with actual string type. Text text(STR("ABCDEFHIJKL")); size_t hash = etl::hash()(text); - size_t compare_hash = etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); + size_t compare_hash = etl::private_hash::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); CHECK_EQUAL(compare_hash, hash); // Test with interface string type. From a0f2f8bf8eb9b58d17a7a05f629abdad06a223ce Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 21 Apr 2018 17:31:59 +0100 Subject: [PATCH 03/14] Added null_type template --- include/etl/null_type.h | 50 ++++++++++++ include/etl/type_lookup.h | 117 ++++++++++++++-------------- include/etl/type_lookup_generator.h | 25 +++--- 3 files changed, 120 insertions(+), 72 deletions(-) create mode 100644 include/etl/null_type.h diff --git a/include/etl/null_type.h b/include/etl/null_type.h new file mode 100644 index 00000000..6b610ced --- /dev/null +++ b/include/etl/null_type.h @@ -0,0 +1,50 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_NULL_TYPE_INCLUDED +#define ETL_NULL_TYPE_INCLUDED + +#undef ETL_FILE +#define ETL_FILE "50" + +namespace etl +{ + template + class null_type + { + private: + + null_type(); + null_type(const null_type&); + null_type& operator=(const null_type&); + }; +} + +#undef ETL_FILE + +#endif diff --git a/include/etl/type_lookup.h b/include/etl/type_lookup.h index 7734f336..30e4932e 100644 --- a/include/etl/type_lookup.h +++ b/include/etl/type_lookup.h @@ -34,6 +34,7 @@ SOFTWARE. #include "platform.h" #include "type_traits.h" #include "static_assert.h" +#include "null_type.h" #undef ETL_FILE #define ETL_FILE "45" @@ -43,13 +44,11 @@ SOFTWARE. #endif //*************************************************************************** -// This file has been auto generated. Do not edit this file. +// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE. //*************************************************************************** namespace etl { - struct null_type {}; - //*************************************************************************** /// The type/id pair type to use for type/id lookup template parameters. //*************************************************************************** @@ -78,21 +77,21 @@ namespace etl // For 16 types. //*************************************************************************** template , - typename T3 = etl::type_id_pair, - typename T4 = etl::type_id_pair, - typename T5 = etl::type_id_pair, - typename T6 = etl::type_id_pair, - typename T7 = etl::type_id_pair, - typename T8 = etl::type_id_pair, - typename T9 = etl::type_id_pair, - typename T10 = etl::type_id_pair, - typename T11 = etl::type_id_pair, - typename T12 = etl::type_id_pair, - typename T13 = etl::type_id_pair, - typename T14 = etl::type_id_pair, - typename T15 = etl::type_id_pair, - typename T16 = etl::type_id_pair > + typename T2 = etl::type_id_pair, -2>, + typename T3 = etl::type_id_pair, -3>, + typename T4 = etl::type_id_pair, -4>, + typename T5 = etl::type_id_pair, -5>, + typename T6 = etl::type_id_pair, -6>, + typename T7 = etl::type_id_pair, -7>, + typename T8 = etl::type_id_pair, -8>, + typename T9 = etl::type_id_pair, -9>, + typename T10 = etl::type_id_pair, -10>, + typename T11 = etl::type_id_pair, -11>, + typename T12 = etl::type_id_pair, -12>, + typename T13 = etl::type_id_pair, -13>, + typename T14 = etl::type_id_pair, -14>, + typename T15 = etl::type_id_pair, -15>, + typename T16 = etl::type_id_pair, -16> > struct type_id_lookup { public: @@ -101,7 +100,7 @@ namespace etl template struct type_from_id { - typedef + typedef typename etl::conditional::type>::type>::type>::type> - ::type>::type>::type>::type> - ::type>::type>::type>::type> - ::type>::type>::type>::type type; + etl::null_type<0>>::type>::type>::type>::type> + ::type>::type>::type>::type> + ::type>::type>::type>::type> + ::type>::type>::type>::type type; - STATIC_ASSERT(!(etl::is_same::value), "Invalid id"); + STATIC_ASSERT(!(etl::is_same, type>::value), "Invalid id"); }; //************************************ @@ -138,22 +137,22 @@ namespace etl enum { value = - (unsigned int) etl::is_same::value ? (unsigned int)T1::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T2::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T3::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T4::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T5::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T6::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T7::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T8::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T9::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T10::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T11::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T12::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T13::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T14::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T15::ID : - (unsigned int) etl::is_same::value ? (unsigned int)T16::ID : + (unsigned int) etl::is_same::value ? T1::ID : + (unsigned int) etl::is_same::value ? T2::ID : + (unsigned int) etl::is_same::value ? T3::ID : + (unsigned int) etl::is_same::value ? T4::ID : + (unsigned int) etl::is_same::value ? T5::ID : + (unsigned int) etl::is_same::value ? T6::ID : + (unsigned int) etl::is_same::value ? T7::ID : + (unsigned int) etl::is_same::value ? T8::ID : + (unsigned int) etl::is_same::value ? T9::ID : + (unsigned int) etl::is_same::value ? T10::ID : + (unsigned int) etl::is_same::value ? T11::ID : + (unsigned int) etl::is_same::value ? T12::ID : + (unsigned int) etl::is_same::value ? T13::ID : + (unsigned int) etl::is_same::value ? T14::ID : + (unsigned int) etl::is_same::value ? T15::ID : + (unsigned int) etl::is_same::value ? T16::ID : (unsigned int) UNKNOWN }; @@ -179,21 +178,21 @@ namespace etl // For 16 types. //*************************************************************************** template , - typename T3 = etl::type_type_pair, - typename T4 = etl::type_type_pair, - typename T5 = etl::type_type_pair, - typename T6 = etl::type_type_pair, - typename T7 = etl::type_type_pair, - typename T8 = etl::type_type_pair, - typename T9 = etl::type_type_pair, - typename T10 = etl::type_type_pair, - typename T11 = etl::type_type_pair, - typename T12 = etl::type_type_pair, - typename T13 = etl::type_type_pair, - typename T14 = etl::type_type_pair, - typename T15 = etl::type_type_pair, - typename T16 = etl::type_type_pair > + typename T2 = etl::type_type_pair, etl::null_type<0>>, + typename T3 = etl::type_type_pair, etl::null_type<0>>, + typename T4 = etl::type_type_pair, etl::null_type<0>>, + typename T5 = etl::type_type_pair, etl::null_type<0>>, + typename T6 = etl::type_type_pair, etl::null_type<0>>, + typename T7 = etl::type_type_pair, etl::null_type<0>>, + typename T8 = etl::type_type_pair, etl::null_type<0>>, + typename T9 = etl::type_type_pair, etl::null_type<0>>, + typename T10 = etl::type_type_pair, etl::null_type<0>>, + typename T11 = etl::type_type_pair, etl::null_type<0>>, + typename T12 = etl::type_type_pair, etl::null_type<0>>, + typename T13 = etl::type_type_pair, etl::null_type<0>>, + typename T14 = etl::type_type_pair, etl::null_type<0>>, + typename T15 = etl::type_type_pair, etl::null_type<0>>, + typename T16 = etl::type_type_pair, etl::null_type<0>> > struct type_type_lookup { public: @@ -202,7 +201,7 @@ namespace etl template struct type_from_type { - typedef + typedef typename etl::conditional::value, typename T1::type2, typename etl::conditional::value, typename T2::type2, typename etl::conditional::value, typename T3::type2, @@ -219,10 +218,10 @@ namespace etl typename etl::conditional::value, typename T14::type2, typename etl::conditional::value, typename T15::type2, typename etl::conditional::value, typename T16::type2, - etl::null_type>::type>::type>::type>::type>::type>::type>::type>::type> - ::type>::type>::type>::type>::type>::type>::type>::type type; + etl::null_type<0>>::type>::type>::type>::type>::type>::type>::type>::type> + ::type>::type>::type>::type>::type>::type>::type>::type type; - STATIC_ASSERT(!(etl::is_same::value), "Invalid type"); + STATIC_ASSERT(!(etl::is_same, type>::value), "Invalid type"); }; }; } diff --git a/include/etl/type_lookup_generator.h b/include/etl/type_lookup_generator.h index 7e0d5f6e..398773bd 100644 --- a/include/etl/type_lookup_generator.h +++ b/include/etl/type_lookup_generator.h @@ -34,6 +34,7 @@ SOFTWARE. #include "platform.h" #include "type_traits.h" #include "static_assert.h" +#include "null_type.h" #undef ETL_FILE #define ETL_FILE "45" @@ -53,15 +54,13 @@ cog.outl("#endif") /*[[[cog import cog cog.outl("//***************************************************************************") -cog.outl("// This file has been auto generated. Do not edit this file.") +cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.") cog.outl("//***************************************************************************") ]]]*/ /*[[[end]]]*/ namespace etl { - struct null_type {}; - //*************************************************************************** /// The type/id pair type to use for type/id lookup template parameters. //*************************************************************************** @@ -93,8 +92,8 @@ namespace etl cog.outl("//***************************************************************************") cog.outl("template ," %(n, n)) - cog.outl(" typename T%s = etl::type_id_pair >" %(NTypes, NTypes)) + cog.outl(" typename T%s = etl::type_id_pair, -%s>," %(n, n)) + cog.outl(" typename T%s = etl::type_id_pair, -%s> >" %(NTypes, NTypes)) cog.outl("struct type_id_lookup") cog.outl("{") cog.outl("public:") @@ -106,7 +105,7 @@ namespace etl cog.outl(" typedef ") for n in range(1, int(NTypes) + 1): cog.outl(" typename etl::conditional") + cog.out(" etl::null_type<0>>") for n in range(1, int(NTypes) + 1): if n == int(NTypes): cog.outl("::type type;") @@ -115,9 +114,9 @@ namespace etl if n % 4 == 0: if n != int(NTypes): cog.outl("") - cog.out(" ") + cog.out(" ") cog.outl("") - cog.outl(" STATIC_ASSERT(!(etl::is_same::value), \"Invalid id\");") + cog.outl(" STATIC_ASSERT(!(etl::is_same, type>::value), \"Invalid id\");") cog.outl(" };") cog.outl("") cog.outl(" //************************************") @@ -160,8 +159,8 @@ namespace etl cog.outl("//***************************************************************************") cog.outl("template ," %n) - cog.outl(" typename T%s = etl::type_type_pair >" %NTypes) + cog.outl(" typename T%s = etl::type_type_pair, etl::null_type<0>>," %n) + cog.outl(" typename T%s = etl::type_type_pair, etl::null_type<0>> >" %NTypes) cog.outl("struct type_type_lookup") cog.outl("{") cog.outl("public:") @@ -173,7 +172,7 @@ namespace etl cog.outl(" typedef ") for n in range(1, int(NTypes) + 1): cog.outl(" typename etl::conditional::value, typename T%s::type2," %(n, n)) - cog.out(" etl::null_type>") + cog.out(" etl::null_type<0>>") for n in range(1, int(NTypes) + 1): if n == int(NTypes): cog.outl("::type type;") @@ -182,9 +181,9 @@ namespace etl if n % 8 == 0: if n != int(NTypes): cog.outl("") - cog.out(" ") + cog.out(" ") cog.outl("") - cog.outl(" STATIC_ASSERT(!(etl::is_same::value), \"Invalid type\");") + cog.outl(" STATIC_ASSERT(!(etl::is_same, type>::value), \"Invalid type\");") cog.outl(" };") cog.outl("};") ]]]*/ From 48ede3fdbef4b5050edf31a8be9b126a2bbefee9 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 21 Apr 2018 17:45:00 +0100 Subject: [PATCH 04/14] Capitalised warning comment --- include/etl/fsm_generator.h | 2 +- include/etl/largest_generator.h | 2 +- include/etl/message_router_generator.h | 2 +- include/etl/smallest_generator.h | 2 +- include/etl/type_traits_generator.h | 2 +- include/etl/variant_pool_generator.h | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/etl/fsm_generator.h b/include/etl/fsm_generator.h index a6f9fbcb..63eb4f75 100644 --- a/include/etl/fsm_generator.h +++ b/include/etl/fsm_generator.h @@ -41,7 +41,7 @@ cog.outl("#endif") /*[[[cog import cog cog.outl("//***************************************************************************") -cog.outl("// This file has been auto generated. Do not edit this file.") +cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.") cog.outl("//***************************************************************************") ]]]*/ /*[[[end]]]*/ diff --git a/include/etl/largest_generator.h b/include/etl/largest_generator.h index f73661ed..7ac3db53 100644 --- a/include/etl/largest_generator.h +++ b/include/etl/largest_generator.h @@ -43,7 +43,7 @@ cog.outl("#endif") /*[[[cog import cog cog.outl("//***************************************************************************") -cog.outl("// This file has been auto generated. Do not edit this file.") +cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.") cog.outl("//***************************************************************************") ]]]*/ /*[[[end]]]*/ diff --git a/include/etl/message_router_generator.h b/include/etl/message_router_generator.h index 989a1619..cc503cca 100644 --- a/include/etl/message_router_generator.h +++ b/include/etl/message_router_generator.h @@ -41,7 +41,7 @@ cog.outl("#endif") /*[[[cog import cog cog.outl("//***************************************************************************") -cog.outl("// This file has been auto generated. Do not edit this file.") +cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.") cog.outl("//***************************************************************************") ]]]*/ /*[[[end]]]*/ diff --git a/include/etl/smallest_generator.h b/include/etl/smallest_generator.h index 45aaba94..dcc955a2 100644 --- a/include/etl/smallest_generator.h +++ b/include/etl/smallest_generator.h @@ -43,7 +43,7 @@ cog.outl("#endif") /*[[[cog import cog cog.outl("//***************************************************************************") -cog.outl("// This file has been auto generated. Do not edit this file.") +cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.") cog.outl("//***************************************************************************") ]]]*/ /*[[[end]]]*/ diff --git a/include/etl/type_traits_generator.h b/include/etl/type_traits_generator.h index f8595b82..c993d746 100644 --- a/include/etl/type_traits_generator.h +++ b/include/etl/type_traits_generator.h @@ -43,7 +43,7 @@ cog.outl("#endif") /*[[[cog import cog cog.outl("//***************************************************************************") -cog.outl("// This file has been auto generated. Do not edit this file.") +cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.") cog.outl("//***************************************************************************") ]]]*/ /*[[[end]]]*/ diff --git a/include/etl/variant_pool_generator.h b/include/etl/variant_pool_generator.h index 45baf9fb..5c117bdf 100644 --- a/include/etl/variant_pool_generator.h +++ b/include/etl/variant_pool_generator.h @@ -41,7 +41,7 @@ cog.outl("#endif") /*[[[cog import cog cog.outl("//***************************************************************************") -cog.outl("// This file has been auto generated. Do not edit this file.") +cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.") cog.outl("//***************************************************************************") ]]]*/ /*[[[end]]]*/ From 67a32df7d0d916dcce84778b03e015faf242d2af Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 21 Apr 2018 17:45:34 +0100 Subject: [PATCH 05/14] Added etl::type_select --- include/etl/file_error_numbers.txt | 1 + include/etl/generate.bat | 3 +- include/etl/generate_type_select.bat | 1 + include/etl/type_select.h | 590 +++++++++++++++++++++++++++ include/etl/type_select_generator.h | 134 ++++++ test/codeblocks/ETL.cbp | 2 + test/test_type_select.cpp | 116 ++++++ test/vs2017/etl.vcxproj | 4 + test/vs2017/etl.vcxproj.filters | 12 + 9 files changed, 862 insertions(+), 1 deletion(-) create mode 100644 include/etl/generate_type_select.bat create mode 100644 include/etl/type_select.h create mode 100644 include/etl/type_select_generator.h create mode 100644 test/test_type_select.cpp diff --git a/include/etl/file_error_numbers.txt b/include/etl/file_error_numbers.txt index 7680234f..40d89b45 100644 --- a/include/etl/file_error_numbers.txt +++ b/include/etl/file_error_numbers.txt @@ -46,3 +46,4 @@ 46 queue_spsc_isr 47 queue_spsc_atomic 48 queue_mpmc_mutex +49 type_select \ No newline at end of file diff --git a/include/etl/generate.bat b/include/etl/generate.bat index 3c6eea14..c121da9f 100644 --- a/include/etl/generate.bat +++ b/include/etl/generate.bat @@ -3,4 +3,5 @@ python -m cogapp -d -e -omessage_router.h -DHandlers=16 message_router_generator python -m cogapp -d -e -olargest.h -DNTypes=16 largest_generator.h python -m cogapp -d -e -osmallest.h -DNTypes=16 smallest_generator.h python -m cogapp -d -e -otype_traits.h -DIsOneOf=17 type_traits_generator.h -python -m cogapp -d -e -otype_lookup.h -DNTypes=16 type_lookup_generator.h \ No newline at end of file +python -m cogapp -d -e -otype_lookup.h -DNTypes=16 type_lookup_generator.h +python -m cogapp -d -e -otype_select.h -DNTypes=16 type_select_generator.h \ No newline at end of file diff --git a/include/etl/generate_type_select.bat b/include/etl/generate_type_select.bat new file mode 100644 index 00000000..89706ac8 --- /dev/null +++ b/include/etl/generate_type_select.bat @@ -0,0 +1 @@ +python -m cogapp -d -e -otype_select.h -DNTypes=16 type_select_generator.h diff --git a/include/etl/type_select.h b/include/etl/type_select.h new file mode 100644 index 00000000..52c8f5f5 --- /dev/null +++ b/include/etl/type_select.h @@ -0,0 +1,590 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_TYPE_SELECT_INCLUDED +#define ETL_TYPE_SELECT_INCLUDED + +#include "platform.h" +#include "static_assert.h" +#include "type_traits.h" +#include "null_type.h" + +#undef ETL_FILE +#define ETL_FILE "49" + +#if 0 +#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE. +#endif + +//*************************************************************************** +// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE. +//*************************************************************************** + +namespace etl +{ + //*************************************************************************** + // For 16 types. + //*************************************************************************** + template + struct type_select + { + public: + + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type>::type> + ::type>::type>::type>::type>::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 16, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 15 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type>::type> + ::type>::type>::type>::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 15, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 14 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type>::type> + ::type>::type>::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 14, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 13 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type>::type> + ::type>::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 13, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 12 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type>::type> + ::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 12, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 11 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type>::type> + ::type>::type>::type type; + + STATIC_ASSERT(ID < 11, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 10 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type>::type> + ::type>::type type; + + STATIC_ASSERT(ID < 10, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 9 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type>::type> + ::type type; + + STATIC_ASSERT(ID < 9, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 8 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 8, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 7 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 7, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 6 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 6, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 5 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 5, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 4 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type>::type type; + + STATIC_ASSERT(ID < 4, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 3 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type>::type type; + + STATIC_ASSERT(ID < 3, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 2 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type>::type type; + + STATIC_ASSERT(ID < 2, "Invalid ID"); + }; + }; + + //*************************************************************************** + // For 1 types. + //*************************************************************************** + template + struct type_select + { + public: + template + struct select + { + typedef typename etl::conditional > + ::type type; + + STATIC_ASSERT(ID < 1, "Invalid ID"); + }; + }; +} + +#undef ETL_FILE + +#endif diff --git a/include/etl/type_select_generator.h b/include/etl/type_select_generator.h new file mode 100644 index 00000000..e804360b --- /dev/null +++ b/include/etl/type_select_generator.h @@ -0,0 +1,134 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_TYPE_SELECT_INCLUDED +#define ETL_TYPE_SELECT_INCLUDED + +#include "platform.h" +#include "static_assert.h" +#include "type_traits.h" +#include "null_type.h" + +#undef ETL_FILE +#define ETL_FILE "49" + +/*[[[cog +import cog +cog.outl("#if 0") +]]]*/ +/*[[[end]]]*/ +#error THIS HEADER IS A GENERATOR. DO NOT INCLUDE. +/*[[[cog +import cog +cog.outl("#endif") +]]]*/ +/*[[[end]]]*/ + +/*[[[cog +import cog +cog.outl("//***************************************************************************") +cog.outl("// THIS FILE HAS BEEN AUTO GENERATED. DO NOT EDIT THIS FILE.") +cog.outl("//***************************************************************************") +]]]*/ +/*[[[end]]]*/ + +namespace etl +{ + /*[[[cog + import cog + cog.outl("//***************************************************************************") + cog.outl("// For %s types." % int(NTypes)) + cog.outl("//***************************************************************************") + cog.outl("template " %(int(NTypes) - 1)) + cog.outl("struct type_select") + cog.outl("{") + cog.outl("public:") + cog.outl("") + cog.outl(" template ") + cog.outl(" struct select") + cog.outl(" {") + cog.outl(" typedef typename etl::conditional >") + cog.out(" ") + for n in range(1, int(NTypes)) : + cog.out("::type>") + if n % 8 == 0: + cog.outl("") + cog.out(" ") + cog.outl("::type type;") + cog.outl(""); + cog.outl(" STATIC_ASSERT(ID < %s, \"Invalid ID\");" % int(NTypes)); + cog.outl(" };") + cog.outl("};") + + for s in range(int(NTypes) - 1, 0, -1): + cog.outl("") + cog.outl("//***************************************************************************") + cog.outl("// For %s types." % int(s)) + cog.outl("//***************************************************************************") + cog.out("template <") + for n in range(0, s - 1): + cog.outl("typename T%s, " % n) + cog.out(" ") + cog.outl("typename T%s>" % (s - 1)) + cog.out("struct type_select<") + for n in range(0, s - 1): + cog.out("T%s, " % n) + cog.outl("T%s>" % (s - 1)) + cog.outl("{") + cog.outl("public:") + cog.outl(" template ") + cog.outl(" struct select") + cog.outl(" {") + cog.outl(" typedef typename etl::conditional >") + cog.out(" ") + for n in range(1, s) : + cog.out("::type>") + if n % 8 == 0: + cog.outl("") + cog.out(" ") + cog.outl("::type type;") + cog.outl(""); + cog.outl(" STATIC_ASSERT(ID < %s, \"Invalid ID\");" % s); + cog.outl(" };") + cog.outl("};") + ]]]*/ + /*[[[end]]]*/ +} + +#undef ETL_FILE + +#endif diff --git a/test/codeblocks/ETL.cbp b/test/codeblocks/ETL.cbp index 69583f71..454afa4e 100644 --- a/test/codeblocks/ETL.cbp +++ b/test/codeblocks/ETL.cbp @@ -213,6 +213,7 @@ + @@ -406,6 +407,7 @@ + diff --git a/test/test_type_select.cpp b/test/test_type_select.cpp new file mode 100644 index 00000000..7ea7ecff --- /dev/null +++ b/test/test_type_select.cpp @@ -0,0 +1,116 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +http://www.etlcpp.com + +Copyright(c) 2018 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. +******************************************************************************/ + +#include "UnitTest++.h" +#include "ExtraCheckMacros.h" + +#include "type_select.h" +#include "null_type.h" + +#include + +namespace +{ + typedef etl::type_select> Types1; + + typedef etl::type_select, etl::null_type<1>, etl::null_type<2>, etl::null_type<3>, + etl::null_type<4>, etl::null_type<5>, etl::null_type<6>, etl::null_type<7>> Types8; + + typedef etl::type_select, etl::null_type<1>, etl::null_type<2>, etl::null_type<3>, + etl::null_type<4>, etl::null_type<5>, etl::null_type<6>, etl::null_type<7>, + etl::null_type<8>, etl::null_type<9>, etl::null_type<10>, etl::null_type<11>, + etl::null_type<12>, etl::null_type<13>, etl::null_type<14>, etl::null_type<15>> Types16; + + SUITE(test_type_lookup) + { + //************************************************************************* + TEST(test_type_select1) + { + CHECK((std::is_same, typename Types1::select<0>::type>::value)); + CHECK(!(std::is_same, typename Types1::select<0>::type>::value)); + } + + //************************************************************************* + TEST(test_type_select8) + { + CHECK((std::is_same, typename Types8::select<0>::type>::value)); + CHECK(!(std::is_same, typename Types8::select<0>::type>::value)); + CHECK((std::is_same, typename Types8::select<1>::type>::value)); + CHECK(!(std::is_same, typename Types8::select<1>::type>::value)); + CHECK((std::is_same, typename Types8::select<2>::type>::value)); + CHECK(!(std::is_same, typename Types8::select<2>::type>::value)); + CHECK((std::is_same, typename Types8::select<3>::type>::value)); + CHECK(!(std::is_same, typename Types8::select<3>::type>::value)); + CHECK((std::is_same, typename Types8::select<4>::type>::value)); + CHECK(!(std::is_same, typename Types8::select<4>::type>::value)); + CHECK((std::is_same, typename Types8::select<5>::type>::value)); + CHECK(!(std::is_same, typename Types8::select<5>::type>::value)); + CHECK((std::is_same, typename Types8::select<6>::type>::value)); + CHECK(!(std::is_same, typename Types8::select<6>::type>::value)); + CHECK((std::is_same, typename Types8::select<7>::type>::value)); + CHECK(!(std::is_same, typename Types8::select<7>::type>::value)); + } + + //************************************************************************* + TEST(test_type_select16) + { + CHECK((std::is_same, typename Types16::select<0>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<0>::type>::value)); + CHECK((std::is_same, typename Types16::select<1>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<1>::type>::value)); + CHECK((std::is_same, typename Types16::select<2>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<2>::type>::value)); + CHECK((std::is_same, typename Types16::select<3>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<3>::type>::value)); + CHECK((std::is_same, typename Types16::select<4>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<4>::type>::value)); + CHECK((std::is_same, typename Types16::select<5>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<5>::type>::value)); + CHECK((std::is_same, typename Types16::select<6>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<6>::type>::value)); + CHECK((std::is_same, typename Types16::select<7>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<7>::type>::value)); + CHECK((std::is_same, typename Types16::select<8>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<8>::type>::value)); + CHECK((std::is_same, typename Types16::select<9>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<9>::type>::value)); + CHECK((std::is_same, typename Types16::select<10>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<10>::type>::value)); + CHECK((std::is_same, typename Types16::select<11>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<11>::type>::value)); + CHECK((std::is_same, typename Types16::select<12>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<12>::type>::value)); + CHECK((std::is_same, typename Types16::select<13>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<13>::type>::value)); + CHECK((std::is_same, typename Types16::select<14>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<14>::type>::value)); + CHECK((std::is_same, typename Types16::select<15>::type>::value)); + CHECK(!(std::is_same, typename Types16::select<15>::type>::value)); + } + }; +} diff --git a/test/vs2017/etl.vcxproj b/test/vs2017/etl.vcxproj index 87c633a5..767c9004 100644 --- a/test/vs2017/etl.vcxproj +++ b/test/vs2017/etl.vcxproj @@ -371,6 +371,8 @@ + + @@ -702,6 +704,7 @@ + @@ -722,6 +725,7 @@ + diff --git a/test/vs2017/etl.vcxproj.filters b/test/vs2017/etl.vcxproj.filters index d45f1a84..273aa52f 100644 --- a/test/vs2017/etl.vcxproj.filters +++ b/test/vs2017/etl.vcxproj.filters @@ -621,6 +621,12 @@ ETL\Maths + + ETL\Utilities + + + ETL\Utilities\Generators + @@ -1019,6 +1025,9 @@ Source Files + + Source Files + @@ -1057,6 +1066,9 @@ Resource Files\Images + + Resource Files\Generators + From d63afc70ea7bd45383e74635daf89f2aa96088d4 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 21 Apr 2018 18:26:24 +0100 Subject: [PATCH 06/14] Removed non-compliant constexpr --- include/etl/queue.h | 4 ++-- include/etl/queue_mpmc_mutex.h | 4 ++-- include/etl/queue_spsc_atomic.h | 4 ++-- include/etl/queue_spsc_isr.h | 4 ++-- include/etl/variant.h | 2 +- include/etl/version.h | 4 ++-- support/Release notes.txt | 7 +++++++ test/codeblocks/ETL.cbp | 1 + 8 files changed, 19 insertions(+), 11 deletions(-) diff --git a/include/etl/queue.h b/include/etl/queue.h index bc2ae1a9..15ded9bd 100644 --- a/include/etl/queue.h +++ b/include/etl/queue.h @@ -119,7 +119,7 @@ namespace etl //************************************************************************* /// Returns the maximum number of items that can be queued. //************************************************************************* - ETL_CONSTEXPR size_type max_size() const + size_type max_size() const { return CAPACITY; } @@ -127,7 +127,7 @@ namespace etl //************************************************************************* /// Returns the maximum number of items that can be queued. //************************************************************************* - ETL_CONSTEXPR size_type capacity() const + size_type capacity() const { return CAPACITY; } diff --git a/include/etl/queue_mpmc_mutex.h b/include/etl/queue_mpmc_mutex.h index 03ef4005..f6951406 100644 --- a/include/etl/queue_mpmc_mutex.h +++ b/include/etl/queue_mpmc_mutex.h @@ -51,7 +51,7 @@ namespace etl //************************************************************************* /// How many items can the queue hold. //************************************************************************* - ETL_CONSTEXPR size_t capacity() const + size_t capacity() const { return MAX_SIZE; } @@ -59,7 +59,7 @@ namespace etl //************************************************************************* /// How many items can the queue hold. //************************************************************************* - ETL_CONSTEXPR size_t max_size() const + size_t max_size() const { return MAX_SIZE; } diff --git a/include/etl/queue_spsc_atomic.h b/include/etl/queue_spsc_atomic.h index cc5e6f6d..dfe32fc0 100644 --- a/include/etl/queue_spsc_atomic.h +++ b/include/etl/queue_spsc_atomic.h @@ -105,7 +105,7 @@ namespace etl //************************************************************************* /// How many items can the queue hold. //************************************************************************* - ETL_CONSTEXPR size_t capacity() const + size_t capacity() const { return RESERVED - 1; } @@ -113,7 +113,7 @@ namespace etl //************************************************************************* /// How many items can the queue hold. //************************************************************************* - ETL_CONSTEXPR size_t max_size() const + size_t max_size() const { return RESERVED - 1; } diff --git a/include/etl/queue_spsc_isr.h b/include/etl/queue_spsc_isr.h index b58333d6..2b89603d 100644 --- a/include/etl/queue_spsc_isr.h +++ b/include/etl/queue_spsc_isr.h @@ -131,7 +131,7 @@ namespace etl //************************************************************************* /// How many items can the queue hold. //************************************************************************* - ETL_CONSTEXPR size_t capacity() const + size_t capacity() const { return MAX_SIZE; } @@ -139,7 +139,7 @@ namespace etl //************************************************************************* /// How many items can the queue hold. //************************************************************************* - ETL_CONSTEXPR size_t max_size() const + size_t max_size() const { return MAX_SIZE; } diff --git a/include/etl/variant.h b/include/etl/variant.h index 72ae6950..182e19c8 100644 --- a/include/etl/variant.h +++ b/include/etl/variant.h @@ -912,7 +912,7 @@ namespace etl //*************************************************************************** /// Gets the index of the type currently stored or UNSUPPORTED_TYPE_ID //*************************************************************************** - ETL_CONSTEXPR size_t index() const + size_t index() const { return type_id; } diff --git a/include/etl/version.h b/include/etl/version.h index 74abd073..85be9694 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,9 +37,9 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.6.0" +#define ETL_VERSION "11.7.0" #define ETL_VERSION_MAJOR 11 -#define ETL_VERSION_MINOR 6 +#define ETL_VERSION_MINOR 7 #define ETL_VERSION_PATCH 0 #endif diff --git a/support/Release notes.txt b/support/Release notes.txt index d86df051..aedbe2fa 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,10 @@ +=============================================================================== +11.7.0 +Modified header guards. +Added etl::type_select +Added etl::null_type + +=============================================================================== 11.6.0 Added capacity() to etl::queue Prefixed max_size() and capacity() with ETL_CONSTEXPR in all queue types. diff --git a/test/codeblocks/ETL.cbp b/test/codeblocks/ETL.cbp index 454afa4e..65639955 100644 --- a/test/codeblocks/ETL.cbp +++ b/test/codeblocks/ETL.cbp @@ -157,6 +157,7 @@ + From 8085f97e5225a57d37da5bc0e53fb21f2a322fe1 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 24 Apr 2018 14:15:30 +0100 Subject: [PATCH 07/14] Rewrite of debug count so that it does not exists in unit test code or when explicitly enabled. --- include/etl/debug_count.h | 60 +++++++------------ include/etl/deque.h | 56 +++++++++--------- include/etl/flat_map.h | 24 ++++---- include/etl/flat_multimap.h | 20 +++---- include/etl/flat_multiset.h | 18 +++--- include/etl/flat_set.h | 22 +++---- include/etl/forward_list.h | 30 +++++----- include/etl/list.h | 38 ++++++------- include/etl/map.h | 6 +- include/etl/memory_model.h | 46 +++++++++++++++ include/etl/multimap.h | 6 +- include/etl/multiset.h | 6 +- include/etl/private/vector_base.h | 4 +- include/etl/queue.h | 16 +++--- include/etl/set.h | 6 +- include/etl/stack.h | 14 ++--- include/etl/unordered_map.h | 16 +++--- include/etl/unordered_multimap.h | 14 ++--- include/etl/unordered_multiset.h | 14 ++--- include/etl/unordered_set.h | 14 ++--- include/etl/vector.h | 95 ++++++++----------------------- test/etl_profile.h | 1 + test/test_queue_mpmc_mutex.cpp | 38 ++++++++++++- test/vs2017/etl.vcxproj | 1 + test/vs2017/etl.vcxproj.filters | 3 + 25 files changed, 293 insertions(+), 275 deletions(-) create mode 100644 include/etl/memory_model.h diff --git a/include/etl/debug_count.h b/include/etl/debug_count.h index 41370c40..3aeede54 100644 --- a/include/etl/debug_count.h +++ b/include/etl/debug_count.h @@ -39,6 +39,15 @@ SOFTWARE. ///\defgroup debug_count debug count ///\ingroup utilities +#if defined(ETL_DEBUG_COUNT) + +#define ETL_DECLARE_DEBUG_COUNT etl::debug_count etl_debug_count +#define ETL_INCREMENT_DEBUG_COUNT ++etl_debug_count +#define ETL_DECREMENT_DEBUG_COUNT --etl_debug_count +#define ETL_ADD_DEBUG_COUNT(n) etl_debug_count += (n) +#define ETL_SUBTRACT_DEBUG_COUNT(n) etl_debug_count -= (n) +#define ETL_RESET_DEBUG_COUNT etl_debug_count.clear() + namespace etl { //*************************************************************************** @@ -51,8 +60,7 @@ namespace etl class debug_count { public: - -#if defined(ETL_DEBUG) + inline debug_count() : count(0) { @@ -113,46 +121,16 @@ namespace etl private: int32_t count; -#else - inline debug_count() - { - } - - inline ~debug_count() - { - } - - inline debug_count& operator ++() - { - return *this; - } - - inline debug_count& operator --() - { - return *this; - } - - inline debug_count& operator +=(int32_t /*n*/) - { - return *this; - } - - inline debug_count& operator -=(int32_t /*n*/) - { - return *this; - } - - inline operator int32_t() - { - return 0; - } - - inline void clear() - { - } - -#endif }; + +#else +#define ETL_DECLARE_DEBUG_COUNT +#define ETL_INCREMENT_DEBUG_COUNT +#define ETL_DECREMENT_DEBUG_COUNT +#define ETL_ADD_DEBUG_COUNT(n) +#define ETL_SUBTRACT_DEBUG_COUNT(n) +#define ETL_RESET_DEBUG_COUNT +#endif // ETL_DEBUG_COUNT } #endif diff --git a/include/etl/deque.h b/include/etl/deque.h index 3a10a4e3..08228ddc 100644 --- a/include/etl/deque.h +++ b/include/etl/deque.h @@ -211,10 +211,10 @@ namespace etl { } - size_type current_size; ///< The current number of elements in the deque. - const size_type CAPACITY; ///< The maximum number of elements in the deque. - const size_type BUFFER_SIZE; ///< The number of elements in the buffer. - etl::debug_count construct_count; ///< Internal debugging. + size_type current_size; ///< The current number of elements in the deque. + const size_type CAPACITY; ///< The maximum number of elements in the deque. + const size_type BUFFER_SIZE; ///< The number of elements in the buffer. + ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging. }; //*************************************************************************** @@ -935,7 +935,7 @@ namespace etl --_begin; p = etl::addressof(*_begin); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; position = _begin; } else if (insert_position == end()) @@ -943,7 +943,7 @@ namespace etl p = etl::addressof(*_end); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; position = _end - 1; } else @@ -1000,7 +1000,7 @@ namespace etl --_begin; p = etl::addressof(*_begin); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; position = _begin; } else if (insert_position == end()) @@ -1008,7 +1008,7 @@ namespace etl p = etl::addressof(*_end); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; position = _end - 1; } else @@ -1065,7 +1065,7 @@ namespace etl --_begin; p = etl::addressof(*_begin); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; position = _begin; } else if (insert_position == end()) @@ -1073,7 +1073,7 @@ namespace etl p = etl::addressof(*_end); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; position = _end - 1; } else @@ -1130,7 +1130,7 @@ namespace etl --_begin; p = etl::addressof(*_begin); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; position = _begin; } else if (insert_position == end()) @@ -1138,7 +1138,7 @@ namespace etl p = etl::addressof(*_end); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; position = _end - 1; } else @@ -1538,7 +1538,7 @@ namespace etl ::new (&(*_end)) T(value1); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -1555,7 +1555,7 @@ namespace etl ::new (&(*_end)) T(value1, value2); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -1572,7 +1572,7 @@ namespace etl ::new (&(*_end)) T(value1, value2, value3); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -1589,7 +1589,7 @@ namespace etl ::new (&(*_end)) T(value1, value2, value3, value4); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -1645,7 +1645,7 @@ namespace etl --_begin; ::new (&(*_begin)) T(value1); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -1662,7 +1662,7 @@ namespace etl --_begin; ::new (&(*_begin)) T(value1, value2); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -1679,7 +1679,7 @@ namespace etl --_begin; ::new (&(*_begin)) T(value1, value2, value3); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -1696,7 +1696,7 @@ namespace etl --_begin; ::new (&(*_begin)) T(value1, value2, value3, value4); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -1811,7 +1811,7 @@ namespace etl if ETL_IF_CONSTEXPR(etl::is_trivially_destructible::value) { current_size = 0; - construct_count.clear(); + ETL_RESET_DEBUG_COUNT; } else { @@ -1850,7 +1850,7 @@ namespace etl --_begin; ::new (&(*_begin)) T(); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //********************************************************************* @@ -1882,7 +1882,7 @@ namespace etl ::new (&(*item++)) T(*from); ++from; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } while (n-- != 0); } @@ -1894,7 +1894,7 @@ namespace etl ::new (&(*_end)) T(); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //********************************************************************* @@ -1905,7 +1905,7 @@ namespace etl --_begin; ::new (&(*_begin)) T(value); ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //********************************************************************* @@ -1916,7 +1916,7 @@ namespace etl ::new (&(*_end)) T(value); ++_end; ++current_size; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //********************************************************************* @@ -1926,7 +1926,7 @@ namespace etl { (*_begin).~T(); --current_size; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; ++_begin; } @@ -1938,7 +1938,7 @@ namespace etl --_end; (*_end).~T(); --current_size; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* diff --git a/include/etl/flat_map.h b/include/etl/flat_map.h index 087b792c..2c7e2f99 100644 --- a/include/etl/flat_map.h +++ b/include/etl/flat_map.h @@ -234,7 +234,7 @@ namespace etl { value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; std::pair result = refmap_t::insert_at(i_element, *pvalue); i_element->second = result.first->second; @@ -306,7 +306,7 @@ namespace etl value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); } @@ -367,7 +367,7 @@ namespace etl // Doesn't already exist? if ((i_element == end() || (i_element->first != key))) { - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); } else @@ -399,7 +399,7 @@ namespace etl // Doesn't already exist? if ((i_element == end() || (i_element->first != key))) { - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); } else @@ -431,7 +431,7 @@ namespace etl // Doesn't already exist? if ((i_element == end() || (i_element->first != key))) { - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); } else @@ -463,7 +463,7 @@ namespace etl // Doesn't already exist? if ((i_element == end() || (i_element->first != key))) { - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); } else @@ -495,7 +495,7 @@ namespace etl // Doesn't already exist? if ((i_element == end() || (i_element->first != key))) { - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); } else @@ -525,7 +525,7 @@ namespace etl i_element->~value_type(); storage.release(etl::addressof(*i_element)); refmap_t::erase(i_element); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; return 1; } } @@ -539,7 +539,7 @@ namespace etl i_element->~value_type(); storage.release(etl::addressof(*i_element)); refmap_t::erase(i_element); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //********************************************************************* @@ -558,7 +558,7 @@ namespace etl itr->~value_type(); storage.release(etl::addressof(*itr)); ++itr; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } refmap_t::erase(first, last); @@ -585,7 +585,7 @@ namespace etl } } - construct_count.clear(); + ETL_RESET_DEBUG_COUNT; refmap_t::clear(); } @@ -765,7 +765,7 @@ namespace etl storage_t& storage; /// Internal debugging. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/flat_multimap.h b/include/etl/flat_multimap.h index 4611f8af..210664ff 100644 --- a/include/etl/flat_multimap.h +++ b/include/etl/flat_multimap.h @@ -260,7 +260,7 @@ namespace etl value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refmap_t::insert_at(i_element, *pvalue); return result; @@ -313,7 +313,7 @@ namespace etl ::new ((void*)etl::addressof(pvalue->first)) key_type(key); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(value); iterator i_element = lower_bound(key); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } @@ -331,7 +331,7 @@ namespace etl ::new ((void*)etl::addressof(pvalue->first)) key_type(key); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1); iterator i_element = lower_bound(key); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } @@ -349,7 +349,7 @@ namespace etl ::new ((void*)etl::addressof(pvalue->first)) key_type(key); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1, value2); iterator i_element = lower_bound(key); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } @@ -367,7 +367,7 @@ namespace etl ::new ((void*)etl::addressof(pvalue->first)) key_type(key); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1, value2, value3); iterator i_element = lower_bound(key); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } @@ -385,7 +385,7 @@ namespace etl ::new ((void*)etl::addressof(pvalue->first)) key_type(key); ::new ((void*)etl::addressof(pvalue->second)) mapped_type(value1, value2, value3, value4); iterator i_element = lower_bound(key); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return refmap_t::insert_at(i_element, *pvalue); } @@ -420,7 +420,7 @@ namespace etl i_element->~value_type(); storage.release(etl::addressof(*i_element)); refmap_t::erase(i_element); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //********************************************************************* @@ -439,7 +439,7 @@ namespace etl itr->~value_type(); storage.release(etl::addressof(*itr)); ++itr; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } refmap_t::erase(first, last); @@ -466,7 +466,7 @@ namespace etl } } - construct_count.clear(); + ETL_RESET_DEBUG_COUNT; refmap_t::clear(); } @@ -646,7 +646,7 @@ namespace etl storage_t& storage; /// Internal debugging. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/flat_multiset.h b/include/etl/flat_multiset.h index 243c9ddb..442f2f99 100644 --- a/include/etl/flat_multiset.h +++ b/include/etl/flat_multiset.h @@ -236,7 +236,7 @@ namespace etl value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); return result; @@ -292,7 +292,7 @@ namespace etl iterator i_element = lower_bound(*pvalue); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return std::pair(refset_t::insert_at(i_element, *pvalue)); } @@ -310,7 +310,7 @@ namespace etl iterator i_element = lower_bound(*pvalue); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return std::pair(refset_t::insert_at(i_element, *pvalue)); } @@ -328,7 +328,7 @@ namespace etl iterator i_element = lower_bound(*pvalue); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return std::pair(refset_t::insert_at(i_element, *pvalue)); } @@ -346,7 +346,7 @@ namespace etl iterator i_element = lower_bound(*pvalue); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return std::pair(refset_t::insert_at(i_element, *pvalue)); } @@ -380,7 +380,7 @@ namespace etl etl::destroy_at(etl::addressof(*i_element)); storage.release(etl::addressof(*i_element)); refset_t::erase(i_element); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //********************************************************************* @@ -399,7 +399,7 @@ namespace etl etl::destroy_at(etl::addressof(*itr)); storage.release(etl::addressof(*itr)); ++itr; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } refset_t::erase(first, last); @@ -426,7 +426,7 @@ namespace etl } } - construct_count.clear(); + ETL_RESET_DEBUG_COUNT; refset_t::clear(); } @@ -606,7 +606,7 @@ namespace etl storage_t& storage; /// Internal debugging. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/flat_set.h b/include/etl/flat_set.h index c2f0f4c2..fe7590d6 100644 --- a/include/etl/flat_set.h +++ b/include/etl/flat_set.h @@ -239,7 +239,7 @@ namespace etl value_type* pvalue = storage.allocate(); ::new (pvalue) value_type(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); } @@ -300,7 +300,7 @@ namespace etl // Doesn't already exist? if ((i_element == end() || (*i_element != *pvalue))) { - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); } else @@ -333,7 +333,7 @@ namespace etl // Doesn't already exist? if ((i_element == end() || (*i_element != *pvalue))) { - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); } else @@ -366,7 +366,7 @@ namespace etl // Doesn't already exist? if ((i_element == end() || (*i_element != *pvalue))) { - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); } else @@ -399,7 +399,7 @@ namespace etl // Doesn't already exist? if ((i_element == end() || (*i_element != *pvalue))) { - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; result = refset_t::insert_at(i_element, *pvalue); } else @@ -431,7 +431,7 @@ namespace etl etl::destroy_at(etl::addressof(*i_element)); storage.release(etl::addressof(*i_element)); refset_t::erase(i_element); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; return 1; } } @@ -445,7 +445,7 @@ namespace etl etl::destroy_at(etl::addressof(*i_element)); storage.release(etl::addressof(*i_element)); refset_t::erase(i_element); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //********************************************************************* @@ -464,7 +464,7 @@ namespace etl etl::destroy_at(etl::addressof(*itr)); storage.release(etl::addressof(*itr)); ++itr; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } refset_t::erase(first, last); @@ -488,11 +488,11 @@ namespace etl etl::destroy_at(etl::addressof(*itr)); storage.release(etl::addressof(*itr)); ++itr; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } } - construct_count.clear(); + ETL_RESET_DEBUG_COUNT; refset_t::clear(); } @@ -672,7 +672,7 @@ namespace etl storage_t& storage; /// Internal debugging. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index 0d32dfe5..6249e0ba 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -275,10 +275,10 @@ namespace etl left->next = right; } - node_t start_node; ///< The node that acts as the forward_list start. - etl::ipool* p_node_pool; ///< The pool of data nodes used in the list. - const size_type MAX_SIZE; ///< The maximum size of the forward_list. - etl::debug_count construct_count; ///< Internal debugging. + node_t start_node; ///< The node that acts as the forward_list start. + etl::ipool* p_node_pool; ///< The pool of data nodes used in the list. + const size_type MAX_SIZE; ///< The maximum size of the forward_list. + ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging. }; //*************************************************************************** @@ -658,7 +658,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(start_node, *p_data_node); } @@ -673,7 +673,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(start_node, *p_data_node); } @@ -688,7 +688,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(start_node, *p_data_node); } @@ -703,7 +703,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3, value4); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(start_node, *p_data_node); } @@ -793,7 +793,7 @@ namespace etl data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(*position.p_node, *p_data_node); return iterator(*p_data_node); @@ -809,7 +809,7 @@ namespace etl data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(*position.p_node, *p_data_node); return iterator(*p_data_node); @@ -825,7 +825,7 @@ namespace etl data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(*position.p_node, *p_data_node); return iterator(*p_data_node); @@ -841,7 +841,7 @@ namespace etl data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3, value4); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node_after(*position.p_node, *p_data_node); return iterator(*p_data_node); @@ -1247,7 +1247,7 @@ namespace etl if ETL_IF_CONSTEXPR(etl::is_trivially_destructible::value) { p_node_pool->release_all(); - construct_count.clear(); + ETL_RESET_DEBUG_COUNT; } else { @@ -1326,7 +1326,7 @@ namespace etl { data_node_t* p_node = p_node_pool->allocate(); ::new (&(p_node->value)) T(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return *p_node; } @@ -1338,7 +1338,7 @@ namespace etl { node.value.~T(); p_node_pool->release(&node); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } // Disable copy construction. diff --git a/include/etl/list.h b/include/etl/list.h index 174e2b6b..42aaaeb2 100644 --- a/include/etl/list.h +++ b/include/etl/list.h @@ -317,10 +317,10 @@ namespace etl { } - etl::ipool* p_node_pool; ///< The pool of data nodes used in the list. - node_t terminal_node; ///< The node that acts as the list start and end. - const size_type MAX_SIZE; ///< The maximum size of the list. - etl::debug_count construct_count; ///< Internal debugging. + etl::ipool* p_node_pool; ///< The pool of data nodes used in the list. + node_t terminal_node; ///< The node that acts as the list start and end. + const size_type MAX_SIZE; ///< The maximum size of the list. + ETL_DECLARE_DEBUG_COUNT; ///< Internal debugging. }; //*************************************************************************** @@ -789,7 +789,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(get_head(), *p_data_node); } @@ -804,7 +804,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(get_head(), *p_data_node); } @@ -819,7 +819,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(get_head(), *p_data_node); } @@ -834,7 +834,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3, value4); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(get_head(), *p_data_node); } @@ -880,7 +880,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(terminal_node, *p_data_node); } @@ -895,7 +895,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(terminal_node, *p_data_node); } @@ -910,7 +910,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(terminal_node, *p_data_node); } @@ -925,7 +925,7 @@ namespace etl #endif data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3, value4); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(terminal_node, *p_data_node); } @@ -964,7 +964,7 @@ namespace etl data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(*position.p_node, *p_data_node); return iterator(*p_data_node); @@ -980,7 +980,7 @@ namespace etl data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(*position.p_node, *p_data_node); return iterator(*p_data_node); @@ -996,7 +996,7 @@ namespace etl data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(*position.p_node, *p_data_node); return iterator(*p_data_node); @@ -1012,7 +1012,7 @@ namespace etl data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value1, value2, value3, value4); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; insert_node(*position.p_node, *p_data_node); return iterator(*p_data_node); @@ -1456,7 +1456,7 @@ namespace etl if ETL_IF_CONSTEXPR(etl::is_trivially_destructible::value) { p_node_pool->release_all(); - construct_count.clear(); + ETL_RESET_DEBUG_COUNT; } else { @@ -1549,7 +1549,7 @@ namespace etl { data_node_t* p_data_node = p_node_pool->allocate(); ::new (&(p_data_node->value)) T(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return *p_data_node; } @@ -1561,7 +1561,7 @@ namespace etl { node.value.~T(); p_node_pool->release(&node); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } // Disable copy construction. diff --git a/include/etl/map.h b/include/etl/map.h index 276457f4..6f1908e0 100644 --- a/include/etl/map.h +++ b/include/etl/map.h @@ -453,7 +453,7 @@ namespace etl size_type current_size; ///< The number of the used nodes. const size_type CAPACITY; ///< The maximum size of the map. Node* root_node; ///< The node that acts as the map root. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; }; //*************************************************************************** @@ -1263,7 +1263,7 @@ namespace etl { Data_Node& node = *p_node_pool->allocate(); ::new (&node.value) const value_type(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return node; } @@ -1274,7 +1274,7 @@ namespace etl { node.value.~value_type(); p_node_pool->release(&node); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* diff --git a/include/etl/memory_model.h b/include/etl/memory_model.h new file mode 100644 index 00000000..07bfc73f --- /dev/null +++ b/include/etl/memory_model.h @@ -0,0 +1,46 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_MEMORY_MODEL_INCLUDED +#define ETL_MEMORY_MODEL_INCLUDED + +#include "user_type.h" + +namespace etl +{ + ETL_DECLARE_USER_TYPE(memory_model, int) + ETL_USER_TYPE(MM_SMALL, 0) + ETL_USER_TYPE(MM_MEDIUM, 1) + ETL_USER_TYPE(MM_LARGE, 2) + ETL_END_USER_TYPE(memory_model) +} + +#endif + diff --git a/include/etl/multimap.h b/include/etl/multimap.h index b855e2cd..91aca760 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -609,7 +609,7 @@ namespace etl size_type current_size; ///< The number of the used nodes. const size_type CAPACITY; ///< The maximum size of the map. Node* root_node; ///< The node that acts as the multimap root. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; }; //*************************************************************************** @@ -1356,7 +1356,7 @@ namespace etl { Data_Node& node = *p_node_pool->allocate(); ::new (&node.value) const value_type(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return node; } @@ -1367,7 +1367,7 @@ namespace etl { node.value.~value_type(); p_node_pool->release(&node); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* diff --git a/include/etl/multiset.h b/include/etl/multiset.h index 23eed65d..4b6a74e0 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -609,7 +609,7 @@ namespace etl size_type current_size; ///< The number of the used nodes. const size_type CAPACITY; ///< The maximum size of the set. Node* root_node; ///< The node that acts as the multiset root. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; }; //*************************************************************************** @@ -1337,7 +1337,7 @@ namespace etl { Data_Node& node = *p_node_pool->allocate(); ::new ((void*)&node.value) value_type(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return node; } @@ -1348,7 +1348,7 @@ namespace etl { node.value.~value_type(); p_node_pool->release(&node); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* diff --git a/include/etl/private/vector_base.h b/include/etl/private/vector_base.h index 6839e67a..d34b4f68 100644 --- a/include/etl/private/vector_base.h +++ b/include/etl/private/vector_base.h @@ -161,8 +161,8 @@ namespace etl { } - const size_type CAPACITY; ///allocate(); ::new ((void*)&node.value) value_type(value); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; return node; } @@ -1197,7 +1197,7 @@ namespace etl { node.value.~value_type(); p_node_pool->release(&node); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* diff --git a/include/etl/stack.h b/include/etl/stack.h index 57e40dde..3f9e1612 100644 --- a/include/etl/stack.h +++ b/include/etl/stack.h @@ -178,7 +178,7 @@ namespace etl void add_in() { top_index = current_size++; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -188,7 +188,7 @@ namespace etl { --top_index; --current_size; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } //************************************************************************* @@ -198,13 +198,13 @@ namespace etl { top_index = 0; current_size = 0; - construct_count.clear(); + ETL_RESET_DEBUG_COUNT; } - size_type top_index; ///< The index of the top of the stack. - size_type current_size; ///< The number of items in the stack. - const size_type CAPACITY; ///< The maximum number of items in the stack. - etl::debug_count construct_count; ///< For internal debugging purposes. + size_type top_index; ///< The index of the top of the stack. + size_type current_size; ///< The number of items in the stack. + const size_type CAPACITY; ///< The maximum number of items in the stack. + ETL_DECLARE_DEBUG_COUNT; ///< For internal debugging purposes. }; //*************************************************************************** diff --git a/include/etl/unordered_map.h b/include/etl/unordered_map.h index c5dd51e0..0f757b0e 100644 --- a/include/etl/unordered_map.h +++ b/include/etl/unordered_map.h @@ -658,7 +658,7 @@ namespace etl // Get a new node. node_t& node = *pnodepool->allocate(); ::new (&node.key_value_pair) value_type(key, T()); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; pbucket->insert_after(pbucket->before_begin(), node); @@ -788,7 +788,7 @@ namespace etl // Get a new node. node_t& node = *pnodepool->allocate(); ::new (&node.key_value_pair) value_type(key_value_pair); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; // Just add the pointer to the bucket; bucket.insert_after(bucket.before_begin(), node); @@ -822,7 +822,7 @@ namespace etl // Get a new node. node_t& node = *pnodepool->allocate(); ::new (&node.key_value_pair) value_type(key_value_pair); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; // Add the node to the end of the bucket; bucket.insert_after(inode_previous, node); @@ -892,7 +892,7 @@ namespace etl icurrent->key_value_pair.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. n = 1; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } return n; @@ -921,7 +921,7 @@ namespace etl bucket.erase_after(iprevious); // Unlink from the bucket. icurrent->key_value_pair.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; return inext; } @@ -956,7 +956,7 @@ namespace etl local_iterator inext = pbucket->erase_after(iprevious); // Unlink from the bucket. icurrent->key_value_pair.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; icurrent = inext; @@ -1224,7 +1224,7 @@ namespace etl { // Destroy the value contents. it->key_value_pair.~value_type(); - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; ++it; } @@ -1282,7 +1282,7 @@ namespace etl key_equal key_equal_function; /// For library debugging purposes only. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/unordered_multimap.h b/include/etl/unordered_multimap.h index 1bec644d..25257d39 100644 --- a/include/etl/unordered_multimap.h +++ b/include/etl/unordered_multimap.h @@ -677,7 +677,7 @@ namespace etl // Get a new node. node_t& node = *pnodepool->allocate(); ::new (&node.key_value_pair) value_type(key_value_pair); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; // Just add the pointer to the bucket; bucket.insert_after(bucket.before_begin(), node); @@ -707,7 +707,7 @@ namespace etl // Get a new node. node_t& node = *pnodepool->allocate(); ::new (&node.key_value_pair) value_type(key_value_pair); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; // Add the node to the end of the bucket; bucket.insert_after(inode_previous, node); @@ -770,7 +770,7 @@ namespace etl pnodepool->release(&*icurrent); // Release it back to the pool. ++n; icurrent = iprevious; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } else { @@ -806,7 +806,7 @@ namespace etl bucket.erase_after(iprevious); // Unlink from the bucket. icurrent->key_value_pair.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; return inext; } @@ -841,7 +841,7 @@ namespace etl local_iterator inext = pbucket->erase_after(iprevious); // Unlink from the bucket. icurrent->key_value_pair.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; icurrent = inext; @@ -1136,7 +1136,7 @@ namespace etl // Destroy the value contents. it->key_value_pair.~value_type(); ++it; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } // Now it's safe to clear the bucket. @@ -1192,7 +1192,7 @@ namespace etl key_equal key_equal_function; /// For library debugging purposes only. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/unordered_multiset.h b/include/etl/unordered_multiset.h index 1301f40a..11cbc07a 100644 --- a/include/etl/unordered_multiset.h +++ b/include/etl/unordered_multiset.h @@ -669,7 +669,7 @@ namespace etl // Get a new node. node_t& node = *pnodepool->allocate(); ::new (&node.key) value_type(key); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; // Just add the pointer to the bucket; bucket.insert_after(bucket.before_begin(), node); @@ -700,7 +700,7 @@ namespace etl // Get a new node. node_t& node = *pnodepool->allocate(); ::new (&node.key) value_type(key); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; // Add the node to the end of the bucket; bucket.insert_after(inode_previous, node); @@ -764,7 +764,7 @@ namespace etl pnodepool->release(&*icurrent); // Release it back to the pool. ++n; icurrent = iprevious; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } else { @@ -800,7 +800,7 @@ namespace etl bucket.erase_after(iprevious); // Unlink from the bucket. icurrent->key.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; return inext; } @@ -835,7 +835,7 @@ namespace etl local_iterator inext = pbucket->erase_after(iprevious); // Unlink from the bucket. icurrent->key.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; icurrent = inext; @@ -1130,7 +1130,7 @@ namespace etl // Destroy the value contents. it->key.~value_type(); ++it; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } // Now it's safe to clear the bucket. @@ -1186,7 +1186,7 @@ namespace etl key_equal key_equal_function; /// For library debugging purposes only. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/unordered_set.h b/include/etl/unordered_set.h index d1b7000f..94473567 100644 --- a/include/etl/unordered_set.h +++ b/include/etl/unordered_set.h @@ -670,7 +670,7 @@ namespace etl // Get a new node. node_t& node = *pnodepool->allocate(); ::new (&node.key) value_type(key); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; // Just add the pointer to the bucket; bucket.insert_after(bucket.before_begin(), node); @@ -704,7 +704,7 @@ namespace etl // Get a new node. node_t& node = *pnodepool->allocate(); ::new (&node.key) value_type(key); - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; // Add the node to the end of the bucket; bucket.insert_after(inode_previous, node); @@ -774,7 +774,7 @@ namespace etl icurrent->key.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. n = 1; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } return n; @@ -803,7 +803,7 @@ namespace etl bucket.erase_after(iprevious); // Unlink from the bucket. icurrent->key.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; return inext; } @@ -838,7 +838,7 @@ namespace etl local_iterator inext = pbucket->erase_after(iprevious); // Unlink from the bucket. icurrent->key.~value_type(); // Destroy the value. pnodepool->release(&*icurrent); // Release it back to the pool. - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; icurrent = inext; @@ -1107,7 +1107,7 @@ namespace etl // Destroy the value contents. it->key.~value_type(); ++it; - --construct_count; + ETL_DECREMENT_DEBUG_COUNT; } // Now it's safe to clear the bucket. @@ -1163,7 +1163,7 @@ namespace etl key_equal key_equal_function; /// For library debugging purposes only. - etl::debug_count construct_count; + ETL_DECLARE_DEBUG_COUNT; //************************************************************************* /// Destructor. diff --git a/include/etl/vector.h b/include/etl/vector.h index 78be2370..41683a93 100644 --- a/include/etl/vector.h +++ b/include/etl/vector.h @@ -5,7 +5,7 @@ The MIT License(MIT) Embedded Template Library. https://github.com/ETLCPP/etl -http://www.etlcpp.com +https://www.etlcpp.com Copyright(c) 2014 jwellbelove @@ -233,16 +233,12 @@ namespace etl if (current_size < new_size) { etl::uninitialized_fill_n(p_end, delta, value); -#if defined(ETL_DEBUG) - construct_count += delta; -#endif + ETL_ADD_DEBUG_COUNT(delta); } else { etl::destroy_n(p_end - delta, delta); -#if defined(ETL_DEBUG) - construct_count -= delta; -#endif + ETL_SUBTRACT_DEBUG_COUNT(delta); } p_end = p_buffer + new_size; @@ -372,11 +368,8 @@ namespace etl initialise(); -#if defined(ETL_DEBUG) - p_end = etl::uninitialized_copy(first, last, p_buffer, construct_count); -#else p_end = etl::uninitialized_copy(first, last, p_buffer); -#endif + ETL_ADD_DEBUG_COUNT(uint32_t(std::distance(first, last))); } //********************************************************************* @@ -391,11 +384,8 @@ namespace etl initialise(); -#if defined(ETL_DEBUG) - p_end = etl::uninitialized_fill_n(p_buffer, n, value, construct_count); -#else p_end = etl::uninitialized_fill_n(p_buffer, n, value); -#endif + ETL_ADD_DEBUG_COUNT(uint32_t(n)); } //************************************************************************* @@ -445,7 +435,7 @@ namespace etl #endif ::new (p_end) T(value1); ++p_end; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //********************************************************************* @@ -461,7 +451,7 @@ namespace etl #endif ::new (p_end) T(value1, value2); ++p_end; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //********************************************************************* @@ -477,7 +467,7 @@ namespace etl #endif ::new (p_end) T(value1, value2, value3); ++p_end; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //********************************************************************* @@ -493,7 +483,7 @@ namespace etl #endif ::new (p_end) T(value1, value2, value3, value4); ++p_end; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } //************************************************************************* @@ -545,7 +535,7 @@ namespace etl if (position == end()) { p = p_end++; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } else { @@ -573,7 +563,7 @@ namespace etl if (position == end()) { p = p_end++; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } else { @@ -601,7 +591,7 @@ namespace etl if (position == end()) { p = p_end++; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } else { @@ -629,7 +619,7 @@ namespace etl if (position == end()) { p = p_end++; - ++construct_count; + ETL_INCREMENT_DEBUG_COUNT; } else { @@ -680,31 +670,19 @@ namespace etl size_t copy_new_n = construct_old_n; size_t construct_new_n = insert_n - copy_new_n; -#if defined(ETL_DEBUG) - // Construct old. - etl::uninitialized_copy_n(p_end - construct_old_n, construct_old_n, p_construct_old, construct_count); - - // Copy old. - etl::copy_n(p_buffer + insert_begin, copy_old_n, p_buffer + insert_end); - - // Construct new. - etl::uninitialized_fill_n(p_end, construct_new_n, value, construct_count); - - // Copy new. - std::fill_n(p_buffer + insert_begin, copy_new_n, value); -#else // Construct old. etl::uninitialized_copy_n(p_end - construct_old_n, construct_old_n, p_construct_old); + ETL_ADD_DEBUG_COUNT(construct_old_n); // Copy old. etl::copy_n(p_buffer + insert_begin, copy_old_n, p_buffer + insert_end); // Construct new. etl::uninitialized_fill_n(p_end, construct_new_n, value); + ETL_ADD_DEBUG_COUNT(construct_new_n); // Copy new. std::fill_n(p_buffer + insert_begin, copy_new_n, value); -#endif p_end += n; } @@ -749,31 +727,19 @@ namespace etl size_t copy_new_n = construct_old_n; size_t construct_new_n = insert_n - copy_new_n; -#if defined(ETL_DEBUG) - // Construct old. - etl::uninitialized_copy_n(p_end - construct_old_n, construct_old_n, p_construct_old, construct_count); - - // Copy old. - etl::copy_n(p_buffer + insert_begin, copy_old_n, p_buffer + insert_end); - - // Construct new. - etl::uninitialized_copy_n(first + copy_new_n, construct_new_n, p_end, construct_count); - - // Copy new. - etl::copy_n(first, copy_new_n, p_buffer + insert_begin); -#else // Construct old. etl::uninitialized_copy_n(p_end - construct_old_n, construct_old_n, p_construct_old); + ETL_ADD_DEBUG_COUNT(construct_old_n); // Copy old. etl::copy_n(p_buffer + insert_begin, copy_old_n, p_buffer + insert_end); // Construct new. etl::uninitialized_copy_n(first + copy_new_n, construct_new_n, p_end); + ETL_ADD_DEBUG_COUNT(construct_new_n); // Copy new. etl::copy_n(first, copy_new_n, p_buffer + insert_begin); -#endif p_end += count; } @@ -811,11 +777,8 @@ namespace etl size_t n_delete = std::distance(first, last); // Destroy the elements left over at the end. -#if defined(ETL_DEBUG) - etl::destroy(p_end - n_delete, p_end, construct_count); -#else etl::destroy(p_end - n_delete, p_end); -#endif + ETL_SUBTRACT_DEBUG_COUNT(n_delete); p_end -= n_delete; } @@ -895,11 +858,8 @@ namespace etl //********************************************************************* void initialise() { -#if defined(ETL_DEBUG) - etl::destroy(p_buffer, p_end, construct_count); -#else etl::destroy(p_buffer, p_end); -#endif + ETL_SUBTRACT_DEBUG_COUNT(int32_t(std::distance(p_buffer, p_end))); p_end = p_buffer; } @@ -924,11 +884,9 @@ namespace etl //********************************************************************* inline void create_back() { -#if defined(ETL_DEBUG) - etl::create_value_at(p_end, construct_count); -#else etl::create_value_at(p_end); -#endif + ETL_INCREMENT_DEBUG_COUNT; + ++p_end; } @@ -937,11 +895,9 @@ namespace etl //********************************************************************* inline void create_back(parameter_t value) { -#if defined(ETL_DEBUG) - etl::create_copy_at(p_end, value, construct_count); -#else etl::create_copy_at(p_end, value); -#endif + ETL_INCREMENT_DEBUG_COUNT; + ++p_end; } @@ -952,11 +908,8 @@ namespace etl { --p_end; -#if defined(ETL_DEBUG) - etl::destroy_at(p_end, construct_count); -#else etl::destroy_at(p_end); -#endif + ETL_DECREMENT_DEBUG_COUNT; } // Disable copy construction. diff --git a/test/etl_profile.h b/test/etl_profile.h index 96636ff8..906660b9 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -38,6 +38,7 @@ SOFTWARE. #define ETL_IVECTOR_REPAIR_ENABLE #define ETL_IDEQUE_REPAIR_ENABLE #define ETL_IN_UNIT_TEST +#define ETL_DEBUG_COUNT #define ETL_MESSAGE_TIMER_USE_ATOMIC_LOCK #define ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK diff --git a/test/test_queue_mpmc_mutex.cpp b/test/test_queue_mpmc_mutex.cpp index b9f39105..9b8b7bee 100644 --- a/test/test_queue_mpmc_mutex.cpp +++ b/test/test_queue_mpmc_mutex.cpp @@ -45,6 +45,42 @@ SOFTWARE. namespace { + struct Data + { + Data(int a_, int b_ = 2, int c_ = 3, int d_ = 4) + : a(a_), + b(b_), + c(c_), + d(d_) + { + } + + Data() + : a(0), + b(0), + c(0), + d(0) + { + } + + int a; + int b; + int c; + int d; + }; + + bool operator ==(const Data& lhs, const Data& rhs) + { + return (lhs.a == rhs.a) && (lhs.b == rhs.b) && (lhs.c == rhs.c) && (lhs.d == rhs.d); + } + + std::ostream& operator <<(std::ostream& os, const Data& data) + { + os << data.a << " " << data.b << " " << data.c << " " << data.d; + + return os; + } + SUITE(test_queue_mpmc_mutex) { //************************************************************************* @@ -371,7 +407,7 @@ namespace std::thread t2(push_thread2); std::thread t3(pop_thread1); std::thread t4(pop_thread2); - + start.store(true); // Join the threads with the main thread diff --git a/test/vs2017/etl.vcxproj b/test/vs2017/etl.vcxproj index 767c9004..abb1b7a1 100644 --- a/test/vs2017/etl.vcxproj +++ b/test/vs2017/etl.vcxproj @@ -337,6 +337,7 @@ + diff --git a/test/vs2017/etl.vcxproj.filters b/test/vs2017/etl.vcxproj.filters index 273aa52f..eb3e8c7a 100644 --- a/test/vs2017/etl.vcxproj.filters +++ b/test/vs2017/etl.vcxproj.filters @@ -627,6 +627,9 @@ ETL\Utilities\Generators + + ETL\Utilities + From dcd42ee17eff5836253263229e94c2b8065d3110 Mon Sep 17 00:00:00 2001 From: Austin Morton Date: Tue, 24 Apr 2018 09:27:18 -0400 Subject: [PATCH 08/14] Fix assumption that min/max macros will always be defined on a Microsoft compiler (#72) Merge in min-max changes to a feature branch --- include/etl/basic_string.h | 16 +------- include/etl/bitset.h | 8 +--- include/etl/cstring.h | 8 +--- include/etl/deque.h | 8 +--- include/etl/forward_list.h | 8 +--- include/etl/fsm.h | 8 +--- include/etl/fsm_generator.h | 8 +--- include/etl/integral_limits.h | 10 +---- include/etl/intrusive_forward_list.h | 8 +--- include/etl/intrusive_list.h | 8 +--- include/etl/list.h | 8 +--- include/etl/map.h | 8 +--- include/etl/multimap.h | 8 +--- include/etl/multiset.h | 8 +--- .../minmax_pop.h} | 13 +++--- include/etl/private/minmax_push.h | 41 +++++++++++++++++++ include/etl/private/pvoidvector.h | 8 +--- include/etl/set.h | 8 +--- include/etl/string_view.h | 10 +---- include/etl/u16string.h | 8 +--- include/etl/u32string.h | 8 +--- include/etl/wstring.h | 8 +--- test/test_binary.cpp | 2 - test/test_bitset.cpp | 3 -- test/test_constant.cpp | 2 - test/test_integral_limits.cpp | 3 -- test/test_string_char.cpp | 2 - test/test_string_u16.cpp | 2 - test/test_string_u32.cpp | 2 - test/test_string_wchar_t.cpp | 2 - 30 files changed, 89 insertions(+), 155 deletions(-) rename include/etl/{spsc_queue_freertos.h => private/minmax_pop.h} (85%) create mode 100644 include/etl/private/minmax_push.h diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index b58e9599..17ee2480 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -55,13 +55,7 @@ SOFTWARE. #pragma GCC diagnostic ignored "-Wunused-variable" #endif -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#endif - -#ifdef ETL_COMPILER_MICROSOFT -#undef max -#endif +#include "private/minmax_push.h" //***************************************************************************** ///\defgroup basic_string basic_string @@ -2234,13 +2228,7 @@ namespace etl } } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif - -#ifdef ETL_COMPILER_MICROSOFT -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #undef ETL_FILE diff --git a/include/etl/bitset.h b/include/etl/bitset.h index 3e42bd86..ae328129 100644 --- a/include/etl/bitset.h +++ b/include/etl/bitset.h @@ -46,9 +46,7 @@ SOFTWARE. #include "integral_limits.h" #include "binary.h" -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#endif +#include "private/minmax_push.h" #include "error_handler.h" @@ -1018,8 +1016,6 @@ void swap(etl::bitset& lhs, etl::bitset& rhs) lhs.swap(rhs); } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #endif diff --git a/include/etl/cstring.h b/include/etl/cstring.h index f2a0ee9a..0ddfc80a 100644 --- a/include/etl/cstring.h +++ b/include/etl/cstring.h @@ -39,9 +39,7 @@ SOFTWARE. #include #endif -#if defined(ETL_COMPILER_MICROSOFT) -#undef min -#endif +#include "private/minmax_push.h" namespace etl { @@ -227,8 +225,6 @@ namespace etl #endif } -#if defined(ETL_COMPILER_MICROSOFT) -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #endif diff --git a/include/etl/deque.h b/include/etl/deque.h index 08228ddc..da898328 100644 --- a/include/etl/deque.h +++ b/include/etl/deque.h @@ -52,9 +52,7 @@ SOFTWARE. #include #endif -#ifdef ETL_COMPILER_MICROSOFT - #undef min -#endif +#include "private/minmax_push.h" #undef ETL_FILE #define ETL_FILE "1" @@ -2194,8 +2192,6 @@ bool operator >=(const etl::ideque& lhs, const etl::ideque& rhs) #undef ETL_FILE -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #endif diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index 6249e0ba..407380d3 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -50,9 +50,7 @@ SOFTWARE. #include #endif -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#endif +#include "private/minmax_push.h" #undef ETL_FILE #define ETL_FILE "6" @@ -1536,9 +1534,7 @@ bool operator >=(const etl::iforward_list& lhs, const etl::iforward_list& return !(lhs < rhs); } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #undef ETL_FILE diff --git a/include/etl/fsm.h b/include/etl/fsm.h index 54a06c36..eeb343b9 100644 --- a/include/etl/fsm.h +++ b/include/etl/fsm.h @@ -66,9 +66,7 @@ SOFTWARE. #undef ETL_FILE #define ETL_FILE "34" -#ifdef ETL_COMPILER_MICROSOFT -#undef max -#endif +#include "private/minmax_push.h" namespace etl { @@ -1215,8 +1213,6 @@ namespace etl #undef ETL_FILE -#ifdef ETL_COMPILER_MICROSOFT -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #endif diff --git a/include/etl/fsm_generator.h b/include/etl/fsm_generator.h index 63eb4f75..91997b63 100644 --- a/include/etl/fsm_generator.h +++ b/include/etl/fsm_generator.h @@ -78,9 +78,7 @@ cog.outl("//******************************************************************** #undef ETL_FILE #define ETL_FILE "34" -#ifdef ETL_COMPILER_MICROSOFT -#undef max -#endif +#include "private/minmax_push.h" namespace etl { @@ -538,8 +536,6 @@ namespace etl #undef ETL_FILE -#ifdef ETL_COMPILER_MICROSOFT -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #endif diff --git a/include/etl/integral_limits.h b/include/etl/integral_limits.h index 4277d939..4adf9fad 100644 --- a/include/etl/integral_limits.h +++ b/include/etl/integral_limits.h @@ -37,10 +37,7 @@ SOFTWARE. #include "platform.h" #include "type_traits.h" -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#undef max -#endif +#include "private/minmax_push.h" //***************************************************************************** ///\defgroup integral_limits integral_limits @@ -213,9 +210,6 @@ namespace etl }; } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #endif diff --git a/include/etl/intrusive_forward_list.h b/include/etl/intrusive_forward_list.h index 9c8e0224..bcc24ddd 100644 --- a/include/etl/intrusive_forward_list.h +++ b/include/etl/intrusive_forward_list.h @@ -33,9 +33,7 @@ SOFTWARE. #include "platform.h" -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#endif +#include "private/minmax_push.h" #include #include @@ -1046,9 +1044,7 @@ namespace etl }; } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #undef ETL_FILE diff --git a/include/etl/intrusive_list.h b/include/etl/intrusive_list.h index 2d0e764c..6e4494d0 100644 --- a/include/etl/intrusive_list.h +++ b/include/etl/intrusive_list.h @@ -33,9 +33,7 @@ SOFTWARE. #include "platform.h" -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#endif +#include "private/minmax_push.h" #include #include @@ -1078,9 +1076,7 @@ namespace etl }; } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #undef ETL_FILE diff --git a/include/etl/list.h b/include/etl/list.h index 42aaaeb2..d48a6f5d 100644 --- a/include/etl/list.h +++ b/include/etl/list.h @@ -51,9 +51,7 @@ SOFTWARE. #include #endif -#ifdef ETL_COMPILER_MICROSOFT - #undef min -#endif +#include "private/minmax_push.h" #undef ETL_FILE #define ETL_FILE "7" @@ -1768,9 +1766,7 @@ bool operator >=(const etl::ilist& lhs, const etl::ilist& rhs) } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #undef ETL_FILE diff --git a/include/etl/map.h b/include/etl/map.h index 6f1908e0..4e7476fb 100644 --- a/include/etl/map.h +++ b/include/etl/map.h @@ -51,9 +51,7 @@ SOFTWARE. #include #endif -#ifdef ETL_COMPILER_MICROSOFT - #undef min -#endif +#include "private/minmax_push.h" #undef ETL_FILE #define ETL_FILE "8" @@ -2186,9 +2184,7 @@ bool operator >=(const etl::imap& lhs, const etl::im return !(lhs < rhs); } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #undef ETL_FILE diff --git a/include/etl/multimap.h b/include/etl/multimap.h index 91aca760..e08e65dd 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -50,9 +50,7 @@ SOFTWARE. #include #endif -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#endif +#include "private/minmax_push.h" #undef ETL_FILE #define ETL_FILE "9" @@ -2071,9 +2069,7 @@ bool operator >=(const etl::imultimap& lhs, const et return !(lhs < rhs); } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #undef ETL_FILE diff --git a/include/etl/multiset.h b/include/etl/multiset.h index 4b6a74e0..47673ee5 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -50,9 +50,7 @@ SOFTWARE. #include #endif -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#endif +#include "private/minmax_push.h" #undef ETL_FILE #define ETL_FILE "10" @@ -2051,9 +2049,7 @@ bool operator >=(const etl::imultiset& lhs, const etl::imultiset=(const etl::pvoidvector& lhs, const etl::pvoidvector& rhs); } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "minmax_pop.h" #undef ETL_IN_PVOIDVECTOR diff --git a/include/etl/set.h b/include/etl/set.h index fe2f3eec..e405de30 100644 --- a/include/etl/set.h +++ b/include/etl/set.h @@ -50,9 +50,7 @@ SOFTWARE. #include #endif -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#endif +#include "private/minmax_push.h" #undef ETL_FILE #define ETL_FILE "14" @@ -2109,9 +2107,7 @@ bool operator >=(const etl::iset& lhs, const etl::iset return !(lhs < rhs); } -#ifdef ETL_COMPILER_MICROSOFT -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #undef ETL_FILE diff --git a/include/etl/string_view.h b/include/etl/string_view.h index 0b376bb5..5402cda6 100644 --- a/include/etl/string_view.h +++ b/include/etl/string_view.h @@ -49,10 +49,7 @@ SOFTWARE. #undef ETL_FILE #define ETL_FILE "42" -#ifdef ETL_COMPILER_MICROSOFT -#undef min -#undef max -#endif +#include "private/minmax_push.h" namespace etl { @@ -864,10 +861,7 @@ void swap(etl::basic_string_view& lhs, etl::basic_string_view (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #undef ETL_FILE diff --git a/include/etl/u16string.h b/include/etl/u16string.h index 7380c786..f9c5d22f 100644 --- a/include/etl/u16string.h +++ b/include/etl/u16string.h @@ -39,9 +39,7 @@ SOFTWARE. #include #endif -#if defined(ETL_COMPILER_MICROSOFT) - #undef min -#endif +#include "private/minmax_push.h" namespace etl { @@ -231,8 +229,6 @@ namespace etl #endif } -#if defined(ETL_COMPILER_MICROSOFT) - #define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #endif diff --git a/include/etl/u32string.h b/include/etl/u32string.h index a1e2086d..23554cf4 100644 --- a/include/etl/u32string.h +++ b/include/etl/u32string.h @@ -39,9 +39,7 @@ SOFTWARE. #include #endif -#if defined(ETL_COMPILER_MICROSOFT) - #undef min -#endif +#include "private/minmax_push.h" namespace etl { @@ -231,8 +229,6 @@ namespace etl #endif } -#if defined(ETL_COMPILER_MICROSOFT) - #define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #endif diff --git a/include/etl/wstring.h b/include/etl/wstring.h index 8c7f8251..d3d6eb65 100644 --- a/include/etl/wstring.h +++ b/include/etl/wstring.h @@ -39,9 +39,7 @@ SOFTWARE. #include #endif -#if defined(ETL_COMPILER_MICROSOFT) - #undef min -#endif +#include "private/minmax_push.h" namespace etl { @@ -232,8 +230,6 @@ namespace etl #endif } -#if defined(ETL_COMPILER_MICROSOFT) - #define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif +#include "private/minmax_pop.h" #endif diff --git a/test/test_binary.cpp b/test/test_binary.cpp index 5689d400..5de74d2a 100644 --- a/test/test_binary.cpp +++ b/test/test_binary.cpp @@ -36,8 +36,6 @@ SOFTWARE. #include "fnv_1.h" #include "integral_limits.h" -#undef max - // Count bits the easy way. template size_t test_count(T value) diff --git a/test/test_bitset.cpp b/test/test_bitset.cpp index fa5b47ae..b3991918 100644 --- a/test/test_bitset.cpp +++ b/test/test_bitset.cpp @@ -34,9 +34,6 @@ SOFTWARE. #include "bitset.h" -#undef min -#undef max - namespace { SUITE(test_bitset) diff --git a/test/test_constant.cpp b/test/test_constant.cpp index f3c6dda9..6cd1587a 100644 --- a/test/test_constant.cpp +++ b/test/test_constant.cpp @@ -28,8 +28,6 @@ SOFTWARE. #include "UnitTest++.h" -#undef max - #include "constant.h" #include "integral_limits.h" diff --git a/test/test_integral_limits.cpp b/test/test_integral_limits.cpp index c48e6f37..8a23abf8 100644 --- a/test/test_integral_limits.cpp +++ b/test/test_integral_limits.cpp @@ -34,9 +34,6 @@ SOFTWARE. #include "integral_limits.h" -#undef min -#undef max - namespace { SUITE(test_integral_limits) diff --git a/test/test_string_char.cpp b/test/test_string_char.cpp index 9d0404f0..3d9aab80 100644 --- a/test/test_string_char.cpp +++ b/test/test_string_char.cpp @@ -35,8 +35,6 @@ SOFTWARE. #include "cstring.h" #include "fnv_1.h" -#undef min - #undef STR #define STR(x) x diff --git a/test/test_string_u16.cpp b/test/test_string_u16.cpp index 6d23555c..62de9237 100644 --- a/test/test_string_u16.cpp +++ b/test/test_string_u16.cpp @@ -34,8 +34,6 @@ SOFTWARE. #include "u16string.h" -#undef min - #undef STR #define STR(x) u##x diff --git a/test/test_string_u32.cpp b/test/test_string_u32.cpp index 8a608d4f..4cfd43f9 100644 --- a/test/test_string_u32.cpp +++ b/test/test_string_u32.cpp @@ -34,8 +34,6 @@ SOFTWARE. #include "u32string.h" -#undef min - #undef STR #define STR(x) U##x diff --git a/test/test_string_wchar_t.cpp b/test/test_string_wchar_t.cpp index c0c28a98..ff538896 100644 --- a/test/test_string_wchar_t.cpp +++ b/test/test_string_wchar_t.cpp @@ -34,8 +34,6 @@ SOFTWARE. #include "wstring.h" -#undef min - #undef STR #define STR(x) L##x From 27aa3a2ab3dc588f1e8cc7d8a375228369478040 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 29 Apr 2018 19:59:46 +0100 Subject: [PATCH 09/14] Added new binary utilities --- include/etl/binary.h | 177 +++++++++++++++++++++++- include/etl/file_error_numbers.txt | 5 +- include/etl/version.h | 4 +- support/Release notes.txt | 7 + test/test_binary.cpp | 208 ++++++++++++++++++++++++++++- 5 files changed, 391 insertions(+), 10 deletions(-) diff --git a/include/etl/binary.h b/include/etl/binary.h index 7029c3fc..c54bc1fc 100644 --- a/include/etl/binary.h +++ b/include/etl/binary.h @@ -36,7 +36,6 @@ SOFTWARE. ///\ingroup utilities #include -#include #include "platform.h" #include "type_traits.h" @@ -45,10 +44,42 @@ SOFTWARE. #include "log.h" #include "power.h" #include "smallest.h" -#include "platform.h" +#include "exception.h" +#include "error_handler.h" + +#undef ETL_FILE +#define ETL_FILE "50" namespace etl { + //*************************************************************************** + /// Exception for binary functions. + ///\ingroup binary + //*************************************************************************** + class binary_exception : public etl::exception + { + public: + + binary_exception(string_type reason_, string_type file_name_, numeric_type line_number_) + : exception(reason_, file_name_, line_number_) + { + } + }; + + //*************************************************************************** + /// Full exception 'for out of range' errors. + ///\ingroup binary + //*************************************************************************** + class binary_out_of_range : public etl::binary_exception + { + public: + + binary_out_of_range(string_type file_name_, numeric_type line_number_) + : etl::binary_exception(ETL_ERROR_TEXT("binary:out of range", ETL_FILE"A"), file_name_, line_number_) + { + } + }; + //*************************************************************************** /// Maximum value that can be contained in N bits. //*************************************************************************** @@ -310,7 +341,8 @@ namespace etl STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); STATIC_ASSERT(etl::is_integral::value, "TReturn not an integral type"); STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); - assert(NBITS <= std::numeric_limits::digits); + + ETL_ASSERT((NBITS <= std::numeric_limits::digits), ETL_ERROR(binary_out_of_range)); TReturn mask = TReturn(1U) << (NBITS - 1); value = value & ((1U << NBITS) - 1); @@ -329,7 +361,8 @@ namespace etl STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); STATIC_ASSERT(etl::is_integral::value, "TReturn not an integral type"); STATIC_ASSERT(etl::is_signed::value, "TReturn not a signed type"); - assert(NBITS <= std::numeric_limits::digits); + + ETL_ASSERT((NBITS <= std::numeric_limits::digits), ETL_ERROR(binary_out_of_range)); TReturn mask = TReturn(1U) << (NBITS - 1); value = (value >> SHIFT) & ((1U << NBITS) - 1); @@ -402,6 +435,140 @@ namespace etl template const typename bit::value_type bit::value; + //*************************************************************************** + /// Fills a value with a bit pattern. Compile time. + //*************************************************************************** + template + class binary_fill + { + private: + + STATIC_ASSERT(sizeof(TResult) >= sizeof(TValue), "Result must be at least as large as the fill value"); + STATIC_ASSERT(VALUE <= etl::integral_limits::type>::max, "Value is too large for specified type"); + + typedef typename etl::make_unsigned::type unsigned_r_t; + typedef typename etl::make_unsigned::type unsigned_v_t; + + public: + + static const TResult value = TResult(unsigned_v_t(VALUE) * (unsigned_r_t(~unsigned_r_t(0U)) / unsigned_v_t(~unsigned_v_t(0U)))); + }; + + template + const TResult binary_fill::value; + + //*************************************************************************** + /// Fills a value with a bit pattern. Run time. + //*************************************************************************** + template + class binary_fill + { + private: + + typedef typename etl::make_unsigned::type unsigned_r_t; + + public: + + template + static TResult value(TValue value) + { + STATIC_ASSERT(sizeof(TResult) >= sizeof(TValue), "Result must be at least as large as the fill value"); + + typedef typename etl::make_unsigned::type unsigned_v_t; + + return TResult(unsigned_v_t(value) * (unsigned_r_t(~unsigned_r_t(0U)) / unsigned_v_t(~unsigned_v_t(0U)))); + } + }; + +#if ETL_8BIT_SUPPORT + //*************************************************************************** + /// Detects the presence of zero bytes. Compile time. + //*************************************************************************** + template + class has_zero_byte + { + private: + + typedef typename etl::make_unsigned::type unsigned_t; + + static const unsigned_t mask = etl::binary_fill::value; + + public: + + static const bool test = unsigned_t(~((((unsigned_t(VALUE) & mask) + mask) | unsigned_t(VALUE)) | mask)) != 0U; + }; + + template + const typename etl::make_unsigned::type has_zero_byte::mask; + + template + const bool has_zero_byte::test; + + //*************************************************************************** + /// Detects the presence of zero bytes. Run time. + //*************************************************************************** + template <> + class has_zero_byte + { + public: + + template + static bool test(TValue value) + { + typedef typename etl::make_unsigned::type unsigned_t; + static const unsigned_t mask = etl::binary_fill::value; + + const unsigned_t temp = unsigned_t(~((((unsigned_t(value) & mask) + mask) | unsigned_t(value)) | mask)); + + return (temp != 0U); + } + }; + + //*************************************************************************** + /// Detects the presence of a byte of value N. Compile time. + //*************************************************************************** + template + class has_byte_n + { + public: + + static const bool test = etl::has_zero_byte::value)>::test; + }; + + template + const bool has_byte_n::test; + + //*************************************************************************** + /// Detects the presence of a byte of value N. Partial run time. + //*************************************************************************** + template + class has_byte_n + { + public: + + template + static bool test(TValue value) + { + return etl::has_zero_byte<>::test(TValue(value ^ etl::binary_fill::value)); + } + }; + + //*************************************************************************** + /// Detects the presence of a byte of value N. Run time. + //*************************************************************************** + template <> + class has_byte_n<0, void*, (void*)0> + { + public: + + template + static bool test(TValue value, uint8_t n) + { + return etl::has_zero_byte<>::test(TValue(value ^ etl::binary_fill::template value(n))); + } + }; +#endif + //*************************************************************************** /// 8 bit binary constants. //*************************************************************************** @@ -702,4 +869,6 @@ namespace etl }; } +#undef ETL_FILE + #endif diff --git a/include/etl/file_error_numbers.txt b/include/etl/file_error_numbers.txt index 40d89b45..4abc3060 100644 --- a/include/etl/file_error_numbers.txt +++ b/include/etl/file_error_numbers.txt @@ -1,4 +1,4 @@ - 1 + 1 deque 2 flat_map 3 flat_multimap 4 flat_multiset @@ -46,4 +46,5 @@ 46 queue_spsc_isr 47 queue_spsc_atomic 48 queue_mpmc_mutex -49 type_select \ No newline at end of file +49 type_select +50 binary \ No newline at end of file diff --git a/include/etl/version.h b/include/etl/version.h index 85be9694..c00eabc8 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,9 +37,9 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.7.0" +#define ETL_VERSION "11.8.0" #define ETL_VERSION_MAJOR 11 -#define ETL_VERSION_MINOR 7 +#define ETL_VERSION_MINOR 8 #define ETL_VERSION_PATCH 0 #endif diff --git a/support/Release notes.txt b/support/Release notes.txt index aedbe2fa..26605032 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,10 @@ +=============================================================================== +11.8.0 +Added more binary utilities. +binary_fill +has_zero_byte +has_byte_n + =============================================================================== 11.7.0 Modified header guards. diff --git a/test/test_binary.cpp b/test/test_binary.cpp index 5de74d2a..fc5ecbc4 100644 --- a/test/test_binary.cpp +++ b/test/test_binary.cpp @@ -1056,11 +1056,11 @@ namespace { uint8_t value8 = 0x2A; uint8_t value8mask = 0x3F; - + const uint32_t value_initial = 0x55555555; uint32_t value; - + // Shift 0 value = value_initial; value &= ~value8mask; @@ -1276,6 +1276,210 @@ namespace CHECK_EQUAL(N << 30, etl::b30); CHECK_EQUAL(N << 31, uint32_t(etl::b31)); } + + //************************************************************************* + TEST(test_binary_fill_compile_time) + { + CHECK_EQUAL(0x12U, (etl::binary_fill::value)); + CHECK_EQUAL(0x1212U, (etl::binary_fill::value)); + CHECK_EQUAL(0x12121212U, (etl::binary_fill::value)); + CHECK_EQUAL(0x1212121212121212U, (etl::binary_fill::value)); + + CHECK_EQUAL(0x12, (etl::binary_fill::value)); + CHECK_EQUAL(0x1212, (etl::binary_fill::value)); + CHECK_EQUAL(0x12121212, (etl::binary_fill::value)); + CHECK_EQUAL(0x1212121212121212, (etl::binary_fill::value)); + + CHECK_EQUAL(0x1234U, (etl::binary_fill::value)); + CHECK_EQUAL(0x12341234U, (etl::binary_fill::value)); + CHECK_EQUAL(0x1234123412341234U, (etl::binary_fill::value)); + + CHECK_EQUAL(0x1234, (etl::binary_fill::value)); + CHECK_EQUAL(0x12341234, (etl::binary_fill::value)); + CHECK_EQUAL(0x1234123412341234, (etl::binary_fill::value)); + + CHECK_EQUAL(0x12345678U, (etl::binary_fill::value)); + CHECK_EQUAL(0x1234567812345678U, (etl::binary_fill::value)); + + CHECK_EQUAL(0x12345678, (etl::binary_fill::value)); + CHECK_EQUAL(0x1234567812345678, (etl::binary_fill::value)); + + CHECK_EQUAL(0x123456789ABCDEF0U, (etl::binary_fill::value)); + + CHECK_EQUAL(0x123456789ABCDEF0, (etl::binary_fill::value)); + } + + //************************************************************************* + TEST(test_binary_fill_run_time) + { + CHECK_EQUAL(0x12U, (etl::binary_fill::value(0x12))); + CHECK_EQUAL(0x1212U, (etl::binary_fill::value(0x12))); + CHECK_EQUAL(0x12121212U, (etl::binary_fill::value(0x12))); + CHECK_EQUAL(0x1212121212121212U, (etl::binary_fill::value(0x12))); + + CHECK_EQUAL(0x12, (etl::binary_fill::value(0x12))); + CHECK_EQUAL(0x1212, (etl::binary_fill::value(0x12))); + CHECK_EQUAL(0x12121212, (etl::binary_fill::value(0x12))); + CHECK_EQUAL(0x1212121212121212, (etl::binary_fill::value(0x12))); + + CHECK_EQUAL(0x1234U, (etl::binary_fill::value(0x1234))); + CHECK_EQUAL(0x12341234U, (etl::binary_fill::value(0x1234))); + CHECK_EQUAL(0x1234123412341234U, (etl::binary_fill::value(0x1234))); + + CHECK_EQUAL(0x1234, (etl::binary_fill::value(0x1234))); + CHECK_EQUAL(0x12341234, (etl::binary_fill::value(0x1234))); + CHECK_EQUAL(0x1234123412341234, (etl::binary_fill::value(0x1234))); + + CHECK_EQUAL(0x12345678U, (etl::binary_fill::value(0x12345678))); + CHECK_EQUAL(0x1234567812345678U, (etl::binary_fill::value(0x12345678))); + + CHECK_EQUAL(int32_t(0x12345678), int32_t(etl::binary_fill::value(0x12345678))); + CHECK_EQUAL(int64_t(0x1234567812345678), int64_t(etl::binary_fill::value(0x12345678))); + + CHECK_EQUAL(0x123456789ABCDEF0U, (etl::binary_fill::value(0x123456789ABCDEF0))); + + CHECK_EQUAL(int64_t(0x123456789ABCDEF0), int64_t(etl::binary_fill::value(0x123456789ABCDEF0))); + } + + //************************************************************************* + TEST(test_has_zero_compile_time) + { + CHECK(!(etl::has_zero_byte::test)); + CHECK((etl::has_zero_byte::test)); + + CHECK(!(etl::has_zero_byte::test)); + CHECK((etl::has_zero_byte::test)); + + CHECK(!(etl::has_zero_byte::test)); + CHECK((etl::has_zero_byte::test)); + + CHECK(!(etl::has_zero_byte::test)); + CHECK((etl::has_zero_byte::test)); + + CHECK(!(etl::has_zero_byte::test)); + CHECK((etl::has_zero_byte::test)); + + CHECK(!(etl::has_zero_byte::test)); + CHECK((etl::has_zero_byte::test)); + + CHECK(!(etl::has_zero_byte::test)); + CHECK((etl::has_zero_byte::test)); + + CHECK(!(etl::has_zero_byte::test)); + CHECK((etl::has_zero_byte::test)); + } + + //************************************************************************* + TEST(test_has_zero_run_time) + { + CHECK(!(etl::has_zero_byte<>::test(uint8_t(0x01)))); + CHECK((etl::has_zero_byte<>::test(uint8_t(0x00)))); + + CHECK(!(etl::has_zero_byte<>::test(int8_t(0x01)))); + CHECK((etl::has_zero_byte<>::test(int8_t(0x00)))); + + CHECK(!(etl::has_zero_byte<>::test(uint16_t(0x0123)))); + CHECK((etl::has_zero_byte<>::test(uint16_t(0x0100)))); + + CHECK(!(etl::has_zero_byte<>::test(int16_t(0x0123)))); + CHECK((etl::has_zero_byte<>::test(int16_t(0x0100)))); + + CHECK(!(etl::has_zero_byte<>::test(uint32_t(0x01234567)))); + CHECK((etl::has_zero_byte<>::test(uint32_t(0x01230067)))); + + CHECK(!(etl::has_zero_byte<>::test(int32_t(0x01234567)))); + CHECK((etl::has_zero_byte<>::test(int32_t(0x01230067)))); + + CHECK(!(etl::has_zero_byte<>::test(uint64_t(0x0123456789ABCDEF)))); + CHECK((etl::has_zero_byte<>::test(uint64_t(0x012345678900CDEF)))); + + CHECK(!(etl::has_zero_byte<>::test(int64_t(0x0123456789ABCDEF)))); + CHECK((etl::has_zero_byte<>::test(int64_t(0x012345678900CDEF)))); + } + + //************************************************************************* + TEST(test_has_n_compile_time) + { + CHECK(!(etl::has_byte_n<0x12, uint8_t, 0x01>::test)); + CHECK((etl::has_byte_n<0x01, uint8_t, 0x01>::test)); + + CHECK(!(etl::has_byte_n<0x12, int8_t, 0x01>::test)); + CHECK((etl::has_byte_n<0x01, int8_t, 0x01>::test)); + + CHECK(!(etl::has_byte_n<0x12, uint16_t, 0x0123>::test)); + CHECK((etl::has_byte_n<0x23, uint16_t, 0x0123>::test)); + + CHECK(!(etl::has_byte_n<0x12, int16_t, 0x0123>::test)); + CHECK((etl::has_byte_n<0x23, int16_t, 0x0123>::test)); + + CHECK(!(etl::has_byte_n<0x12, uint32_t, 0x01234567>::test)); + CHECK((etl::has_byte_n<0x45, uint32_t, 0x01234567>::test)); + + CHECK(!(etl::has_byte_n<0x12, int32_t, 0x01234567>::test)); + CHECK((etl::has_byte_n<0x45, int32_t, 0x01234567>::test)); + + CHECK(!(etl::has_byte_n<0x12, uint64_t, 0x0123456789ABCDEF>::test)); + CHECK((etl::has_byte_n<0xAB, uint64_t, 0x0123456789ABCDEF>::test)); + + CHECK(!(etl::has_byte_n<0x12, int64_t, 0x0123456789ABCDEF>::test)); + CHECK((etl::has_byte_n<0xAB, int64_t, 0x0123456789ABCDEF>::test)); + } + + //************************************************************************* + TEST(test_has_n_partial_run_time) + { + CHECK(!(etl::has_byte_n<0x12>::test(uint8_t(0x01)))); + CHECK((etl::has_byte_n<0x01>::test(uint8_t(0x01)))); + + CHECK(!(etl::has_byte_n<0x12>::test(int8_t(0x01)))); + CHECK((etl::has_byte_n<0x01>::test(int8_t(0x01)))); + + CHECK(!(etl::has_byte_n<0x12>::test(uint16_t(0x0123)))); + CHECK((etl::has_byte_n<0x23>::test(uint16_t(0x0123)))); + + CHECK(!(etl::has_byte_n<0x12>::test(int16_t(0x0123)))); + CHECK((etl::has_byte_n<0x23>::test(int16_t(0x0123)))); + + CHECK(!(etl::has_byte_n<0x12>::test(uint32_t(0x01234567)))); + CHECK((etl::has_byte_n<0x45>::test(uint32_t(0x01234567)))); + + CHECK(!(etl::has_byte_n<0x12>::test(int32_t(0x01234567)))); + CHECK((etl::has_byte_n<0x45>::test(int32_t(0x01234567)))); + + CHECK(!(etl::has_byte_n<0x12>::test(uint64_t(0x0123456789ABCDEF)))); + CHECK((etl::has_byte_n<0xAB>::test(uint64_t(0x0123456789ABCDEF)))); + + CHECK(!(etl::has_byte_n<0x12>::test(int64_t(0x0123456789ABCDEF)))); + CHECK((etl::has_byte_n<0xAB>::test(int64_t(0x0123456789ABCDEF)))); + } + + //************************************************************************* + TEST(test_has_n_run_time) + { + CHECK(!(etl::has_byte_n<>::test(uint8_t(0x01), 0x12))); + CHECK((etl::has_byte_n<>::test(uint8_t(0x01), 0x01))); + + CHECK(!(etl::has_byte_n<>::test(uint8_t(0x01), 0x12))); + CHECK((etl::has_byte_n<>::test(uint8_t(0x01), 0x01))); + + CHECK(!(etl::has_byte_n<>::test(uint16_t(0x0123), 0x12))); + CHECK((etl::has_byte_n<>::test(uint16_t(0x0123), 0x23))); + + CHECK(!(etl::has_byte_n<>::test(int16_t(0x0123), 0x12))); + CHECK((etl::has_byte_n<>::test(int16_t(0x0123), 0x23))); + + CHECK(!(etl::has_byte_n<>::test(uint32_t(0x01234567), 0x12))); + CHECK((etl::has_byte_n<>::test(uint32_t(0x01234567), 0x45))); + + CHECK(!(etl::has_byte_n<>::test(int32_t(0x01234567), 0x12))); + CHECK((etl::has_byte_n<>::test(int32_t(0x01234567), 0x45))); + + CHECK(!(etl::has_byte_n<>::test(uint64_t(0x0123456789ABCDEF), 0x12))); + CHECK((etl::has_byte_n<>::test(uint64_t(0x0123456789ABCDEF), 0xAB))); + + CHECK(!(etl::has_byte_n<>::test(int64_t(0x0123456789ABCDEF), 0x12))); + CHECK((etl::has_byte_n<>::test(int64_t(0x0123456789ABCDEF), 0xAB))); + } }; } From d39e51847a1ea7e3fdaa3922f15b0393a88d532b Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 5 May 2018 09:50:49 +0100 Subject: [PATCH 10/14] Added CRC32-C (Castagnoli) --- include/etl/crc32_c.h | 108 ++++++++++++++++++++++++++++++++ src/crc32_c.cpp | 80 +++++++++++++++++++++++ test/codeblocks/ETL.cbp | 2 + test/vs2017/etl.vcxproj | 2 + test/vs2017/etl.vcxproj.filters | 6 ++ 5 files changed, 198 insertions(+) create mode 100644 include/etl/crc32_c.h create mode 100644 src/crc32_c.cpp diff --git a/include/etl/crc32_c.h b/include/etl/crc32_c.h new file mode 100644 index 00000000..cd47c145 --- /dev/null +++ b/include/etl/crc32_c.h @@ -0,0 +1,108 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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_CRC32_C_INCLUDED +#define ETL_CRC32_C_INCLUDED + +#include +#include + +#include "platform.h" +#include "frame_check_sequence.h" + +#if defined(ETL_COMPILER_KEIL) +#pragma diag_suppress 1300 +#endif + +///\defgroup crc32_c 32 bit CRC-C calculation (Castagnoli) +///\ingroup crc + +namespace etl +{ + //*************************************************************************** + /// CRC32_C table + /// \ingroup crc32_c + //*************************************************************************** + extern const uint32_t CRC32_C[]; + + //*************************************************************************** + /// CRC32_C policy. + /// Calculates CRC32_C using polynomial 0x1EDC6F41. + //*************************************************************************** + struct crc_policy_32_c + { + typedef uint32_t value_type; + + inline uint32_t initial() const + { + return 0xFFFFFFFF; + } + + inline uint32_t add(uint32_t crc, uint8_t value) const + { + return (crc >> 8) ^ CRC32_C[(crc ^ value) & 0xFF]; + } + + inline uint32_t final(uint32_t crc) const + { + return crc ^ 0xFFFFFFFF; + } + }; + + //************************************************************************* + /// CRC32_C + //************************************************************************* + class crc32_c : public etl::frame_check_sequence + { + public: + + //************************************************************************* + /// Default constructor. + //************************************************************************* + crc32_c() + { + this->reset(); + } + + //************************************************************************* + /// Constructor from range. + /// \param begin Start of the range. + /// \param end End of the range. + //************************************************************************* + template + crc32_c(TIterator begin, const TIterator end) + { + this->reset(); + this->add(begin, end); + } + }; +} + +#endif diff --git a/src/crc32_c.cpp b/src/crc32_c.cpp new file mode 100644 index 00000000..22700a32 --- /dev/null +++ b/src/crc32_c.cpp @@ -0,0 +1,80 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2018 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. +******************************************************************************/ + +#include + +#include "platform.h" + +namespace etl +{ + //*************************************************************************** + /// CRC32_C table + /// \ingroup CRC32_C + //*************************************************************************** + extern const uint32_t CRC32_C[] = + { + 0x00000000L, 0xF26B8303L, 0xE13B70F7L, 0x1350F3F4L, 0xC79A971FL, 0x35F1141CL, 0x26A1E7E8L, 0xD4CA64EBL, + 0x8AD958CFL, 0x78B2DBCCL, 0x6BE22838L, 0x9989AB3BL, 0x4D43CFD0L, 0xBF284CD3L, 0xAC78BF27L, 0x5E133C24L, + 0x105EC76FL, 0xE235446CL, 0xF165B798L, 0x030E349BL, 0xD7C45070L, 0x25AFD373L, 0x36FF2087L, 0xC494A384L, + 0x9A879FA0L, 0x68EC1CA3L, 0x7BBCEF57L, 0x89D76C54L, 0x5D1D08BFL, 0xAF768BBCL, 0xBC267848L, 0x4E4DFB4BL, + 0x20BD8EDEL, 0xD2D60DDDL, 0xC186FE29L, 0x33ED7D2AL, 0xE72719C1L, 0x154C9AC2L, 0x061C6936L, 0xF477EA35L, + 0xAA64D611L, 0x580F5512L, 0x4B5FA6E6L, 0xB93425E5L, 0x6DFE410EL, 0x9F95C20DL, 0x8CC531F9L, 0x7EAEB2FAL, + 0x30E349B1L, 0xC288CAB2L, 0xD1D83946L, 0x23B3BA45L, 0xF779DEAEL, 0x05125DADL, 0x1642AE59L, 0xE4292D5AL, + 0xBA3A117EL, 0x4851927DL, 0x5B016189L, 0xA96AE28AL, 0x7DA08661L, 0x8FCB0562L, 0x9C9BF696L, 0x6EF07595L, + 0x417B1DBCL, 0xB3109EBFL, 0xA0406D4BL, 0x522BEE48L, 0x86E18AA3L, 0x748A09A0L, 0x67DAFA54L, 0x95B17957L, + 0xCBA24573L, 0x39C9C670L, 0x2A993584L, 0xD8F2B687L, 0x0C38D26CL, 0xFE53516FL, 0xED03A29BL, 0x1F682198L, + 0x5125DAD3L, 0xA34E59D0L, 0xB01EAA24L, 0x42752927L, 0x96BF4DCCL, 0x64D4CECFL, 0x77843D3BL, 0x85EFBE38L, + 0xDBFC821CL, 0x2997011FL, 0x3AC7F2EBL, 0xC8AC71E8L, 0x1C661503L, 0xEE0D9600L, 0xFD5D65F4L, 0x0F36E6F7L, + 0x61C69362L, 0x93AD1061L, 0x80FDE395L, 0x72966096L, 0xA65C047DL, 0x5437877EL, 0x4767748AL, 0xB50CF789L, + 0xEB1FCBADL, 0x197448AEL, 0x0A24BB5AL, 0xF84F3859L, 0x2C855CB2L, 0xDEEEDFB1L, 0xCDBE2C45L, 0x3FD5AF46L, + 0x7198540DL, 0x83F3D70EL, 0x90A324FAL, 0x62C8A7F9L, 0xB602C312L, 0x44694011L, 0x5739B3E5L, 0xA55230E6L, + 0xFB410CC2L, 0x092A8FC1L, 0x1A7A7C35L, 0xE811FF36L, 0x3CDB9BDDL, 0xCEB018DEL, 0xDDE0EB2AL, 0x2F8B6829L, + 0x82F63B78L, 0x709DB87BL, 0x63CD4B8FL, 0x91A6C88CL, 0x456CAC67L, 0xB7072F64L, 0xA457DC90L, 0x563C5F93L, + 0x082F63B7L, 0xFA44E0B4L, 0xE9141340L, 0x1B7F9043L, 0xCFB5F4A8L, 0x3DDE77ABL, 0x2E8E845FL, 0xDCE5075CL, + 0x92A8FC17L, 0x60C37F14L, 0x73938CE0L, 0x81F80FE3L, 0x55326B08L, 0xA759E80BL, 0xB4091BFFL, 0x466298FCL, + 0x1871A4D8L, 0xEA1A27DBL, 0xF94AD42FL, 0x0B21572CL, 0xDFEB33C7L, 0x2D80B0C4L, 0x3ED04330L, 0xCCBBC033L, + 0xA24BB5A6L, 0x502036A5L, 0x4370C551L, 0xB11B4652L, 0x65D122B9L, 0x97BAA1BAL, 0x84EA524EL, 0x7681D14DL, + 0x2892ED69L, 0xDAF96E6AL, 0xC9A99D9EL, 0x3BC21E9DL, 0xEF087A76L, 0x1D63F975L, 0x0E330A81L, 0xFC588982L, + 0xB21572C9L, 0x407EF1CAL, 0x532E023EL, 0xA145813DL, 0x758FE5D6L, 0x87E466D5L, 0x94B49521L, 0x66DF1622L, + 0x38CC2A06L, 0xCAA7A905L, 0xD9F75AF1L, 0x2B9CD9F2L, 0xFF56BD19L, 0x0D3D3E1AL, 0x1E6DCDEEL, 0xEC064EEDL, + 0xC38D26C4L, 0x31E6A5C7L, 0x22B65633L, 0xD0DDD530L, 0x0417B1DBL, 0xF67C32D8L, 0xE52CC12CL, 0x1747422FL, + 0x49547E0BL, 0xBB3FFD08L, 0xA86F0EFCL, 0x5A048DFFL, 0x8ECEE914L, 0x7CA56A17L, 0x6FF599E3L, 0x9D9E1AE0L, + 0xD3D3E1ABL, 0x21B862A8L, 0x32E8915CL, 0xC083125FL, 0x144976B4L, 0xE622F5B7L, 0xF5720643L, 0x07198540L, + 0x590AB964L, 0xAB613A67L, 0xB831C993L, 0x4A5A4A90L, 0x9E902E7BL, 0x6CFBAD78L, 0x7FAB5E8CL, 0x8DC0DD8FL, + 0xE330A81AL, 0x115B2B19L, 0x020BD8EDL, 0xF0605BEEL, + 0x24AA3F05L, 0xD6C1BC06L, 0xC5914FF2L, 0x37FACCF1L, + 0x69E9F0D5L, 0x9B8273D6L, 0x88D28022L, 0x7AB90321L, + 0xAE7367CAL, 0x5C18E4C9L, 0x4F48173DL, 0xBD23943EL, + 0xF36E6F75L, 0x0105EC76L, 0x12551F82L, 0xE03E9C81L, + 0x34F4F86AL, 0xC69F7B69L, 0xD5CF889DL, 0x27A40B9EL, + 0x79B737BAL, 0x8BDCB4B9L, 0x988C474DL, 0x6AE7C44EL, + 0xBE2DA0A5L, 0x4C4623A6L, 0x5F16D052L, 0xAD7D5351L + }; +} diff --git a/test/codeblocks/ETL.cbp b/test/codeblocks/ETL.cbp index 65639955..b4758871 100644 --- a/test/codeblocks/ETL.cbp +++ b/test/codeblocks/ETL.cbp @@ -100,6 +100,7 @@ + @@ -240,6 +241,7 @@ + diff --git a/test/vs2017/etl.vcxproj b/test/vs2017/etl.vcxproj index abb1b7a1..eee0ad5c 100644 --- a/test/vs2017/etl.vcxproj +++ b/test/vs2017/etl.vcxproj @@ -333,6 +333,7 @@ + @@ -515,6 +516,7 @@ + diff --git a/test/vs2017/etl.vcxproj.filters b/test/vs2017/etl.vcxproj.filters index eb3e8c7a..7ba6c7d5 100644 --- a/test/vs2017/etl.vcxproj.filters +++ b/test/vs2017/etl.vcxproj.filters @@ -630,6 +630,9 @@ ETL\Utilities + + ETL\Maths + @@ -1031,6 +1034,9 @@ Source Files + + ETL\Maths + From 837da911c27524da24a9fbe09b1980bd587cd866 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 9 May 2018 23:02:50 +0100 Subject: [PATCH 11/14] Github Issue #73 Fixed issue where single shot timers could not be altered once timed out. --- include/etl/callback_timer.h | 15 ++++++----- include/etl/message_timer.h | 15 ++++++----- src/c/ecl_timer.c | 15 ++++++----- test/test_c_timer_framework.cpp | 45 +++++++++++++++++++++++++++++++++ test/test_callback_timer.cpp | 45 +++++++++++++++++++++++++++++++++ test/test_message_timer.cpp | 45 +++++++++++++++++++++++++++++++++ 6 files changed, 159 insertions(+), 21 deletions(-) diff --git a/include/etl/callback_timer.h b/include/etl/callback_timer.h index c0b4c72d..f4362341 100644 --- a/include/etl/callback_timer.h +++ b/include/etl/callback_timer.h @@ -423,13 +423,13 @@ namespace etl ETL_DISABLE_TIMER_UPDATES; active_list.remove(timer.id, false); ETL_ENABLE_TIMER_UPDATES; - - // Reset in-place. - new (&timer) callback_timer_data(); - --registered_timers; - - result = true; } + + // Reset in-place. + new (&timer) callback_timer_data(); + --registered_timers; + + result = true; } } @@ -588,8 +588,9 @@ namespace etl ETL_DISABLE_TIMER_UPDATES; active_list.remove(timer.id, false); ETL_ENABLE_TIMER_UPDATES; - result = true; } + + result = true; } } diff --git a/include/etl/message_timer.h b/include/etl/message_timer.h index 9ec27add..635845af 100644 --- a/include/etl/message_timer.h +++ b/include/etl/message_timer.h @@ -392,13 +392,13 @@ namespace etl ETL_DISABLE_TIMER_UPDATES; active_list.remove(timer.id, true); ETL_ENABLE_TIMER_UPDATES; - - // Reset in-place. - new (&timer) message_timer_data(); - --registered_timers; - - result = true; } + + // Reset in-place. + new (&timer) message_timer_data(); + --registered_timers; + + result = true; } } @@ -557,8 +557,9 @@ namespace etl ETL_DISABLE_TIMER_UPDATES; active_list.remove(timer.id, false); ETL_ENABLE_TIMER_UPDATES; - result = true; } + + result = true; } } diff --git a/src/c/ecl_timer.c b/src/c/ecl_timer.c index 004ee669..3f57f01d 100644 --- a/src/c/ecl_timer.c +++ b/src/c/ecl_timer.c @@ -340,13 +340,13 @@ ecl_timer_result_t ecl_timer_unregister(ecl_timer_id_t id_) ECL_TIMER_DISABLE_PROCESSING; ecl_timer_list_remove(ptimer->id, 0); ECL_TIMER_ENABLE_PROCESSING; - - // Reset in-place. - ecl_timer_data_init_default(ptimer); - --ecl.registered_timers; - - result = ECL_TIMER_PASS; } + + // Reset in-place. + ecl_timer_data_init_default(ptimer); + --ecl.registered_timers; + + result = ECL_TIMER_PASS; } } @@ -506,8 +506,9 @@ ecl_timer_result_t ecl_timer_stop(ecl_timer_id_t id_) ECL_TIMER_DISABLE_PROCESSING; ecl_timer_list_remove(ptimer->id, 0); ECL_TIMER_ENABLE_PROCESSING; - result = ECL_TIMER_PASS; } + + result = ECL_TIMER_PASS; } } diff --git a/test/test_c_timer_framework.cpp b/test/test_c_timer_framework.cpp index 47aa0aa9..c6dcff92 100644 --- a/test/test_c_timer_framework.cpp +++ b/test/test_c_timer_framework.cpp @@ -149,6 +149,51 @@ namespace CHECK_ARRAY_EQUAL(compare3.data(), callback_list3.data(), compare3.size()); } + //========================================================================= + TEST(message_timer_one_shot_after_timeout) + { + ecl_timer_init(timers, NTIMERS); + + ecl_timer_id_t id1 = ecl_timer_register(callback1, 37, ECL_TIMER_SINGLE_SHOT); + callback_list1.clear(); + + ecl_timer_enable(ECL_TIMER_ENABLED); + ecl_timer_start(id1, ECL_TIMER_START_DELAYED); + + ticks = 0; + + const uint32_t step = 1; + + while (ticks <= 100U) + { + ticks += step; + ecl_timer_tick(step); + } + + // Timer should have timed out. + + CHECK(ecl_timer_set_period(id1, 50)); + + callback_list1.clear(); + + ticks = 0; + + while (ticks <= 100U) + { + ticks += step; + ecl_timer_tick(step); + } + + // Timer should have timed out. + + CHECK_EQUAL(50, *callback_list1.data()); + + CHECK(ecl_timer_unregister(id1)); + CHECK(!ecl_timer_unregister(id1)); + CHECK(!ecl_timer_start(id1, ECL_TIMER_START_DELAYED)); + CHECK(!ecl_timer_stop(id1)); + } + //========================================================================= TEST(ecl_timer_repeating) { diff --git a/test/test_callback_timer.cpp b/test/test_callback_timer.cpp index eed41124..1c63308d 100644 --- a/test/test_callback_timer.cpp +++ b/test/test_callback_timer.cpp @@ -169,6 +169,51 @@ namespace CHECK_ARRAY_EQUAL(compare3.data(), free_tick_list2.data(), compare3.size()); } + //========================================================================= + TEST(message_timer_one_shot_after_timeout) + { + etl::callback_timer<1> timer_controller; + + etl::timer::id::type id1 = timer_controller.register_timer(member_callback, 37, etl::timer::mode::SINGLE_SHOT); + test.tick_list.clear(); + + timer_controller.start(id1); + timer_controller.enable(true); + + ticks = 0; + + const uint32_t step = 1; + + while (ticks <= 100U) + { + ticks += step; + timer_controller.tick(step); + } + + // Timer should have timed out. + + CHECK(timer_controller.set_period(id1, 50)); + + test.tick_list.clear(); + + ticks = 0; + + while (ticks <= 100U) + { + ticks += step; + timer_controller.tick(step); + } + + // Timer should have timed out. + + CHECK_EQUAL(50, *test.tick_list.data()); + + CHECK(timer_controller.unregister_timer(id1)); + CHECK(!timer_controller.unregister_timer(id1)); + CHECK(!timer_controller.start(id1)); + CHECK(!timer_controller.stop(id1)); + } + //========================================================================= TEST(callback_timer_repeating) { diff --git a/test/test_message_timer.cpp b/test/test_message_timer.cpp index b8b3488c..c8cec00c 100644 --- a/test/test_message_timer.cpp +++ b/test/test_message_timer.cpp @@ -191,6 +191,51 @@ namespace CHECK_ARRAY_EQUAL(compare3.data(), router1.message3.data(), compare3.size()); } + //========================================================================= + TEST(message_timer_one_shot_after_timeout) + { + etl::message_timer<1> timer_controller; + + etl::timer::id::type id1 = timer_controller.register_timer(message1, router1, 37, etl::timer::mode::SINGLE_SHOT); + router1.clear(); + + timer_controller.start(id1); + timer_controller.enable(true); + + ticks = 0; + + const uint32_t step = 1; + + while (ticks <= 100U) + { + ticks += step; + timer_controller.tick(step); + } + + // Timer should have timed out. + + CHECK(timer_controller.set_period(id1, 50)); + + router1.clear(); + + ticks = 0; + + while (ticks <= 100U) + { + ticks += step; + timer_controller.tick(step); + } + + // Timer should have timed out. + + CHECK_EQUAL(50, *router1.message1.data()); + + CHECK(timer_controller.unregister_timer(id1)); + CHECK(!timer_controller.unregister_timer(id1)); + CHECK(!timer_controller.start(id1)); + CHECK(!timer_controller.stop(id1)); + } + //========================================================================= TEST(message_timer_repeating) { From 681bc407ac8c866eca136910c55e9e1582ee0903 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 9 May 2018 23:11:56 +0100 Subject: [PATCH 12/14] Github Issue #73 set_period & set_mode no longer automatically start the timer. --- include/etl/callback_timer.h | 4 ++-- include/etl/message_timer.h | 4 ++-- src/c/ecl_timer.c | 4 ++-- test/test_c_timer_framework.cpp | 1 + test/test_callback_timer.cpp | 1 + test/test_message_timer.cpp | 1 + 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/etl/callback_timer.h b/include/etl/callback_timer.h index f4362341..2547e346 100644 --- a/include/etl/callback_timer.h +++ b/include/etl/callback_timer.h @@ -605,7 +605,7 @@ namespace etl if (stop(id_)) { timer_array[id_].period = period_; - return start(id_); + return true; } return false; @@ -619,7 +619,7 @@ namespace etl if (stop(id_)) { timer_array[id_].repeating = repeating_; - return start(id_); + return true; } return false; diff --git a/include/etl/message_timer.h b/include/etl/message_timer.h index 635845af..9dab4780 100644 --- a/include/etl/message_timer.h +++ b/include/etl/message_timer.h @@ -574,7 +574,7 @@ namespace etl if (stop(id_)) { timer_array[id_].period = period_; - return start(id_); + return true; } return false; @@ -588,7 +588,7 @@ namespace etl if (stop(id_)) { timer_array[id_].repeating = repeating_; - return start(id_); + return true; } return false; diff --git a/src/c/ecl_timer.c b/src/c/ecl_timer.c index 3f57f01d..145cb3e3 100644 --- a/src/c/ecl_timer.c +++ b/src/c/ecl_timer.c @@ -525,7 +525,7 @@ ecl_timer_result_t ecl_timer_set_period(ecl_timer_id_t id_, ecl_timer_time_t per if (ecl_timer_stop(id_)) { ecl.ptimers[id_].period = period_; - return ecl_timer_start(id_, 0); + return ECL_TIMER_PASS; } return ECL_TIMER_FAIL; @@ -541,7 +541,7 @@ ecl_timer_result_t ecl_timer_set_mode(ecl_timer_id_t id_, ecl_timer_mode_t repea if (ecl_timer_stop(id_)) { ecl.ptimers[id_].repeating = repeating_; - return ecl_timer_start(id_, 0); + return ECL_TIMER_PASS; } return ECL_TIMER_FAIL; diff --git a/test/test_c_timer_framework.cpp b/test/test_c_timer_framework.cpp index c6dcff92..ec03f140 100644 --- a/test/test_c_timer_framework.cpp +++ b/test/test_c_timer_framework.cpp @@ -173,6 +173,7 @@ namespace // Timer should have timed out. CHECK(ecl_timer_set_period(id1, 50)); + ecl_timer_start(id1, ECL_TIMER_START_DELAYED); callback_list1.clear(); diff --git a/test/test_callback_timer.cpp b/test/test_callback_timer.cpp index 1c63308d..5cf31bb4 100644 --- a/test/test_callback_timer.cpp +++ b/test/test_callback_timer.cpp @@ -193,6 +193,7 @@ namespace // Timer should have timed out. CHECK(timer_controller.set_period(id1, 50)); + timer_controller.start(id1); test.tick_list.clear(); diff --git a/test/test_message_timer.cpp b/test/test_message_timer.cpp index c8cec00c..e7659d80 100644 --- a/test/test_message_timer.cpp +++ b/test/test_message_timer.cpp @@ -215,6 +215,7 @@ namespace // Timer should have timed out. CHECK(timer_controller.set_period(id1, 50)); + timer_controller.start(id1); router1.clear(); From 9435d7b1fb2ed08f1547ba9f641026de7e3f7885 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 9 May 2018 23:14:32 +0100 Subject: [PATCH 13/14] Github Issue #73 Updated version --- include/etl/version.h | 6 +++--- support/Release notes.txt | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/etl/version.h b/include/etl/version.h index c00eabc8..21282bce 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,10 +37,10 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.8.0" +#define ETL_VERSION "11.9.1" #define ETL_VERSION_MAJOR 11 -#define ETL_VERSION_MINOR 8 -#define ETL_VERSION_PATCH 0 +#define ETL_VERSION_MINOR 9 +#define ETL_VERSION_PATCH 1 #endif diff --git a/support/Release notes.txt b/support/Release notes.txt index 26605032..7fec4cc5 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,11 @@ +=============================================================================== +11.9.1 +Fix Github issue #73 (Timers) + +=============================================================================== +11.9.0 +Added CRC32-C (Castagnoli) + =============================================================================== 11.8.0 Added more binary utilities. From 35d6fc533cbfa3cea085c9422a4bd1928e00a1e4 Mon Sep 17 00:00:00 2001 From: "EXPROGROUP\\john.wellbelove" Date: Thu, 10 May 2018 15:26:23 +0100 Subject: [PATCH 14/14] Fixed compile error when ETL_DEBUG_COUNT not defined --- include/etl/debug_count.h | 14 +++++++------- include/etl/version.h | 4 ++-- support/Release notes.txt | 4 ++++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/etl/debug_count.h b/include/etl/debug_count.h index 3aeede54..e3672d32 100644 --- a/include/etl/debug_count.h +++ b/include/etl/debug_count.h @@ -122,16 +122,16 @@ namespace etl int32_t count; }; +} #else -#define ETL_DECLARE_DEBUG_COUNT -#define ETL_INCREMENT_DEBUG_COUNT -#define ETL_DECREMENT_DEBUG_COUNT -#define ETL_ADD_DEBUG_COUNT(n) -#define ETL_SUBTRACT_DEBUG_COUNT(n) -#define ETL_RESET_DEBUG_COUNT + #define ETL_DECLARE_DEBUG_COUNT + #define ETL_INCREMENT_DEBUG_COUNT + #define ETL_DECREMENT_DEBUG_COUNT + #define ETL_ADD_DEBUG_COUNT(n) + #define ETL_SUBTRACT_DEBUG_COUNT(n) + #define ETL_RESET_DEBUG_COUNT #endif // ETL_DEBUG_COUNT -} #endif diff --git a/include/etl/version.h b/include/etl/version.h index 21282bce..fa2e0a6d 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,10 +37,10 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.9.1" +#define ETL_VERSION "11.9.2" #define ETL_VERSION_MAJOR 11 #define ETL_VERSION_MINOR 9 -#define ETL_VERSION_PATCH 1 +#define ETL_VERSION_PATCH 2 #endif diff --git a/support/Release notes.txt b/support/Release notes.txt index 7fec4cc5..09ce8ee4 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +11.9.2 +Fixed compile error when ETL_DEBUG_COUNT is not defined. + =============================================================================== 11.9.1 Fix Github issue #73 (Timers)