diff --git a/examples/ArmTimerCallbacks - C++/main.cpp b/examples/ArmTimerCallbacks - C++/main.cpp index 7f002981..d623ba74 100644 --- a/examples/ArmTimerCallbacks - C++/main.cpp +++ b/examples/ArmTimerCallbacks - C++/main.cpp @@ -17,6 +17,7 @@ extern "C" #include "etl/callback_timer.h" #include "etl/vector.h" #include "etl/iterator.h" +#include "etl/binary.h" struct FP { diff --git a/include/etl/alignment.h b/include/etl/alignment.h index b2e53866..5ebabba5 100644 --- a/include/etl/alignment.h +++ b/include/etl/alignment.h @@ -99,7 +99,11 @@ namespace etl { public: +#if defined(ETL_NO_64BIT_TYPES) + typedef typename private_alignment::type_with_alignment_helper::type type; +#else typedef typename private_alignment::type_with_alignment_helper::type type; +#endif }; //*************************************************************************** diff --git a/include/etl/atomic/atomic_gcc_sync.h b/include/etl/atomic/atomic_gcc_sync.h index e2d51cd9..da86e89e 100644 --- a/include/etl/atomic/atomic_gcc_sync.h +++ b/include/etl/atomic/atomic_gcc_sync.h @@ -763,24 +763,30 @@ namespace etl typedef etl::atomic atomic_int16_t; typedef etl::atomic atomic_uint32_t; typedef etl::atomic atomic_int32_t; +#if !defined(ETL_NO_64BIT_TYPES) typedef etl::atomic atomic_uint64_t; typedef etl::atomic atomic_int64_t; +#endif typedef etl::atomic atomic_int_least8_t; typedef etl::atomic atomic_uint_least8_t; typedef etl::atomic atomic_int_least16_t; typedef etl::atomic atomic_uint_least16_t; typedef etl::atomic atomic_int_least32_t; typedef etl::atomic atomic_uint_least32_t; +#if !defined(ETL_NO_64BIT_TYPES) typedef etl::atomic atomic_int_least64_t; typedef etl::atomic atomic_uint_least64_t; +#endif typedef etl::atomic atomic_int_fast8_t; typedef etl::atomic atomic_uint_fast8_t; typedef etl::atomic atomic_int_fast16_t; typedef etl::atomic atomic_uint_fast16_t; typedef etl::atomic atomic_int_fast32_t; typedef etl::atomic atomic_uint_fast32_t; +#if !defined(ETL_NO_64BIT_TYPES) typedef etl::atomic atomic_int_fast64_t; typedef etl::atomic atomic_uint_fast64_t; +#endif typedef etl::atomic atomic_intptr_t; typedef etl::atomic atomic_uintptr_t; typedef etl::atomic atomic_size_t; diff --git a/include/etl/atomic/atomic_std.h b/include/etl/atomic/atomic_std.h index 7a28a930..9c160f71 100644 --- a/include/etl/atomic/atomic_std.h +++ b/include/etl/atomic/atomic_std.h @@ -576,24 +576,30 @@ namespace etl typedef std::atomic atomic_int16_t; typedef std::atomic atomic_uint32_t; typedef std::atomic atomic_int32_t; +#if !defined(ETL_NO_64BIT_TYPES) typedef std::atomic atomic_uint64_t; typedef std::atomic atomic_int64_t; +#endif typedef std::atomic atomic_int_least8_t; typedef std::atomic atomic_uint_least8_t; typedef std::atomic atomic_int_least16_t; typedef std::atomic atomic_uint_least16_t; typedef std::atomic atomic_int_least32_t; typedef std::atomic atomic_uint_least32_t; +#if !defined(ETL_NO_64BIT_TYPES) typedef std::atomic atomic_int_least64_t; typedef std::atomic atomic_uint_least64_t; +#endif typedef std::atomic atomic_int_fast8_t; typedef std::atomic atomic_uint_fast8_t; typedef std::atomic atomic_int_fast16_t; typedef std::atomic atomic_uint_fast16_t; typedef std::atomic atomic_int_fast32_t; typedef std::atomic atomic_uint_fast32_t; +#if !defined(ETL_NO_64BIT_TYPES) typedef std::atomic atomic_int_fast64_t; typedef std::atomic atomic_uint_fast64_t; +#endif typedef std::atomic atomic_intptr_t; typedef std::atomic atomic_uintptr_t; typedef std::atomic atomic_size_t; diff --git a/include/etl/binary.h b/include/etl/binary.h index f81f3d05..48961fa2 100644 --- a/include/etl/binary.h +++ b/include/etl/binary.h @@ -38,6 +38,7 @@ SOFTWARE. #include "platform.h" #include "type_traits.h" #include "integral_limits.h" +#include "limits.h" #include "static_assert.h" #include "log.h" #include "power.h" @@ -45,8 +46,6 @@ SOFTWARE. #include "exception.h" #include "error_handler.h" -#include "limits.h" - #undef ETL_FILE #define ETL_FILE "50" @@ -103,12 +102,17 @@ namespace etl template const typename max_value_for_nbits::value_type max_value_for_nbits::value; +#if ETL_CPP17_SUPPORTED + template + inline constexpr typename etl::max_value_for_nbits::value_type max_value_for_nbits_v = max_value_for_nbits::value; +#endif + //*************************************************************************** /// Rotate left. ///\ingroup binary //*************************************************************************** template - T rotate_left(T value) + ETL_CONSTEXPR14 T rotate_left(T value) { ETL_STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); @@ -122,7 +126,7 @@ namespace etl ///\ingroup binary //*************************************************************************** template - T rotate_left(T value, size_t distance) + ETL_CONSTEXPR14 T rotate_left(T value, size_t distance) { ETL_STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); @@ -138,7 +142,7 @@ namespace etl ///\ingroup binary //*************************************************************************** template - T rotate_right(T value) + ETL_CONSTEXPR14 T rotate_right(T value) { ETL_STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); @@ -152,7 +156,7 @@ namespace etl ///\ingroup binary //*************************************************************************** template - T rotate_right(T value, size_t distance) + ETL_CONSTEXPR14 T rotate_right(T value, size_t distance) { ETL_STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); @@ -169,11 +173,11 @@ namespace etl ///\ingroup binary //*************************************************************************** template - T rotate(T value, typename etl::make_signed::type distance) + ETL_CONSTEXPR14 T rotate(T value, typename etl::make_signed::type distance) { ETL_STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); - T result; + T result = T(); if (distance > 0) { @@ -192,7 +196,7 @@ namespace etl ///\ingroup binary //*************************************************************************** template - T binary_to_gray(T value) + ETL_CONSTEXPR T binary_to_gray(T value) { ETL_STATIC_ASSERT(etl::is_integral::value, "Not an integral type"); @@ -204,7 +208,7 @@ namespace etl ///\ingroup binary //*************************************************************************** template - TReturn fold_bits(TValue value) + ETL_CONSTEXPR14 TReturn fold_bits(TValue value) { ETL_STATIC_ASSERT(integral_limits::bits >= NBITS, "Return type too small to hold result"); @@ -233,7 +237,7 @@ namespace etl ///\ingroup binary //*************************************************************************** template - TReturn sign_extend(TValue value) + ETL_CONSTEXPR14 TReturn sign_extend(TValue value) { ETL_STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); ETL_STATIC_ASSERT(etl::is_integral::value, "TReturn not an integral type"); @@ -243,7 +247,7 @@ namespace etl struct S { signed value : NBITS; - } s; + } s = {0}; return (s.value = value); } @@ -255,7 +259,7 @@ namespace etl ///\ingroup binary //*************************************************************************** template - TReturn sign_extend(TValue value) + ETL_CONSTEXPR14 TReturn sign_extend(TValue value) { ETL_STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); ETL_STATIC_ASSERT(etl::is_integral::value, "TReturn not an integral type"); @@ -266,7 +270,7 @@ namespace etl struct S { signed value : NBITS; - } s; + } s = {0}; return (s.value = (value >> SHIFT)); } @@ -277,7 +281,7 @@ namespace etl ///\ingroup binary //*************************************************************************** template - TReturn sign_extend(TValue value, const size_t NBITS) + ETL_CONSTEXPR14 TReturn sign_extend(TValue value, const size_t NBITS) { ETL_STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); ETL_STATIC_ASSERT(etl::is_integral::value, "TReturn not an integral type"); @@ -298,7 +302,7 @@ namespace etl ///\ingroup binary //*************************************************************************** template - TReturn sign_extend(TValue value, const size_t NBITS, const size_t SHIFT) + ETL_CONSTEXPR14 TReturn sign_extend(TValue value, const size_t NBITS, const size_t SHIFT) { ETL_STATIC_ASSERT(etl::is_integral::value, "TValue not an integral type"); ETL_STATIC_ASSERT(etl::is_integral::value, "TReturn not an integral type"); @@ -312,15 +316,13 @@ namespace etl return TReturn((value ^ mask) - mask); } - - //*************************************************************************** /// Find the position of the first set bit. /// Starts from LSB. ///\ingroup binary //*************************************************************************** template - uint_least8_t first_set_bit_position(T value) + ETL_CONSTEXPR14 uint_least8_t first_set_bit_position(T value) { return count_trailing_zeros(value); } @@ -331,7 +333,7 @@ namespace etl ///\ingroup binary //*************************************************************************** template - uint_least8_t first_clear_bit_position(T value) + ETL_CONSTEXPR14 uint_least8_t first_clear_bit_position(T value) { value = ~value; return count_trailing_zeros(value); @@ -343,7 +345,7 @@ namespace etl ///\ingroup binary //*************************************************************************** template - uint_least8_t first_bit_position(bool state, T value) + ETL_CONSTEXPR14 uint_least8_t first_bit_position(bool state, T value) { if (!state) { @@ -368,145 +370,60 @@ namespace etl template const typename bit::value_type bit::value; +#if ETL_CPP17_SUPPORTED + template + inline constexpr typename bit::value_type bit_v = bit::value; +#endif + //*************************************************************************** - /// Fills a value with a bit pattern. Compile time. + /// Fills a value with a bit pattern. ///\ingroup binary //*************************************************************************** - template - class binary_fill + template + ETL_CONSTEXPR TResult binary_fill(TValue value) { - private: - ETL_STATIC_ASSERT(sizeof(TResult) >= sizeof(TValue), "Result must be at least as large as the fill value"); - ETL_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; + 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. - ///\ingroup binary - //*************************************************************************** - template - class binary_fill - { - private: - - typedef typename etl::make_unsigned::type unsigned_r_t; - - public: - - template - static TResult value(TValue value) - { - ETL_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)))); - } - }; + 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. + /// Detects the presence of zero bytes. ///\ingroup binary //*************************************************************************** - template - class has_zero_byte + template + ETL_CONSTEXPR14 bool has_zero_byte(const TValue value) { - private: - typedef typename etl::make_unsigned::type unsigned_t; + const unsigned_t mask = etl::binary_fill(0x7FU); + const unsigned_t temp = unsigned_t(~((((unsigned_t(value) & mask) + mask) | unsigned_t(value)) | mask)); - 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. - ///\ingroup binary - //*************************************************************************** - 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. - ///\ingroup binary - //*************************************************************************** - 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. - ///\ingroup binary - //*************************************************************************** - template - class has_byte_n - { - public: - - template - static bool test(TValue value) - { - return etl::has_zero_byte<>::test(TValue(value ^ etl::binary_fill::value)); - } - }; + return (temp != 0U); + } //*************************************************************************** /// Detects the presence of a byte of value N. Run time. ///\ingroup binary //*************************************************************************** - template <> - class has_byte_n<0, void*, (void*)0> + template + ETL_CONSTEXPR14 bool has_byte_n(TValue value, uint8_t n) { - public: + return etl::has_zero_byte(TValue(value ^ etl::binary_fill(n))); + } - template - static bool test(TValue value, uint8_t n) - { - return etl::has_zero_byte<>::test(TValue(value ^ etl::binary_fill::template value(n))); - } - }; + //*************************************************************************** + /// Detects the presence of a byte of value N. Partial time. + ///\ingroup binary + //*************************************************************************** + template + ETL_CONSTEXPR14 bool has_byte_n(TValue value) + { + return etl::has_zero_byte(TValue(value ^ etl::binary_fill(N))); + } #endif //*************************************************************************** @@ -516,7 +433,7 @@ namespace etl ///\ingroup binary //*************************************************************************** template - T binary_merge(const T first, const T second, const T mask) + ETL_CONSTEXPR T binary_merge(const T first, const T second, const T mask) { return second ^ ((second ^ first) & mask); } @@ -528,7 +445,7 @@ namespace etl ///\ingroup binary //*************************************************************************** template - T binary_merge(const T first, const T second) + ETL_CONSTEXPR T binary_merge(const T first, const T second) { return second ^ ((second ^ first) & MASK); } @@ -538,7 +455,7 @@ namespace etl /// Reverse 8 bits. ///\ingroup binary //*************************************************************************** - inline uint8_t reverse_bits(uint8_t value) + inline ETL_CONSTEXPR14 uint8_t reverse_bits(uint8_t value) { value = ((value & 0xAA) >> 1) | ((value & 0x55) << 1); value = ((value & 0xCC) >> 2) | ((value & 0x33) << 2); @@ -547,7 +464,7 @@ namespace etl return value; } - inline int8_t reverse_bits(int8_t value) + inline ETL_CONSTEXPR14 int8_t reverse_bits(int8_t value) { return int8_t(reverse_bits(uint8_t(value))); } @@ -557,7 +474,7 @@ namespace etl /// Reverse 16 bits. ///\ingroup binary //*************************************************************************** - inline uint16_t reverse_bits(uint16_t value) + inline ETL_CONSTEXPR14 uint16_t reverse_bits(uint16_t value) { value = ((value & 0xAAAA) >> 1) | ((value & 0x5555) << 1); value = ((value & 0xCCCC) >> 2) | ((value & 0x3333) << 2); @@ -567,7 +484,7 @@ namespace etl return value; } - inline int16_t reverse_bits(int16_t value) + inline ETL_CONSTEXPR14 int16_t reverse_bits(int16_t value) { return int16_t(reverse_bits(uint16_t(value))); } @@ -576,7 +493,7 @@ namespace etl /// Reverse 32 bits. ///\ingroup binary //*************************************************************************** - inline uint32_t reverse_bits(uint32_t value) + inline ETL_CONSTEXPR14 uint32_t reverse_bits(uint32_t value) { value = ((value & 0xAAAAAAAA) >> 1) | ((value & 0x55555555) << 1); value = ((value & 0xCCCCCCCC) >> 2) | ((value & 0x33333333) << 2); @@ -587,16 +504,17 @@ namespace etl return value; } - inline int32_t reverse_bits(int32_t value) + inline ETL_CONSTEXPR14 int32_t reverse_bits(int32_t value) { return int32_t(reverse_bits(uint32_t(value))); } +#if !defined(ETL_NO_64BIT_TYPES) //*************************************************************************** /// Reverse 64 bits. ///\ingroup binary //*************************************************************************** - inline uint64_t reverse_bits(uint64_t value) + inline ETL_CONSTEXPR14 uint64_t reverse_bits(uint64_t value) { value = ((value & 0xAAAAAAAAAAAAAAAA) >> 1) | ((value & 0x5555555555555555) << 1); value = ((value & 0xCCCCCCCCCCCCCCCC) >> 2) | ((value & 0x3333333333333333) << 2); @@ -608,22 +526,23 @@ namespace etl return value; } - inline int64_t reverse_bits(int64_t value) + inline ETL_CONSTEXPR14 int64_t reverse_bits(int64_t value) { return int64_t(reverse_bits(uint64_t(value))); } +#endif //*************************************************************************** /// Reverse bytes 8 bit. ///\ingroup binary //*************************************************************************** #if ETL_8BIT_SUPPORT - inline uint8_t reverse_bytes(uint8_t value) + inline ETL_CONSTEXPR uint8_t reverse_bytes(uint8_t value) { return value; } - inline int8_t reverse_bytes(int8_t value) + inline ETL_CONSTEXPR int8_t reverse_bytes(int8_t value) { return value; } @@ -633,14 +552,12 @@ namespace etl /// Reverse bytes 16 bit. ///\ingroup binary //*************************************************************************** - inline uint16_t reverse_bytes(uint16_t value) + inline ETL_CONSTEXPR uint16_t reverse_bytes(uint16_t value) { - value = (value >> 8) | (value << 8); - - return value; + return (value >> 8) | (value << 8); } - inline int16_t reverse_bytes(int16_t value) + inline ETL_CONSTEXPR int16_t reverse_bytes(int16_t value) { return int16_t(reverse_bytes(uint16_t(value))); } @@ -649,7 +566,7 @@ namespace etl /// Reverse bytes 32 bit. ///\ingroup binary //*************************************************************************** - inline uint32_t reverse_bytes(uint32_t value) + inline ETL_CONSTEXPR14 uint32_t reverse_bytes(uint32_t value) { value = ((value & 0xFF00FF00) >> 8) | ((value & 0x00FF00FF) << 8); value = (value >> 16) | (value << 16); @@ -657,16 +574,17 @@ namespace etl return value; } - inline int32_t reverse_bytes(int32_t value) + inline ETL_CONSTEXPR14 int32_t reverse_bytes(int32_t value) { return int32_t(reverse_bytes(uint32_t(value))); } +#if !defined(ETL_NO_64BIT_TYPES) //*************************************************************************** /// Reverse bytes 64 bit. ///\ingroup binary //*************************************************************************** - inline uint64_t reverse_bytes(uint64_t value) + inline ETL_CONSTEXPR14 uint64_t reverse_bytes(uint64_t value) { value = ((value & 0xFF00FF00FF00FF00) >> 8) | ((value & 0x00FF00FF00FF00FF) << 8); value = ((value & 0xFFFF0000FFFF0000) >> 16) | ((value & 0x0000FFFF0000FFFF) << 16); @@ -675,17 +593,18 @@ namespace etl return value; } - inline int64_t reverse_bytes(int64_t value) + inline ETL_CONSTEXPR14 int64_t reverse_bytes(int64_t value) { return int64_t(reverse_bytes(uint64_t(value))); } +#endif #if ETL_8BIT_SUPPORT //*************************************************************************** /// Converts Gray code to binary. ///\ingroup binary //*************************************************************************** - inline uint8_t gray_to_binary(uint8_t value) + inline ETL_CONSTEXPR14 uint8_t gray_to_binary(uint8_t value) { value ^= (value >> 4); value ^= (value >> 2); @@ -694,7 +613,7 @@ namespace etl return value; } - inline int8_t gray_to_binary(int8_t value) + inline ETL_CONSTEXPR14 int8_t gray_to_binary(int8_t value) { return int8_t(gray_to_binary(uint8_t(value))); } @@ -704,7 +623,7 @@ namespace etl /// Converts Gray code to binary. ///\ingroup binary //*************************************************************************** - inline uint16_t gray_to_binary(uint16_t value) + inline ETL_CONSTEXPR14 uint16_t gray_to_binary(uint16_t value) { value ^= (value >> 8); value ^= (value >> 4); @@ -714,7 +633,7 @@ namespace etl return value; } - inline int16_t gray_to_binary(int16_t value) + inline ETL_CONSTEXPR14 int16_t gray_to_binary(int16_t value) { return int16_t(gray_to_binary(uint16_t(value))); } @@ -723,7 +642,7 @@ namespace etl /// Converts Gray code to binary. ///\ingroup binary //*************************************************************************** - inline uint32_t gray_to_binary(uint32_t value) + inline ETL_CONSTEXPR14 uint32_t gray_to_binary(uint32_t value) { value ^= (value >> 16); value ^= (value >> 8); @@ -734,16 +653,17 @@ namespace etl return value; } - inline int32_t gray_to_binary(int32_t value) + inline ETL_CONSTEXPR14 int32_t gray_to_binary(int32_t value) { return int32_t(gray_to_binary(uint32_t(value))); } +#if !defined(ETL_NO_64BIT_TYPES) //*************************************************************************** /// Converts Gray code to binary. ///\ingroup binary //*************************************************************************** - inline uint64_t gray_to_binary(uint64_t value) + inline ETL_CONSTEXPR14 uint64_t gray_to_binary(uint64_t value) { value ^= (value >> 32); value ^= (value >> 16); @@ -755,19 +675,20 @@ namespace etl return value; } - inline int64_t gray_to_binary(int64_t value) + inline ETL_CONSTEXPR14 int64_t gray_to_binary(int64_t value) { return int64_t(gray_to_binary(uint64_t(value))); } +#endif #if ETL_8BIT_SUPPORT //*************************************************************************** /// Count set bits. 8 bits. ///\ingroup binary //*************************************************************************** - inline uint_least8_t count_bits(uint8_t value) + inline ETL_CONSTEXPR14 uint_least8_t count_bits(uint8_t value) { - uint32_t count; + uint32_t count = 0U; count = value - ((value >> 1) & 0x55); count = ((count >> 2) & 0x33) + (count & 0x33); @@ -776,7 +697,7 @@ namespace etl return uint_least8_t(count); } - inline uint_least8_t count_bits(int8_t value) + inline ETL_CONSTEXPR14 uint_least8_t count_bits(int8_t value) { return count_bits(uint8_t(value)); } @@ -787,9 +708,9 @@ namespace etl /// Count set bits. 16 bits. ///\ingroup binary //*************************************************************************** - inline uint_least8_t count_bits(uint16_t value) + inline ETL_CONSTEXPR14 uint_least8_t count_bits(uint16_t value) { - uint32_t count; + uint32_t count = 0U; count = value - ((value >> 1) & 0x5555); count = ((count >> 2) & 0x3333) + (count & 0x3333); @@ -799,7 +720,7 @@ namespace etl return count; } - inline uint_least8_t count_bits(int16_t value) + inline ETL_CONSTEXPR14 uint_least8_t count_bits(int16_t value) { return count_bits(uint16_t(value)); } @@ -808,9 +729,9 @@ namespace etl /// Count set bits. 32 bits. ///\ingroup binary //*************************************************************************** - inline uint_least8_t count_bits(uint32_t value) + inline ETL_CONSTEXPR14 uint_least8_t count_bits(uint32_t value) { - uint32_t count; + uint32_t count = 0U; count = value - ((value >> 1) & 0x55555555); count = ((count >> 2) & 0x33333333) + (count & 0x33333333); @@ -821,18 +742,19 @@ namespace etl return uint_least8_t(count); } - inline uint_least8_t count_bits(int32_t value) + inline ETL_CONSTEXPR14 uint_least8_t count_bits(int32_t value) { return count_bits(uint32_t(value)); } +#if !defined(ETL_NO_64BIT_TYPES) //*************************************************************************** /// Count set bits. 64 bits. ///\ingroup binary //*************************************************************************** - inline uint_least8_t count_bits(uint64_t value) + inline ETL_CONSTEXPR14 uint_least8_t count_bits(uint64_t value) { - uint64_t count; + uint64_t count = 0U; count = value - ((value >> 1) & 0x5555555555555555); count = ((count >> 2) & 0x3333333333333333) + (count & 0x3333333333333333); @@ -844,24 +766,25 @@ namespace etl return uint_least8_t(count); } - inline uint_least8_t count_bits(int64_t value) + inline ETL_CONSTEXPR14 uint_least8_t count_bits(int64_t value) { return count_bits(uint64_t(value)); } +#endif #if ETL_8BIT_SUPPORT //*************************************************************************** /// Parity. 8bits. 0 = even, 1 = odd ///\ingroup binary //*************************************************************************** - inline uint_least8_t parity(uint8_t value) + inline ETL_CONSTEXPR14 uint_least8_t parity(uint8_t value) { value ^= value >> 4; value &= 0x0F; return (0x6996 >> value) & 1; } - inline uint_least8_t parity(int8_t value) + inline ETL_CONSTEXPR14 uint_least8_t parity(int8_t value) { return parity(uint8_t(value)); } @@ -871,7 +794,7 @@ namespace etl /// Parity. 16bits. 0 = even, 1 = odd ///\ingroup binary //*************************************************************************** - inline uint_least8_t parity(uint16_t value) + inline ETL_CONSTEXPR14 uint_least8_t parity(uint16_t value) { value ^= value >> 8; value ^= value >> 4; @@ -879,7 +802,7 @@ namespace etl return (0x6996 >> value) & 1; } - inline uint_least8_t parity(int16_t value) + inline ETL_CONSTEXPR14 uint_least8_t parity(int16_t value) { return parity(uint16_t(value)); } @@ -888,7 +811,7 @@ namespace etl /// Parity. 32bits. 0 = even, 1 = odd ///\ingroup binary //*************************************************************************** - inline uint_least8_t parity(uint32_t value) + inline ETL_CONSTEXPR14 uint_least8_t parity(uint32_t value) { value ^= value >> 16; value ^= value >> 8; @@ -897,16 +820,17 @@ namespace etl return (0x6996 >> value) & 1; } - inline uint_least8_t parity(int32_t value) + inline ETL_CONSTEXPR14 uint_least8_t parity(int32_t value) { return parity(uint32_t(value)); } +#if !defined(ETL_NO_64BIT_TYPES) //*************************************************************************** /// Parity. 64bits. 0 = even, 1 = odd ///\ingroup binary //*************************************************************************** - inline uint_least8_t parity(uint64_t value) + inline ETL_CONSTEXPR14 uint_least8_t parity(uint64_t value) { value ^= value >> 32; value ^= value >> 16; @@ -916,10 +840,11 @@ namespace etl return (0x69966996 >> value) & 1; } - inline uint_least8_t parity(int64_t value) + inline ETL_CONSTEXPR14 uint_least8_t parity(int64_t value) { return parity(uint64_t(value)); } +#endif #if ETL_8BIT_SUPPORT //*************************************************************************** @@ -927,9 +852,9 @@ namespace etl /// Uses a binary search. ///\ingroup binary //*************************************************************************** - inline uint_least8_t count_trailing_zeros(uint8_t value) + inline ETL_CONSTEXPR14 uint_least8_t count_trailing_zeros(uint8_t value) { - uint_least8_t count; + uint_least8_t count = 0U; if (value & 0x1) { @@ -957,7 +882,7 @@ namespace etl return count; } - inline uint_least8_t count_trailing_zeros(int8_t value) + inline ETL_CONSTEXPR14 uint_least8_t count_trailing_zeros(int8_t value) { return count_trailing_zeros(uint8_t(value)); } @@ -968,9 +893,9 @@ namespace etl /// Uses a binary search. ///\ingroup binary //*************************************************************************** - inline uint_least8_t count_trailing_zeros(uint16_t value) + inline ETL_CONSTEXPR14 uint_least8_t count_trailing_zeros(uint16_t value) { - uint_least8_t count; + uint_least8_t count = 0U; if (value & 0x1) { @@ -1004,7 +929,7 @@ namespace etl return count; } - inline uint_least8_t count_trailing_zeros(int16_t value) + inline ETL_CONSTEXPR14 uint_least8_t count_trailing_zeros(int16_t value) { return count_trailing_zeros(uint16_t(value)); } @@ -1014,9 +939,9 @@ namespace etl /// Uses a binary search. ///\ingroup binary //*************************************************************************** - inline uint_least8_t count_trailing_zeros(uint32_t value) + inline ETL_CONSTEXPR14 uint_least8_t count_trailing_zeros(uint32_t value) { - uint_least8_t count; + uint_least8_t count = 0U; if (value & 0x1) { @@ -1056,19 +981,20 @@ namespace etl return count; } - inline uint_least8_t count_trailing_zeros(int32_t value) + inline ETL_CONSTEXPR14 uint_least8_t count_trailing_zeros(int32_t value) { return count_trailing_zeros(uint32_t(value)); } +#if !defined(ETL_NO_64BIT_TYPES) //*************************************************************************** /// Count trailing zeros. 64bit. /// Uses a binary search. ///\ingroup binary //*************************************************************************** - inline uint_least8_t count_trailing_zeros(uint64_t value) + ETL_CONSTEXPR14 inline uint_least8_t count_trailing_zeros(uint64_t value) { - uint_least8_t count; + uint_least8_t count = 0U; if (value & 0x1) { @@ -1114,17 +1040,18 @@ namespace etl return count; } - inline uint_least8_t count_trailing_zeros(int64_t value) + inline ETL_CONSTEXPR14 uint_least8_t count_trailing_zeros(int64_t value) { return count_trailing_zeros(uint64_t(value)); } +#endif #if ETL_8BIT_SUPPORT //***************************************************************************** /// Binary interleave ///\ingroup binary //***************************************************************************** - inline uint16_t binary_interleave(uint8_t first, uint8_t second) + inline ETL_CONSTEXPR14 uint16_t binary_interleave(uint8_t first, uint8_t second) { uint16_t f = first; uint16_t s = second; @@ -1140,7 +1067,7 @@ namespace etl return (f | (s << 1)); } - inline int16_t binary_interleave(int8_t first, int8_t second) + inline ETL_CONSTEXPR14 int16_t binary_interleave(int8_t first, int8_t second) { return int16_t(binary_interleave(uint8_t(first), uint8_t(second))); } @@ -1150,7 +1077,7 @@ namespace etl /// Binary interleave ///\ingroup binary //***************************************************************************** - inline uint32_t binary_interleave(uint16_t first, uint16_t second) + inline ETL_CONSTEXPR14 uint32_t binary_interleave(uint16_t first, uint16_t second) { uint32_t f = first; uint32_t s = second; @@ -1168,16 +1095,17 @@ namespace etl return (f | (s << 1)); } - inline int32_t binary_interleave(int16_t first, int16_t second) + inline ETL_CONSTEXPR14 int32_t binary_interleave(int16_t first, int16_t second) { return int32_t(binary_interleave(uint16_t(first), uint16_t(second))); } +#if !defined(ETL_NO_64BIT_TYPES) //***************************************************************************** /// Binary interleave ///\ingroup binary //***************************************************************************** - inline uint64_t binary_interleave(uint32_t first, uint32_t second) + inline ETL_CONSTEXPR14 uint64_t binary_interleave(uint32_t first, uint32_t second) { uint64_t f = first; uint64_t s = second; @@ -1197,17 +1125,18 @@ namespace etl return (f | (s << 1)); } - inline int64_t binary_interleave(int32_t first, int32_t second) + inline ETL_CONSTEXPR14 int64_t binary_interleave(int32_t first, int32_t second) { return int64_t(binary_interleave(uint16_t(first), uint16_t(second))); } +#endif //*************************************************************************** /// Checks if odd. ///\ingroup binary //*************************************************************************** template - typename etl::enable_if::value, bool>::type + ETL_CONSTEXPR typename etl::enable_if::value, bool>::type is_odd(const T value) { return ((static_cast::type>(value) & 1U) != 0U); @@ -1218,7 +1147,7 @@ namespace etl ///\ingroup binary //*************************************************************************** template - typename etl::enable_if::value, bool>::type + ETL_CONSTEXPR typename etl::enable_if::value, bool>::type is_even(const T value) { return ((static_cast::type>(value) & 1U) == 0U); diff --git a/include/etl/bit_stream.h b/include/etl/bit_stream.h index c662edd0..88cffc54 100644 --- a/include/etl/bit_stream.h +++ b/include/etl/bit_stream.h @@ -186,6 +186,7 @@ namespace etl return put_integral(static_cast(value), width); } +#if !defined(ETL_NO_64BIT_TYPES) //*************************************************************************** /// For 64bit integral types //*************************************************************************** @@ -201,6 +202,7 @@ namespace etl { return put_integral(value, width); } +#endif //*************************************************************************** /// For floating point types @@ -396,6 +398,7 @@ namespace etl return success; } +#if !defined(ETL_NO_64BIT_TYPES) //*************************************************************************** /// For unsigned integral types. 64bit //*************************************************************************** @@ -428,6 +431,7 @@ namespace etl return success; } +#endif //*************************************************************************** /// Put a data chunk to the stream diff --git a/include/etl/deque.h b/include/etl/deque.h index 9f35008f..0cdf4bfd 100644 --- a/include/etl/deque.h +++ b/include/etl/deque.h @@ -262,9 +262,9 @@ namespace etl //*************************************************** iterator() - : index(0), - p_deque(0), - p_buffer(0) + : index(0) + , p_deque(0) + , p_buffer(0) { } @@ -276,6 +276,16 @@ namespace etl { } + //*************************************************** + iterator& operator =(const iterator& other) + { + index = other.index; + p_deque = other.p_deque; + p_buffer = other.p_buffer; + + return *this; + } + //*************************************************** iterator& operator ++() { @@ -430,9 +440,9 @@ namespace etl //*************************************************** iterator(difference_type index_, ideque& the_deque, pointer p_buffer_) - : index(index_), - p_deque(&the_deque), - p_buffer(p_buffer_) + : index(index_) + , p_deque(&the_deque) + , p_buffer(p_buffer_) { } @@ -450,28 +460,47 @@ namespace etl //*************************************************** const_iterator() - : index(0), - p_deque(0), - p_buffer(0) + : index(0) + , p_deque(0) + , p_buffer(0) { } //*************************************************** const_iterator(const const_iterator& other) - : index(other.index), - p_deque(other.p_deque), - p_buffer(other.p_buffer) + : index(other.index) + , p_deque(other.p_deque) + , p_buffer(other.p_buffer) { } //*************************************************** const_iterator(const typename ideque::iterator& other) - : index(other.index), - p_deque(other.p_deque), - p_buffer(other.p_buffer) + : index(other.index) + , p_deque(other.p_deque) + , p_buffer(other.p_buffer) { } + //*************************************************** + const_iterator& operator =(const const_iterator& other) + { + index = other.index; + p_deque = other.p_deque; + p_buffer = other.p_buffer; + + return *this; + } + + const_iterator& operator =(const typename ideque::iterator& other) + { + index = other.index; + p_deque = other.p_deque; + p_buffer = other.p_buffer; + + return *this; + } + //*************************************************** const_iterator& operator ++() { @@ -625,9 +654,9 @@ namespace etl //*************************************************** const_iterator(difference_type index_, ideque& the_deque, pointer p_buffer_) - : index(index_), - p_deque(&the_deque), - p_buffer(p_buffer_) + : index(index_) + , p_deque(&the_deque) + , p_buffer(p_buffer_) { } diff --git a/include/etl/endianness.h b/include/etl/endianness.h index d4bbb1a7..276985aa 100644 --- a/include/etl/endianness.h +++ b/include/etl/endianness.h @@ -135,6 +135,7 @@ namespace etl } } +#if !defined(ETL_NO_64BIT_TYPES) //*************************************************************************** inline uint64_t ntoh(const uint64_t network) { @@ -147,6 +148,7 @@ namespace etl return network; } } +#endif //*************************************************************************** inline uint8_t hton(const uint8_t host) @@ -180,6 +182,7 @@ namespace etl } } +#if !defined(ETL_NO_64BIT_TYPES) //*************************************************************************** inline uint64_t hton(const uint64_t host) { @@ -192,6 +195,7 @@ namespace etl return host; } } +#endif } #endif diff --git a/include/etl/fnv_1.h b/include/etl/fnv_1.h index fad564e6..93900d84 100644 --- a/include/etl/fnv_1.h +++ b/include/etl/fnv_1.h @@ -49,6 +49,7 @@ SOFTWARE. namespace etl { +#if !defined(ETL_NO_64BIT_TYPES) //*************************************************************************** /// fnv_1 policy. /// Calculates FNV1. @@ -164,6 +165,7 @@ namespace etl this->add(begin, end); } }; +#endif //*************************************************************************** /// fnv_1 policy. diff --git a/include/etl/hash.h b/include/etl/hash.h index a0458262..72d0d1b9 100644 --- a/include/etl/hash.h +++ b/include/etl/hash.h @@ -72,6 +72,7 @@ namespace etl return fnv_1a_32(begin, end); } +#if !defined(ETL_NO_64BIT_TYPES) //************************************************************************* /// Hash to use when size_t is 64 bits. /// T is always expected to be size_t. @@ -82,6 +83,7 @@ namespace etl { return fnv_1a_64(begin, end); } +#endif } //*************************************************************************** diff --git a/include/etl/limits.h b/include/etl/limits.h index cc9814b5..147f9eb7 100644 --- a/include/etl/limits.h +++ b/include/etl/limits.h @@ -36,6 +36,13 @@ SOFTWARE. #include "etl/char_traits.h" #include "etl/integral_limits.h" +#if defined(ETL_NO_STL) && defined(ETL_COMPILER_ARM5) + // Required for nan, nanf, nanl + #if !defined(__USE_C99_MATH) + #define __USE_C99_MATH + #endif +#endif + #include #include #include @@ -108,7 +115,7 @@ namespace etl static const float_denorm_style has_denorm = denorm_indeterminate; static const float_round_style round_style = round_indeterminate; - static const float round_error() { return float(0.5); } + static float round_error() { return float(0.5); } }; //*************************************************************************** @@ -137,15 +144,15 @@ namespace etl static const bool is_signed = false; static const bool is_modulo = false; - static const bool min() { return false; } - static const bool max() { return true; } - static const bool lowest() { return false; } - static const bool epsilon() { return false; } - static const bool round_error() { return false; } - static const bool denorm_min() { return false; } - static const bool infinity() { return false; } - static const bool quiet_NaN() { return false; } - static const bool signaling_NaN() { return false; } + static bool min() { return false; } + static bool max() { return true; } + static bool lowest() { return false; } + static bool epsilon() { return false; } + static bool round_error() { return false; } + static bool denorm_min() { return false; } + static bool infinity() { return false; } + static bool quiet_NaN() { return false; } + static bool signaling_NaN() { return false; } }; //*************************************************************************** @@ -160,15 +167,15 @@ namespace etl static const bool is_signed = etl::is_signed::value; static const bool is_modulo = false; - static const char min() { return char(CHAR_MIN); } - static const char max() { return char(CHAR_MAX); } - static const char lowest() { return char(CHAR_MIN); } - static const char epsilon() { return 0; } - static const char round_error() { return 0; } - static const char denorm_min() { return 0; } - static const char infinity() { return 0; } - static const char quiet_NaN() { return 0; } - static const char signaling_NaN() { return 0; } + static char min() { return char(CHAR_MIN); } + static char max() { return char(CHAR_MAX); } + static char lowest() { return char(CHAR_MIN); } + static char epsilon() { return 0; } + static char round_error() { return 0; } + static char denorm_min() { return 0; } + static char infinity() { return 0; } + static char quiet_NaN() { return 0; } + static char signaling_NaN() { return 0; } }; //*************************************************************************** @@ -183,15 +190,15 @@ namespace etl static const bool is_signed = false; static const bool is_modulo = true; - static const unsigned char min() { return 0U; } - static const unsigned char max() { return UCHAR_MAX; } - static const unsigned char lowest() { return 0U; } - static const unsigned char epsilon() { return 0U; } - static const unsigned char round_error() { return 0U; } - static const unsigned char denorm_min() { return 0U; } - static const unsigned char infinity() { return 0U; } - static const unsigned char quiet_NaN() { return 0U; } - static const unsigned char signaling_NaN() { return 0U; } + static unsigned char min() { return 0U; } + static unsigned char max() { return UCHAR_MAX; } + static unsigned char lowest() { return 0U; } + static unsigned char epsilon() { return 0U; } + static unsigned char round_error() { return 0U; } + static unsigned char denorm_min() { return 0U; } + static unsigned char infinity() { return 0U; } + static unsigned char quiet_NaN() { return 0U; } + static unsigned char signaling_NaN() { return 0U; } }; //*************************************************************************** @@ -206,15 +213,15 @@ namespace etl static const bool is_signed = true; static const bool is_modulo = false; - static const signed char min() { return SCHAR_MIN; } - static const signed char max() { return SCHAR_MAX; } - static const signed char lowest() { return SCHAR_MIN; } - static const signed char epsilon() { return 0; } - static const signed char round_error() { return 0; } - static const signed char denorm_min() { return 0; } - static const signed char infinity() { return 0; } - static const signed char quiet_NaN() { return 0; } - static const signed char signaling_NaN() { return 0; } + static signed char min() { return SCHAR_MIN; } + static signed char max() { return SCHAR_MAX; } + static signed char lowest() { return SCHAR_MIN; } + static signed char epsilon() { return 0; } + static signed char round_error() { return 0; } + static signed char denorm_min() { return 0; } + static signed char infinity() { return 0; } + static signed char quiet_NaN() { return 0; } + static signed char signaling_NaN() { return 0; } }; #if (ETL_NO_LARGE_CHAR_SUPPORT == false) @@ -230,15 +237,15 @@ namespace etl static const bool is_signed = false; static const bool is_modulo = true; - static const char16_t min() { return 0U; } - static const char16_t max() { return UINT_LEAST16_MAX; } - static const char16_t lowest() { return 0U; } - static const char16_t epsilon() { return 0U; } - static const char16_t round_error() { return 0U; } - static const char16_t denorm_min() { return 0U; } - static const char16_t infinity() { return 0U; } - static const char16_t quiet_NaN() { return 0U; } - static const char16_t signaling_NaN() { return 0U; } + static char16_t min() { return 0U; } + static char16_t max() { return UINT_LEAST16_MAX; } + static char16_t lowest() { return 0U; } + static char16_t epsilon() { return 0U; } + static char16_t round_error() { return 0U; } + static char16_t denorm_min() { return 0U; } + static char16_t infinity() { return 0U; } + static char16_t quiet_NaN() { return 0U; } + static char16_t signaling_NaN() { return 0U; } }; //*************************************************************************** @@ -253,15 +260,15 @@ namespace etl static const bool is_signed = false; static const bool is_modulo = true; - static const char32_t min() { return 0U; } - static const char32_t max() { return UINT_LEAST32_MAX; } - static const char32_t lowest() { return 0U; } - static const char32_t epsilon() { return 0U; } - static const char32_t round_error() { return 0U; } - static const char32_t denorm_min() { return 0U; } - static const char32_t infinity() { return 0U; } - static const char32_t quiet_NaN() { return 0U; } - static const char32_t signaling_NaN() { return 0U; } + static char32_t min() { return 0U; } + static char32_t max() { return UINT_LEAST32_MAX; } + static char32_t lowest() { return 0U; } + static char32_t epsilon() { return 0U; } + static char32_t round_error() { return 0U; } + static char32_t denorm_min() { return 0U; } + static char32_t infinity() { return 0U; } + static char32_t quiet_NaN() { return 0U; } + static char32_t signaling_NaN() { return 0U; } }; #endif @@ -278,15 +285,15 @@ namespace etl static const bool is_signed = etl::is_signed::value; static const bool is_modulo = etl::is_unsigned::value; - static const wchar_t min() { return WCHAR_MIN; } - static const wchar_t max() { return WCHAR_MAX; } - static const wchar_t lowest() { return WCHAR_MIN; } - static const wchar_t epsilon() { return wchar_t(0); } - static const wchar_t round_error() { return wchar_t(0); } - static const wchar_t denorm_min() { return wchar_t(0); } - static const wchar_t infinity() { return wchar_t(0); } - static const wchar_t quiet_NaN() { return wchar_t(0); } - static const wchar_t signaling_NaN() { return wchar_t(0); } + static wchar_t min() { return WCHAR_MIN; } + static wchar_t max() { return WCHAR_MAX; } + static wchar_t lowest() { return WCHAR_MIN; } + static wchar_t epsilon() { return wchar_t(0); } + static wchar_t round_error() { return wchar_t(0); } + static wchar_t denorm_min() { return wchar_t(0); } + static wchar_t infinity() { return wchar_t(0); } + static wchar_t quiet_NaN() { return wchar_t(0); } + static wchar_t signaling_NaN() { return wchar_t(0); } }; //*************************************************************************** @@ -301,15 +308,15 @@ namespace etl static const bool is_signed = true; static const bool is_modulo = false; - static const short min() { return SHRT_MIN; } - static const short max() { return SHRT_MAX; } - static const short lowest() { return SHRT_MIN; } - static const short epsilon() { return 0; } - static const short round_error() { return 0; } - static const short denorm_min() { return 0; } - static const short infinity() { return 0; } - static const short quiet_NaN() { return 0; } - static const short signaling_NaN() { return 0; } + static short min() { return SHRT_MIN; } + static short max() { return SHRT_MAX; } + static short lowest() { return SHRT_MIN; } + static short epsilon() { return 0; } + static short round_error() { return 0; } + static short denorm_min() { return 0; } + static short infinity() { return 0; } + static short quiet_NaN() { return 0; } + static short signaling_NaN() { return 0; } }; //*************************************************************************** @@ -324,15 +331,15 @@ namespace etl static const bool is_signed = false; static const bool is_modulo = true; - static const unsigned short min() { return 0U; } - static const unsigned short max() { return USHRT_MAX; } - static const unsigned short lowest() { return 0U; } - static const unsigned short epsilon() { return 0U; } - static const unsigned short round_error() { return 0U; } - static const unsigned short denorm_min() { return 0U; } - static const unsigned short infinity() { return 0U; } - static const unsigned short quiet_NaN() { return 0U; } - static const unsigned short signaling_NaN() { return 0U; } + static unsigned short min() { return 0U; } + static unsigned short max() { return USHRT_MAX; } + static unsigned short lowest() { return 0U; } + static unsigned short epsilon() { return 0U; } + static unsigned short round_error() { return 0U; } + static unsigned short denorm_min() { return 0U; } + static unsigned short infinity() { return 0U; } + static unsigned short quiet_NaN() { return 0U; } + static unsigned short signaling_NaN() { return 0U; } }; @@ -348,15 +355,15 @@ namespace etl static const bool is_signed = true; static const bool is_modulo = false; - static const int min() { return INT_MIN; } - static const int max() { return INT_MAX; } - static const int lowest() { return INT_MIN; } - static const int epsilon() { return 0; } - static const int round_error() { return 0; } - static const int denorm_min() { return 0; } - static const int infinity() { return 0; } - static const int quiet_NaN() { return 0; } - static const int signaling_NaN() { return 0; } + static int min() { return INT_MIN; } + static int max() { return INT_MAX; } + static int lowest() { return INT_MIN; } + static int epsilon() { return 0; } + static int round_error() { return 0; } + static int denorm_min() { return 0; } + static int infinity() { return 0; } + static int quiet_NaN() { return 0; } + static int signaling_NaN() { return 0; } }; //*************************************************************************** @@ -371,15 +378,15 @@ namespace etl static const bool is_signed = false; static const bool is_modulo = true; - static const unsigned int min() { return 0U; } - static const unsigned int max() { return UINT_MAX; } - static const unsigned int lowest() { return 0U; } - static const unsigned int epsilon() { return 0U; } - static const unsigned int round_error() { return 0U; } - static const unsigned int denorm_min() { return 0U; } - static const unsigned int infinity() { return 0U; } - static const unsigned int quiet_NaN() { return 0U; } - static const unsigned int signaling_NaN() { return 0U; } + static unsigned int min() { return 0U; } + static unsigned int max() { return UINT_MAX; } + static unsigned int lowest() { return 0U; } + static unsigned int epsilon() { return 0U; } + static unsigned int round_error() { return 0U; } + static unsigned int denorm_min() { return 0U; } + static unsigned int infinity() { return 0U; } + static unsigned int quiet_NaN() { return 0U; } + static unsigned int signaling_NaN() { return 0U; } }; //*************************************************************************** @@ -394,15 +401,15 @@ namespace etl static const bool is_signed = true; static const bool is_modulo = false; - static const long min() { return LONG_MIN; } - static const long max() { return LONG_MAX; } - static const long lowest() { return LONG_MIN; } - static const long epsilon() { return 0; } - static const long round_error() { return 0; } - static const long denorm_min() { return 0; } - static const long infinity() { return 0; } - static const long quiet_NaN() { return 0; } - static const long signaling_NaN() { return 0; } + static long min() { return LONG_MIN; } + static long max() { return LONG_MAX; } + static long lowest() { return LONG_MIN; } + static long epsilon() { return 0; } + static long round_error() { return 0; } + static long denorm_min() { return 0; } + static long infinity() { return 0; } + static long quiet_NaN() { return 0; } + static long signaling_NaN() { return 0; } }; //*************************************************************************** @@ -417,15 +424,15 @@ namespace etl static const bool is_signed = false; static const bool is_modulo = true; - static const unsigned long min() { return 0U; } - static const unsigned long max() { return ULONG_MAX; } - static const unsigned long lowest() { return 0U; } - static const unsigned long epsilon() { return 0U; } - static const unsigned long round_error() { return 0U; } - static const unsigned long denorm_min() { return 0U; } - static const unsigned long infinity() { return 0U; } - static const unsigned long quiet_NaN() { return 0U; } - static const unsigned long signaling_NaN() { return 0U; } + static unsigned long min() { return 0U; } + static unsigned long max() { return ULONG_MAX; } + static unsigned long lowest() { return 0U; } + static unsigned long epsilon() { return 0U; } + static unsigned long round_error() { return 0U; } + static unsigned long denorm_min() { return 0U; } + static unsigned long infinity() { return 0U; } + static unsigned long quiet_NaN() { return 0U; } + static unsigned long signaling_NaN() { return 0U; } }; //*************************************************************************** @@ -440,15 +447,15 @@ namespace etl static const bool is_signed = true; static const bool is_modulo = false; - static const long long min() { return LLONG_MIN; } - static const long long max() { return LLONG_MAX; } - static const long long lowest() { return LLONG_MIN; } - static const long long epsilon() { return 0; } - static const long long round_error() { return 0; } - static const long long denorm_min() { return 0; } - static const long long infinity() { return 0; } - static const long long quiet_NaN() { return 0; } - static const long long signaling_NaN() { return 0; } + static long long min() { return LLONG_MIN; } + static long long max() { return LLONG_MAX; } + static long long lowest() { return LLONG_MIN; } + static long long epsilon() { return 0; } + static long long round_error() { return 0; } + static long long denorm_min() { return 0; } + static long long infinity() { return 0; } + static long long quiet_NaN() { return 0; } + static long long signaling_NaN() { return 0; } }; //*************************************************************************** @@ -463,15 +470,15 @@ namespace etl static const bool is_signed = false; static const bool is_modulo = true; - static const unsigned long long min() { return 0U; } - static const unsigned long long max() { return ULLONG_MAX; } - static const unsigned long long lowest() { return 0U; } - static const unsigned long long epsilon() { return 0U; } - static const unsigned long long round_error() { return 0U; } - static const unsigned long long denorm_min() { return 0U; } - static const unsigned long long infinity() { return 0U; } - static const unsigned long long quiet_NaN() { return 0U; } - static const unsigned long long signaling_NaN() { return 0U; } + static unsigned long long min() { return 0U; } + static unsigned long long max() { return ULLONG_MAX; } + static unsigned long long lowest() { return 0U; } + static unsigned long long epsilon() { return 0U; } + static unsigned long long round_error() { return 0U; } + static unsigned long long denorm_min() { return 0U; } + static unsigned long long infinity() { return 0U; } + static unsigned long long quiet_NaN() { return 0U; } + static unsigned long long signaling_NaN() { return 0U; } }; //*************************************************************************** @@ -481,14 +488,14 @@ namespace etl { public: - static const float min() { return FLT_MIN; } - static const float max() { return FLT_MAX; } - static const float lowest() { return -FLT_MAX; } - static const float epsilon() { return FLT_EPSILON; } - static const float denorm_min() { return FLT_MIN; } - static const float infinity() { return HUGE_VALF; } - static const float quiet_NaN() { return nanf(""); } - static const float signaling_NaN() { return nanf(""); } + static float min() { return FLT_MIN; } + static float max() { return FLT_MAX; } + static float lowest() { return -FLT_MAX; } + static float epsilon() { return FLT_EPSILON; } + static float denorm_min() { return FLT_MIN; } + static float infinity() { return HUGE_VALF; } + static float quiet_NaN() { return nanf(""); } + static float signaling_NaN() { return nanf(""); } static const int digits = FLT_MANT_DIG; static const int digits10 = FLT_DIG; @@ -507,14 +514,14 @@ namespace etl { public: - static const double min() { return DBL_MIN; } - static const double max() { return DBL_MAX; } - static const double lowest() { return -DBL_MAX; } - static const double epsilon() { return DBL_EPSILON; } - static const double denorm_min() { return DBL_MIN; } - static const double infinity() { return HUGE_VAL; } - static const double quiet_NaN() { return nan(""); } - static const double signaling_NaN() { return nan(""); } + static double min() { return DBL_MIN; } + static double max() { return DBL_MAX; } + static double lowest() { return -DBL_MAX; } + static double epsilon() { return DBL_EPSILON; } + static double denorm_min() { return DBL_MIN; } + static double infinity() { return HUGE_VAL; } + static double quiet_NaN() { return nan(""); } + static double signaling_NaN() { return nan(""); } static const int digits = DBL_MANT_DIG; static const int digits10 = DBL_DIG; @@ -533,14 +540,14 @@ namespace etl { public: - static const long double min() { return LDBL_MIN; } - static const long double max() { return LDBL_MAX; } - static const long double lowest() { return -LDBL_MAX; } - static const long double epsilon() { return LDBL_EPSILON; } - static const long double denorm_min() { return LDBL_MIN; } - static const long double infinity() { return HUGE_VALL; } - static const long double quiet_NaN() { return nanl(""); } - static const long double signaling_NaN() { return nanl(""); } + static long double min() { return LDBL_MIN; } + static long double max() { return LDBL_MAX; } + static long double lowest() { return -LDBL_MAX; } + static long double epsilon() { return LDBL_EPSILON; } + static long double denorm_min() { return LDBL_MIN; } + static long double infinity() { return HUGE_VALL; } + static long double quiet_NaN() { return nanl(""); } + static long double signaling_NaN() { return nanl(""); } static const int digits = LDBL_MANT_DIG; diff --git a/include/etl/murmur3.h b/include/etl/murmur3.h index bb15c259..7490bbdb 100644 --- a/include/etl/murmur3.h +++ b/include/etl/murmur3.h @@ -57,7 +57,11 @@ namespace etl { public: +#if defined(ETL_NO_64BIT_TYPES) + ETL_STATIC_ASSERT((etl::is_same::value), "Only 32 bit types supported"); +#else ETL_STATIC_ASSERT((etl::is_same::value || etl::is_same::value), "Only 32 & 64 bit types supported"); +#endif typedef THash value_type; diff --git a/include/etl/nullptr.h b/include/etl/nullptr.h index 0b74f327..4668c803 100644 --- a/include/etl/nullptr.h +++ b/include/etl/nullptr.h @@ -73,7 +73,7 @@ namespace std /// A null pointer. ///\ingroup nullptr //***************************************************************************** -#if !defined(ETL_STLPORT) && (defined(ETL_COMPILER_ARM5) && (__cplusplus < 201103L)) +#if !defined(ETL_STLPORT) const std::nullptr_t nullptr = {}; #endif diff --git a/include/etl/power.h b/include/etl/power.h index 34577748..2ac977ca 100644 --- a/include/etl/power.h +++ b/include/etl/power.h @@ -43,6 +43,15 @@ SOFTWARE. namespace etl { + namespace private_power + { +#if defined(ETL_NO_64BIT_TYPES) + typedef uint32_t type; +#else + typedef uint64_t type; +#endif + } + //*************************************************************************** ///\ingroup power /// Calculates powers. @@ -51,7 +60,7 @@ namespace etl template struct power { - static const uint64_t value = NV * power::value; + static const private_power::type value = NV * power::value; }; //*************************************************************************** @@ -62,7 +71,7 @@ namespace etl template struct power { - static const uint64_t value = 1; + static const private_power::type value = 1; }; //*************************************************************************** diff --git a/include/etl/private/to_string_helper.h b/include/etl/private/to_string_helper.h index 42514d68..1f544bf4 100644 --- a/include/etl/private/to_string_helper.h +++ b/include/etl/private/to_string_helper.h @@ -50,6 +50,12 @@ namespace etl { namespace private_to_string { +#if defined(ETL_NO_64BIT_TYPES) + typedef int32_t workspace_t; +#else + typedef int64_t workspace_t; +#endif + //*************************************************************************** /// Helper function for left/right alignment. //*************************************************************************** @@ -198,8 +204,8 @@ namespace etl /// Helper function for floating point integral and fractional. //*************************************************************************** template - void add_integral_fractional(const int64_t integral, - const int64_t fractional, + void add_integral_fractional(const workspace_t integral, + const workspace_t fractional, TIString& str, const etl::basic_format_spec& integral_format, const etl::basic_format_spec& fractional_format) @@ -249,7 +255,7 @@ namespace etl etl::basic_format_spec fractional_format = integral_format; fractional_format.width(integral_format.get_precision()).fill(type('0')).right(); - int64_t multiplier = 1; + workspace_t multiplier = 1; for (uint32_t i = 0; i < fractional_format.get_precision(); ++i) { @@ -258,10 +264,10 @@ namespace etl // Find the integral part of the floating point T f_integral = (value < T(0.0) ? ceil(value) : floor(value)); - int64_t integral = static_cast(f_integral); + workspace_t integral = static_cast(f_integral); // Find the fractional part of the floating point. - int64_t fractional = etl::absolute(static_cast(round((value - f_integral) * multiplier))); + workspace_t fractional = etl::absolute(static_cast(round((value - f_integral) * multiplier))); // Check for a rounding carry to the integral. if (fractional == multiplier) @@ -350,6 +356,67 @@ namespace etl return str; } +#if defined(ETL_NO_64BIT_TYPES) + //*************************************************************************** + /// For signed integrals less than 64 bits. Default format spec. + //*************************************************************************** + template + typename etl::enable_if::value && + etl::is_signed::value && + !etl::is_same::value>::value, const TIString& > ::type + to_string(const T value, TIString& str, const bool append = false) + { + etl::basic_format_spec format; + + etl::private_to_string::add_integral(int32_t(value), str, format, append); + + return str; + } + + //*************************************************************************** + /// For signed integrals less than 64 bits. Supplied format spec. + //*************************************************************************** + template + typename etl::enable_if::value && + etl::is_signed::value && + !etl::is_same::value>::value, const TIString& > ::type + to_string(const T value, TIString& str, const etl::basic_format_spec& format, const bool append = false) + { + etl::private_to_string::add_integral(int32_t(value), str, format, append); + + return str; + } + + //*************************************************************************** + /// For unsigned integrals less than 64 bits. Default format spec. + //*************************************************************************** + template + typename etl::enable_if::value && + etl::is_unsigned::value && + !etl::is_same::value>::value, const TIString& > ::type + to_string(const T value, TIString& str, const bool append = false) + { + etl::basic_format_spec format; + + etl::private_to_string::add_integral(uint32_t(value), str, format, append); + + return str; + } + + //*************************************************************************** + /// For unsigned integrals less than 64 bits. Supplied format spec. + //*************************************************************************** + template + typename etl::enable_if::value && + etl::is_unsigned::value && + !etl::is_same::value>::value, const TIString& > ::type + to_string(const T value, TIString& str, const etl::basic_format_spec& format, const bool append = false) + { + etl::private_to_string::add_integral(uint32_t(value), str, format, append); + + return str; + } +#else //*************************************************************************** /// For signed integrals less than 64 bits. Default format spec. //*************************************************************************** @@ -358,7 +425,7 @@ namespace etl etl::is_signed::value && !etl::is_same::value && !etl::is_same::value, const TIString&>::type - to_string(const T value, TIString& str, const bool append = false) + to_string(const T value, TIString& str, const bool append = false) { etl::basic_format_spec format; @@ -383,7 +450,7 @@ namespace etl } //*************************************************************************** - /// For unsigned integrals less then 64 bits. Default format spec. + /// For unsigned integrals less than 64 bits. Default format spec. //*************************************************************************** template typename etl::enable_if::value && @@ -477,6 +544,7 @@ namespace etl return str; } +#endif //*************************************************************************** /// For floating point. Default format spec. diff --git a/include/etl/random.h b/include/etl/random.h index fdbe535a..d2ecf043 100644 --- a/include/etl/random.h +++ b/include/etl/random.h @@ -450,6 +450,7 @@ namespace etl uint32_t value2; }; +#if !defined(ETL_NO_64BIT_TYPES) //*************************************************************************** /// A 32 bit random number generator. /// Uses a permuted congruential generator calculation. @@ -518,6 +519,7 @@ namespace etl uint64_t value; }; +#endif #if ETL_8BIT_SUPPORT //*************************************************************************** diff --git a/include/etl/string_view.h b/include/etl/string_view.h index 5a690632..bae52147 100644 --- a/include/etl/string_view.h +++ b/include/etl/string_view.h @@ -40,9 +40,10 @@ SOFTWARE. #include "integral_limits.h" #include "hash.h" #include "basic_string.h" - #include "algorithm.h" +#include "stdint.h" + ///\defgroup array array /// A wrapper for arrays ///\ingroup containers @@ -120,8 +121,8 @@ namespace etl /// Default constructor. //************************************************************************* ETL_CONSTEXPR17 basic_string_view() - : mbegin(nullptr), - mend(nullptr) + : mbegin(nullptr) + , mend(nullptr) { } @@ -129,8 +130,8 @@ namespace etl /// Construct from string. //************************************************************************* ETL_CONSTEXPR17 basic_string_view(const etl::ibasic_string& str) - : mbegin(str.begin()), - mend(str.end()) + : mbegin(str.begin()) + , mend(str.end()) { } @@ -138,8 +139,8 @@ namespace etl /// Construct from T*. //************************************************************************* ETL_EXPLICIT_STRING_FROM_CHAR ETL_CONSTEXPR17 basic_string_view(const T* begin_) - : mbegin(begin_), - mend(begin_ + TTraits::length(begin_)) + : mbegin(begin_) + , mend(begin_ + TTraits::length(begin_)) { } @@ -147,18 +148,17 @@ namespace etl /// Construct from pointer range. //************************************************************************* ETL_CONSTEXPR17 basic_string_view(const T* begin_, const T* end_) - : mbegin(begin_), - mend(end_) + : mbegin(begin_) + , mend(end_) { } //************************************************************************* /// Construct from iterator/size. //************************************************************************* - template ::value, void>::type> - ETL_CONSTEXPR17 basic_string_view(const T* begin_, TSize size_) - : mbegin(begin_), - mend(begin_ + size_) + ETL_CONSTEXPR17 basic_string_view(const T* begin_, size_t size_) + : mbegin(begin_) + , mend(begin_ + size_) { } @@ -166,8 +166,8 @@ namespace etl /// Copy constructor //************************************************************************* ETL_CONSTEXPR17 basic_string_view(const basic_string_view& other) - : mbegin(other.mbegin), - mend(other.mend) + : mbegin(other.mbegin) + , mend(other.mend) { } @@ -301,31 +301,28 @@ namespace etl etl::basic_string_view& operator=(const etl::basic_string_view& other) { mbegin = other.mbegin; - mend = other.mend; + mend = other.mend; return *this; } //************************************************************************* /// Assign from iterators //************************************************************************* - template ::value, void>::type> - void assign(TIterator begin_, TIterator end_) + template + void assign(TIterator begin_, TIterator end_) { mbegin = etl::addressof(*begin_); - mend = etl::addressof(*begin_) + etl::distance(begin_, end_); + mend = etl::addressof(*begin_) + etl::distance(begin_, end_); } //************************************************************************* /// Assign from iterator and size. //************************************************************************* - template ::value, void>::type> - void assign(TIterator begin_, TSize size_) + template + void assign(TIterator begin_, size_t size_) { mbegin = etl::addressof(*begin_); - mend = etl::addressof(*begin_) + size_; + mend = etl::addressof(*begin_) + size_; } //************************************************************************* diff --git a/include/etl/version.h b/include/etl/version.h index ae06c800..a22f20a1 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,8 +37,8 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION_MAJOR 16 -#define ETL_VERSION_MINOR 8 +#define ETL_VERSION_MAJOR 17 +#define ETL_VERSION_MINOR 0 #define ETL_VERSION_PATCH 0 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index 75b96331..3caec6ea 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library", - "version": "16.8.0", + "version": "17.0.0", "authors": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index b554dfd3..808d2c4a 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=16.8.0 +version=17.0.0 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index d971f82e..9988d6bb 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,6 +1,28 @@ +=============================================================================== +17.0.0 +Recoded binary_fill, has_zero_byte and has_byte_n as runtime functions to fix +compiler compatibilty issues. All functions may be constexpr if the compiler supports it. +Added tests for binary constextr functions. + +Added option to define ETL_NO_64BIT_TYPES macro if the compiler does not support 64bit types. +Conditional compilation macros added to affected files. + +Added iterator copy constructors to etl::deque. + +Added code for ARM5 compiler compatibility in limits.h + +Simplified conditional compilation for nullptr definition. + +Compiler compatibility changes to assign() in etl::string_view + +=============================================================================== +16.8.1 +Fixed C++03 compatibility issues nullptr.h, binary.h & string_view.h +Fixed warning + =============================================================================== 16.8.0 -Extracted message_packet from etl::message_router for use as an independant class. +Extracted message_packet from etl::message_router for use as an independent class. =============================================================================== 16.7.1 diff --git a/test/murmurhash3.cpp b/test/murmurhash3.cpp index 31d812e1..09246244 100644 --- a/test/murmurhash3.cpp +++ b/test/murmurhash3.cpp @@ -63,10 +63,12 @@ FORCE_INLINE uint32_t getblock32(const uint32_t * p, int i) return p[i]; } +#if !defined(ETL_NO_64BIT_TYPES) FORCE_INLINE uint64_t getblock64(const uint64_t * p, int i) { return p[i]; } +#endif //----------------------------------------------------------------------------- // Finalization mix - force all bits of a hash block to avalanche @@ -84,6 +86,7 @@ FORCE_INLINE uint32_t fmix32(uint32_t h) //---------- +#if !defined(ETL_NO_64BIT_TYPES) FORCE_INLINE uint64_t fmix64(uint64_t k) { k ^= k >> 33; @@ -94,6 +97,7 @@ FORCE_INLINE uint64_t fmix64(uint64_t k) return k; } +#endif //----------------------------------------------------------------------------- @@ -257,6 +261,7 @@ void MurmurHash3_x86_128(const void * key, const int len, //----------------------------------------------------------------------------- +#if !defined(ETL_NO_64BIT_TYPES) void MurmurHash3_x64_128(const void * key, const int len, const uint32_t seed, void * out) { @@ -335,4 +340,4 @@ void MurmurHash3_x64_128(const void * key, const int len, ((uint64_t*)out)[0] = h1; ((uint64_t*)out)[1] = h2; } - +#endif diff --git a/test/murmurhash3.h b/test/murmurhash3.h index 46ac322a..8c7fb561 100644 --- a/test/murmurhash3.h +++ b/test/murmurhash3.h @@ -16,7 +16,9 @@ typedef unsigned char uint8_t; typedef unsigned int uint32_t; +#if !defined(ETL_NO_64BIT_TYPES) typedef unsigned __int64 uint64_t; +#endif // Other compilers diff --git a/test/test_binary.cpp b/test/test_binary.cpp index f3c0db0e..e1177707 100644 --- a/test/test_binary.cpp +++ b/test/test_binary.cpp @@ -172,6 +172,14 @@ namespace CHECK_EQUAL(0x6F, int(value)); } + //************************************************************************* + TEST(test_rotate_left8_constexpr) + { + char temp[etl::rotate_left(uint8_t(0xAA))]; + + CHECK_EQUAL(etl::rotate_left(uint8_t(0xAA)), sizeof(temp)); + } + //************************************************************************* TEST(test_rotate_left16) { @@ -262,6 +270,14 @@ namespace CHECK_EQUAL(0x6E79, int(value)); } + //************************************************************************* + TEST(test_rotate_left16_constexpr) + { + char temp[etl::rotate_left(uint16_t(0xAA))]; + + CHECK_EQUAL(etl::rotate_left(uint16_t(0xAA)), sizeof(temp)); + } + //************************************************************************* TEST(test_rotate_right8) { @@ -316,6 +332,14 @@ namespace CHECK_EQUAL(0xDB, int(value)); } + //************************************************************************* + TEST(test_rotate_right8_constexpr) + { + char temp[etl::rotate_right(uint8_t(0xAA))]; + + CHECK_EQUAL(etl::rotate_right(uint8_t(0xAA)), sizeof(temp)); + } + //************************************************************************* TEST(test_rotate_right16) { @@ -406,6 +430,14 @@ namespace CHECK_EQUAL(0x5B9E, int(value)); } + //************************************************************************* + TEST(test_rotate_right16_constexpr) + { + char temp[etl::rotate_right(uint16_t(0xAA))]; + + CHECK_EQUAL(etl::rotate_right(uint16_t(0xAA)), sizeof(temp)); + } + //************************************************************************* TEST(test_rotate16) { @@ -423,6 +455,14 @@ namespace CHECK_EQUAL(0xCB73, int(value)); } + //************************************************************************* + TEST(test_rotate16_constexpr) + { + char temp[etl::rotate(uint16_t(0xAA), 1)]; + + CHECK_EQUAL(etl::rotate(uint16_t(0xAA), 1), sizeof(temp)); + } + //************************************************************************* TEST(test_reverse_bits8) { @@ -453,6 +493,14 @@ namespace CHECK_EQUAL(0x35, int(value)); } + //************************************************************************* + TEST(test_reverse_bits8_constexpr) + { + char temp[etl::reverse_bits(uint8_t(0xA5))]; + + CHECK_EQUAL(etl::reverse_bits(uint8_t(0xA5)), sizeof(temp)); + } + //************************************************************************* TEST(test_reverse_bits16) { @@ -471,6 +519,14 @@ namespace CHECK_EQUAL(0xA5A5, value); } + //************************************************************************* + TEST(test_reverse_bits16_constexpr) + { + char temp[etl::reverse_bits(uint16_t(0xA500))]; + + CHECK_EQUAL(etl::reverse_bits(uint16_t(0xA500)), sizeof(temp)); + } + //************************************************************************* TEST(test_reverse_bits32) { @@ -489,6 +545,14 @@ namespace CHECK_EQUAL(uint32_t(0x5A5A5A5A), value); } + //************************************************************************* + TEST(test_reverse_bits32_constexpr) + { + char temp[etl::reverse_bits(uint32_t(0xA5000000))]; + + CHECK_EQUAL(etl::reverse_bits(uint32_t(0xA5000000)), sizeof(temp)); + } + //************************************************************************* TEST(test_reverse_bits64) { @@ -507,6 +571,14 @@ namespace CHECK_EQUAL(uint64_t(0x5A5A5A5A5A5A5A5A), value); } + //************************************************************************* + TEST(test_reverse_bits64_constexpr) + { + char temp[etl::reverse_bits(uint64_t(0xA500000000000000))]; + + CHECK_EQUAL(etl::reverse_bits(uint64_t(0xA500000000000000)), sizeof(temp)); + } + //************************************************************************* TEST(test_reverse_bytes16) { @@ -525,6 +597,14 @@ namespace CHECK_EQUAL(0x5AA5, value); } + //************************************************************************* + TEST(test_reverse_bytes16_constexpr) + { + char temp[etl::reverse_bytes(uint16_t(0xA500))]; + + CHECK_EQUAL(etl::reverse_bytes(uint16_t(0xA500)), sizeof(temp)); + } + //************************************************************************* TEST(test_reverse_bytes32) { @@ -543,6 +623,14 @@ namespace CHECK_EQUAL(0xA5A55A5AU, value); } + //************************************************************************* + TEST(test_reverse_bytes32_constexpr) + { + char temp[etl::reverse_bytes(uint32_t(0xA5000000))]; + + CHECK_EQUAL(etl::reverse_bytes(uint32_t(0xA5000000)), sizeof(temp)); + } + //************************************************************************* TEST(test_reverse_bytes64) { @@ -561,6 +649,14 @@ namespace CHECK_EQUAL(0xA5A55A5AA5A55A5AU, value); } + //************************************************************************* + TEST(test_reverse_bytes64_constexpr) + { + char temp[etl::reverse_bytes(uint64_t(0xA500000000000000))]; + + CHECK_EQUAL(etl::reverse_bytes(uint64_t(0xA500000000000000)), sizeof(temp)); + } + //************************************************************************* TEST(test_binary_to_gray8) { @@ -579,6 +675,14 @@ namespace } } + //************************************************************************* + TEST(test_binary_to_gray8_constexpr) + { + char temp[etl::binary_to_gray(uint8_t(0xFF))]; + + CHECK_EQUAL(etl::binary_to_gray(uint8_t(0xFF)), sizeof(temp)); + } + //************************************************************************* TEST(test_binary_to_gray16) { @@ -597,6 +701,14 @@ namespace } } + //************************************************************************* + TEST(test_binary_to_gray16_constexpr) + { + char temp[etl::binary_to_gray(uint16_t(0xFF))]; + + CHECK_EQUAL(etl::binary_to_gray(uint16_t(0xFF)), sizeof(temp)); + } + //************************************************************************* TEST(test_binary_to_gray32) { @@ -621,6 +733,14 @@ namespace } } + //************************************************************************* + TEST(test_binary_to_gray32_constexpr) + { + char temp[etl::binary_to_gray(uint32_t(0xFF))]; + + CHECK_EQUAL(etl::binary_to_gray(uint32_t(0xFF)), sizeof(temp)); + } + //************************************************************************* TEST(test_binary_to_gray64) { @@ -645,6 +765,19 @@ namespace } } + size_t xxx() + { + return 4; + } + + //************************************************************************* + TEST(test_binary_to_gray64_constexpr) + { + char temp[etl::binary_to_gray(uint64_t(0xFF))]; + + CHECK_EQUAL(etl::binary_to_gray(uint64_t(0xFF)), sizeof(temp)); + } + //************************************************************************* TEST(test_gray_to_binary8) { @@ -655,6 +788,14 @@ namespace } } + //************************************************************************* + TEST(test_gray_to_binary8_constexpr) + { + char temp[etl::gray_to_binary(uint8_t(0xFF))]; + + CHECK_EQUAL(etl::gray_to_binary(uint8_t(0xFF)), sizeof(temp)); + } + //************************************************************************* TEST(test_gray_to_binary16) { @@ -665,6 +806,14 @@ namespace } } + //************************************************************************* + TEST(test_gray_to_binary16_constexpr) + { + char temp[etl::gray_to_binary(uint16_t(0xFF))]; + + CHECK_EQUAL(etl::gray_to_binary(uint16_t(0xFF)), sizeof(temp)); + } + //************************************************************************* TEST(test_gray_to_binary32) { @@ -680,6 +829,14 @@ namespace } } + //************************************************************************* + TEST(test_gray_to_binary32_constexpr) + { + char temp[etl::gray_to_binary(uint32_t(0xFF))]; + + CHECK_EQUAL(etl::gray_to_binary(uint32_t(0xFF)), sizeof(temp)); + } + //************************************************************************* TEST(test_gray_to_binary64) { @@ -695,6 +852,14 @@ namespace } } + //************************************************************************* + TEST(test_gray_to_binary64_constexpr) + { + char temp[etl::gray_to_binary(uint64_t(0xFF))]; + + CHECK_EQUAL(etl::gray_to_binary(uint64_t(0xFF)), sizeof(temp)); + } + //************************************************************************* TEST(test_count_bits_8) { @@ -705,6 +870,14 @@ namespace } } + //************************************************************************* + TEST(test_count_bits_8_constexpr) + { + char temp[etl::count_bits(uint8_t(0xFF))]; + + CHECK_EQUAL(etl::count_bits(uint8_t(0xFF)), sizeof(temp)); + } + //************************************************************************* TEST(test_count_bits_16) { @@ -715,6 +888,14 @@ namespace } } + //************************************************************************* + TEST(test_count_bits_16_constexpr) + { + char temp[etl::count_bits(uint16_t(0xFF))]; + + CHECK_EQUAL(etl::count_bits(uint16_t(0xFF)), sizeof(temp)); + } + //************************************************************************* TEST(test_count_bits_32) { @@ -731,6 +912,14 @@ namespace } } + //************************************************************************* + TEST(test_count_bits_32_constexpr) + { + char temp[etl::count_bits(uint32_t(0xFF))]; + + CHECK_EQUAL(etl::count_bits(uint32_t(0xFF)), sizeof(temp)); + } + //************************************************************************* TEST(test_count_bits_64) { @@ -747,6 +936,14 @@ namespace } } + //************************************************************************* + TEST(test_count_bits_64_constexpr) + { + char temp[etl::count_bits(uint64_t(0xFF))]; + + CHECK_EQUAL(etl::count_bits(uint64_t(0xFF)), sizeof(temp)); + } + //************************************************************************* TEST(test_parity_8) { @@ -757,6 +954,14 @@ namespace } } + //************************************************************************* + TEST(test_parity_8_constexpr) + { + char temp[etl::parity(uint8_t(0xFE))]; + + CHECK_EQUAL(etl::parity(uint8_t(0xFE)), sizeof(temp)); + } + //************************************************************************* TEST(test_parity_16) { @@ -767,6 +972,14 @@ namespace } } + //************************************************************************* + TEST(test_parity_16_constexpr) + { + char temp[etl::parity(uint16_t(0xFE))]; + + CHECK_EQUAL(etl::parity(uint16_t(0xFE)), sizeof(temp)); + } + //************************************************************************* TEST(test_parity_32) { @@ -783,6 +996,14 @@ namespace } } + //************************************************************************* + TEST(test_parity_32_constexpr) + { + char temp[etl::parity(uint32_t(0xFE))]; + + CHECK_EQUAL(etl::parity(uint32_t(0xFE)), sizeof(temp)); + } + //************************************************************************* TEST(test_parity_64) { @@ -799,6 +1020,14 @@ namespace } } + //************************************************************************* + TEST(test_parity_64_constexpr) + { + char temp[etl::parity(uint64_t(0xFE))]; + + CHECK_EQUAL(etl::parity(uint64_t(0xFE)), sizeof(temp)); + } + //************************************************************************* TEST(test_fold_bits) { @@ -869,6 +1098,14 @@ namespace CHECK_EQUAL(test_fold_bits(data, 63), (etl::fold_bits(data))); } + //************************************************************************* + TEST(test_fold_bits_constexpr) + { + char temp[etl::fold_bits(0xE8C9AACCBC3D9A8F)]; + + CHECK_EQUAL((etl::fold_bits(0xE8C9AACCBC3D9A8F)), sizeof(temp)); + } + //************************************************************************* TEST(test_max_value_for_bits) { @@ -1053,6 +1290,14 @@ namespace CHECK_EQUAL(178956970, (etl::sign_extend(value32))); } + //************************************************************************* + TEST(test_sign_extend_template1_constexpr) + { + char temp[etl::sign_extend(0x1A)]; + + CHECK_EQUAL((etl::sign_extend(0x1A)), sizeof(temp)); + } + //************************************************************************* TEST(test_sign_extend_template1b) { @@ -1104,6 +1349,14 @@ namespace CHECK_EQUAL(-22, (etl::sign_extend(value))); } + //************************************************************************* + TEST(test_sign_extend_template1b_constexpr) + { + char temp[etl::sign_extend(0x1A)]; + + CHECK_EQUAL((etl::sign_extend(0x1A)), sizeof(temp)); + } + //************************************************************************* TEST(test_sign_extend_template2) { @@ -1150,6 +1403,14 @@ namespace CHECK_EQUAL(178956970, (etl::sign_extend(value32, 30))); } + //************************************************************************* + TEST(test_sign_extend_template2_constexpr) + { + char temp[etl::sign_extend(0x1A, 6)]; + + CHECK_EQUAL((etl::sign_extend(0x1A, 6)), sizeof(temp)); + } + //************************************************************************* TEST(test_sign_extend_template2b) { @@ -1201,6 +1462,14 @@ namespace CHECK_EQUAL(-22, (etl::sign_extend(value, 6, 26))); } + //************************************************************************* + TEST(test_sign_extend_template2b_constexpr) + { + char temp[etl::sign_extend(0x1A, 6, 0)]; + + CHECK_EQUAL((etl::sign_extend(0x1A, 6, 0)), sizeof(temp)); + } + //************************************************************************* TEST(test_bit) { @@ -1280,207 +1549,119 @@ namespace } //************************************************************************* - TEST(test_binary_fill_compile_time) + TEST(test_binary_fill) { - 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(0x12U, (etl::binary_fill(uint8_t(0x12)))); + CHECK_EQUAL(0x1212U, (etl::binary_fill(uint8_t(0x12)))); + CHECK_EQUAL(0x12121212U, (etl::binary_fill(uint8_t(0x12)))); + CHECK_EQUAL(0x1212121212121212U, (etl::binary_fill(uint8_t(0x12)))); - 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(0x12, (etl::binary_fill(int8_t(0x12)))); + CHECK_EQUAL(0x1212, (etl::binary_fill(int8_t(0x12)))); + CHECK_EQUAL(0x12121212, (etl::binary_fill(int8_t(0x12)))); + CHECK_EQUAL(0x1212121212121212, (etl::binary_fill(int8_t(0x12)))); - CHECK_EQUAL(0x1234U, (etl::binary_fill::value)); - CHECK_EQUAL(0x12341234U, (etl::binary_fill::value)); - CHECK_EQUAL(0x1234123412341234U, (etl::binary_fill::value)); + CHECK_EQUAL(0x1234U, (etl::binary_fill(uint16_t(0x1234)))); + CHECK_EQUAL(0x12341234U, (etl::binary_fill(uint16_t(0x1234)))); + CHECK_EQUAL(0x1234123412341234U, (etl::binary_fill(uint16_t(0x1234)))); - CHECK_EQUAL(0x1234, (etl::binary_fill::value)); - CHECK_EQUAL(0x12341234, (etl::binary_fill::value)); - CHECK_EQUAL(0x1234123412341234, (etl::binary_fill::value)); + CHECK_EQUAL(0x1234, (etl::binary_fill(int16_t(0x1234)))); + CHECK_EQUAL(0x12341234, (etl::binary_fill(int16_t(0x1234)))); + CHECK_EQUAL(0x1234123412341234, (etl::binary_fill(int16_t(0x1234)))); - CHECK_EQUAL(0x12345678U, (etl::binary_fill::value)); - CHECK_EQUAL(0x1234567812345678U, (etl::binary_fill::value)); + CHECK_EQUAL(0x12345678U, (etl::binary_fill(uint32_t(0x12345678)))); + CHECK_EQUAL(0x1234567812345678U, (etl::binary_fill(uint32_t(0x12345678)))); - CHECK_EQUAL(0x12345678, (etl::binary_fill::value)); - CHECK_EQUAL(0x1234567812345678, (etl::binary_fill::value)); + CHECK_EQUAL(int32_t(0x12345678), int32_t(etl::binary_fill(int32_t(0x12345678)))); + CHECK_EQUAL(int64_t(0x1234567812345678), int64_t(etl::binary_fill(uint32_t(0x12345678)))); - CHECK_EQUAL(0x123456789ABCDEF0U, (etl::binary_fill::value)); + CHECK_EQUAL(0x123456789ABCDEF0U, (etl::binary_fill(uint64_t(0x123456789ABCDEF0)))); - CHECK_EQUAL(0x123456789ABCDEF0, (etl::binary_fill::value)); + CHECK_EQUAL(int64_t(0x123456789ABCDEF0), int64_t(etl::binary_fill(int64_t(0x123456789ABCDEF0)))); } //************************************************************************* - TEST(test_binary_fill_run_time) + TEST(test_has_zero_byte) { - 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(!(etl::has_zero_byte(uint8_t(0x01)))); + CHECK((etl::has_zero_byte(uint8_t(0x00)))); - 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(!(etl::has_zero_byte(int8_t(0x01)))); + CHECK((etl::has_zero_byte(int8_t(0x00)))); - 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(!(etl::has_zero_byte(uint16_t(0x0123)))); + CHECK((etl::has_zero_byte(uint16_t(0x0100)))); - 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(!(etl::has_zero_byte(int16_t(0x0123)))); + CHECK((etl::has_zero_byte(int16_t(0x0100)))); - CHECK_EQUAL(0x12345678U, (etl::binary_fill::value(0x12345678))); - CHECK_EQUAL(0x1234567812345678U, (etl::binary_fill::value(0x12345678))); + CHECK(!(etl::has_zero_byte(uint32_t(0x01234567)))); + CHECK((etl::has_zero_byte(uint32_t(0x01230067)))); - 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(!(etl::has_zero_byte(int32_t(0x01234567)))); + CHECK((etl::has_zero_byte(int32_t(0x01230067)))); - CHECK_EQUAL(0x123456789ABCDEF0U, (etl::binary_fill::value(0x123456789ABCDEF0))); + CHECK(!(etl::has_zero_byte(uint64_t(0x0123456789ABCDEF)))); + CHECK((etl::has_zero_byte(uint64_t(0x012345678900CDEF)))); - CHECK_EQUAL(int64_t(0x123456789ABCDEF0), int64_t(etl::binary_fill::value(0x123456789ABCDEF0))); + CHECK(!(etl::has_zero_byte(int64_t(0x0123456789ABCDEF)))); + CHECK((etl::has_zero_byte(int64_t(0x012345678900CDEF)))); } //************************************************************************* - TEST(test_has_zero_compile_time) + TEST(test_has_byte_n_partial_run_time) { - CHECK(!(etl::has_zero_byte::test)); - CHECK((etl::has_zero_byte::test)); + CHECK(!(etl::has_byte_n(uint8_t(0x01)))); + CHECK((etl::has_byte_n(uint8_t(0x01)))); - CHECK(!(etl::has_zero_byte::test)); - CHECK((etl::has_zero_byte::test)); + CHECK(!(etl::has_byte_n(int8_t(0x01)))); + CHECK((etl::has_byte_n(int8_t(0x01)))); - CHECK(!(etl::has_zero_byte::test)); - CHECK((etl::has_zero_byte::test)); + CHECK(!(etl::has_byte_n(uint16_t(0x0123)))); + CHECK((etl::has_byte_n(uint16_t(0x0123)))); - CHECK(!(etl::has_zero_byte::test)); - CHECK((etl::has_zero_byte::test)); + CHECK(!(etl::has_byte_n(int16_t(0x0123)))); + CHECK((etl::has_byte_n(int16_t(0x0123)))); - CHECK(!(etl::has_zero_byte::test)); - CHECK((etl::has_zero_byte::test)); + CHECK(!(etl::has_byte_n(uint32_t(0x01234567)))); + CHECK((etl::has_byte_n(uint32_t(0x01234567)))); - CHECK(!(etl::has_zero_byte::test)); - CHECK((etl::has_zero_byte::test)); + CHECK(!(etl::has_byte_n(int32_t(0x01234567)))); + CHECK((etl::has_byte_n(int32_t(0x01234567)))); - CHECK(!(etl::has_zero_byte::test)); - CHECK((etl::has_zero_byte::test)); + CHECK(!(etl::has_byte_n(uint64_t(0x0123456789ABCDEF)))); + CHECK((etl::has_byte_n(uint64_t(0x0123456789ABCDEF)))); - CHECK(!(etl::has_zero_byte::test)); - CHECK((etl::has_zero_byte::test)); + CHECK(!(etl::has_byte_n(int64_t(0x0123456789ABCDEF)))); + CHECK((etl::has_byte_n(int64_t(0x0123456789ABCDEF)))); } //************************************************************************* - TEST(test_has_zero_run_time) + TEST(test_has_byte_n_run_time) { - CHECK(!(etl::has_zero_byte<>::test(uint8_t(0x01)))); - CHECK((etl::has_zero_byte<>::test(uint8_t(0x00)))); + CHECK(!(etl::has_byte_n(uint8_t(0x01), 0x12))); + CHECK((etl::has_byte_n(uint8_t(0x01), 0x01))); - CHECK(!(etl::has_zero_byte<>::test(int8_t(0x01)))); - CHECK((etl::has_zero_byte<>::test(int8_t(0x00)))); + CHECK(!(etl::has_byte_n(uint8_t(0x01), 0x12))); + CHECK((etl::has_byte_n(uint8_t(0x01), 0x01))); - CHECK(!(etl::has_zero_byte<>::test(uint16_t(0x0123)))); - CHECK((etl::has_zero_byte<>::test(uint16_t(0x0100)))); + CHECK(!(etl::has_byte_n(uint16_t(0x0123), 0x12))); + CHECK((etl::has_byte_n(uint16_t(0x0123), 0x23))); - CHECK(!(etl::has_zero_byte<>::test(int16_t(0x0123)))); - CHECK((etl::has_zero_byte<>::test(int16_t(0x0100)))); + CHECK(!(etl::has_byte_n(int16_t(0x0123), 0x12))); + CHECK((etl::has_byte_n(int16_t(0x0123), 0x23))); - CHECK(!(etl::has_zero_byte<>::test(uint32_t(0x01234567)))); - CHECK((etl::has_zero_byte<>::test(uint32_t(0x01230067)))); + CHECK(!(etl::has_byte_n(uint32_t(0x01234567), 0x12))); + CHECK((etl::has_byte_n(uint32_t(0x01234567), 0x45))); - CHECK(!(etl::has_zero_byte<>::test(int32_t(0x01234567)))); - CHECK((etl::has_zero_byte<>::test(int32_t(0x01230067)))); + CHECK(!(etl::has_byte_n(int32_t(0x01234567), 0x12))); + CHECK((etl::has_byte_n(int32_t(0x01234567), 0x45))); - CHECK(!(etl::has_zero_byte<>::test(uint64_t(0x0123456789ABCDEF)))); - CHECK((etl::has_zero_byte<>::test(uint64_t(0x012345678900CDEF)))); + CHECK(!(etl::has_byte_n(uint64_t(0x0123456789ABCDEF), 0x12))); + CHECK((etl::has_byte_n(uint64_t(0x0123456789ABCDEF), 0xAB))); - 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))); + CHECK(!(etl::has_byte_n(int64_t(0x0123456789ABCDEF), 0x12))); + CHECK((etl::has_byte_n(int64_t(0x0123456789ABCDEF), 0xAB))); } //************************************************************************* diff --git a/test/vs2017/etl.sln b/test/vs2017/etl.sln index c4438e18..688b0aba 100644 --- a/test/vs2017/etl.sln +++ b/test/vs2017/etl.sln @@ -21,6 +21,8 @@ Global Debug MSVC - String Truncation Is Error|x64 = Debug MSVC - String Truncation Is Error|x64 Debug MSVC 64|Win32 = Debug MSVC 64|Win32 Debug MSVC 64|x64 = Debug MSVC 64|x64 + Debug MSVC No Checks|Win32 = Debug MSVC No Checks|Win32 + Debug MSVC No Checks|x64 = Debug MSVC No Checks|x64 Debug MSVC|Win32 = Debug MSVC|Win32 Debug MSVC|x64 = Debug MSVC|x64 Release|Win32 = Release|Win32 @@ -55,6 +57,10 @@ Global {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC 64|Win32.Build.0 = Debug No Unit Tests|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC 64|x64.ActiveCfg = Debug64|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC 64|x64.Build.0 = Debug64|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC No Checks|Win32.ActiveCfg = Debug MSVC No Checks|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC No Checks|Win32.Build.0 = Debug MSVC No Checks|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC No Checks|x64.ActiveCfg = Debug MSVC No Checks|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC No Checks|x64.Build.0 = Debug MSVC No Checks|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC|Win32.ActiveCfg = Debug|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC|Win32.Build.0 = Debug|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC|x64.ActiveCfg = Debug|x64 diff --git a/test/vs2017/etl.vcxproj b/test/vs2017/etl.vcxproj index 6b0c44fa..3f7e9665 100644 --- a/test/vs2017/etl.vcxproj +++ b/test/vs2017/etl.vcxproj @@ -17,6 +17,14 @@ Debug LLVM x64 + + Debug MSVC No Checks + Win32 + + + Debug MSVC No Checks + x64 + Debug64 Win32 @@ -96,6 +104,12 @@ v141 Unicode + + Application + true + v141 + Unicode + Application true @@ -138,6 +152,12 @@ v141 Unicode + + Application + true + v141 + Unicode + Application true @@ -218,6 +238,9 @@ + + + @@ -239,6 +262,9 @@ + + + @@ -281,6 +307,11 @@ true \$(IntDir) + + true + false + \$(IntDir) + true true @@ -315,6 +346,10 @@ true true + + true + true + true true @@ -385,6 +420,27 @@ $(OutDir)\etl.exe + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_NO_CHECKS;%(PreprocessorDefinitions) + ../../../unittest-cpp/;../../include;../../test + + + false + stdcpp17 + + + Console + true + + + $(OutDir)\etl.exe + + @@ -565,6 +621,27 @@ $(OutDir)\etl.exe + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../unittest-cpp/UnitTest++/;../../include/etl;../../test + + + false + stdcpp14 + + + Console + true + + + $(OutDir)\etl.exe + + @@ -888,12 +965,12 @@ - + @@ -1136,6 +1213,7 @@ false false false + false false false false @@ -1144,6 +1222,7 @@ false false false + false false false false @@ -1171,6 +1250,7 @@ false + false false false false @@ -1179,6 +1259,7 @@ false false false + false false false false @@ -1201,6 +1282,7 @@ false + false false false false @@ -1209,6 +1291,7 @@ false false false + false false false false @@ -1221,6 +1304,7 @@ false + false false false false @@ -1229,6 +1313,7 @@ false false false + false false false false @@ -1241,6 +1326,7 @@ false + false false false false @@ -1249,6 +1335,7 @@ false false false + false false false false @@ -1261,6 +1348,7 @@ false + false false false false @@ -1269,6 +1357,7 @@ false false false + false false false false @@ -1281,6 +1370,7 @@ false + false false false false @@ -1289,6 +1379,7 @@ false false false + false false false false @@ -1306,6 +1397,7 @@ false + false false false false @@ -1314,6 +1406,7 @@ false false false + false false false false @@ -1330,6 +1423,7 @@ true true false + false false false false @@ -1338,6 +1432,7 @@ false false false + false false false false @@ -1359,6 +1454,7 @@ false + false false false false @@ -1367,6 +1463,7 @@ false false false + false false false false diff --git a/test/vs2017/etl.vcxproj.filters b/test/vs2017/etl.vcxproj.filters index bde4af08..a2920171 100644 --- a/test/vs2017/etl.vcxproj.filters +++ b/test/vs2017/etl.vcxproj.filters @@ -825,12 +825,12 @@ ETL\Frameworks\Generators - - ETL\Frameworks - ETL\Frameworks + + ETL\Utilities +