From 28ac7c12baf99be2acde291b097b77d5071c56ba Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 30 Mar 2018 12:46:16 +0100 Subject: [PATCH 1/2] Changes for increased 64bit compatibility. --- include/etl/algorithm.h | 16 +-- include/etl/debug_count.h | 12 ++ include/etl/memory.h | 18 +-- include/etl/platform.h | 14 +++ test/codeblocks/ETL.cbp | 21 ++++ test/test_array_wrapper.cpp | 6 +- test/test_hash.cpp | 45 +++++-- test/test_pool.cpp | 8 +- test/test_string_char.cpp | 2 +- test/test_string_u16.cpp | 2 +- test/test_string_u32.cpp | 2 +- test/test_string_wchar_t.cpp | 2 +- test/test_vector.cpp | 6 +- test/vs2017/etl.sln | 18 +++ test/vs2017/etl.vcxproj | 234 +++++++++++++++++++++++++++++++++++ 15 files changed, 369 insertions(+), 37 deletions(-) diff --git a/include/etl/algorithm.h b/include/etl/algorithm.h index ba94a610..463dfd32 100644 --- a/include/etl/algorithm.h +++ b/include/etl/algorithm.h @@ -552,9 +552,9 @@ namespace etl { if (i == std::find(begin1, i, *i)) { - int32_t n = std::count(begin2, end2, *i); + size_t n = std::count(begin2, end2, *i); - if (n == 0 || std::count(i, end1, *i) != n) + if (n == 0 || size_t(std::count(i, end1, *i)) != n) { return false; } @@ -583,9 +583,9 @@ namespace etl { if (i == std::find(begin1, i, *i)) { - int32_t n = std::count(begin2, end2, *i); + size_t n = std::count(begin2, end2, *i); - if (n == 0 || std::count(i, end1, *i) != n) + if (n == 0 || size_t(std::count(i, end1, *i)) != n) { return false; } @@ -619,9 +619,9 @@ namespace etl { if (i == std::find_if(begin1, i, std::bind1st(predicate, *i))) { - int32_t n = std::count(begin2, end2, *i); + size_t n = std::count(begin2, end2, *i); - if (n == 0 || std::count(i, end1, *i) != n) + if (n == 0 || size_t(std::count(i, end1, *i)) != n) { return false; } @@ -652,9 +652,9 @@ namespace etl { if (i == std::find_if(begin1, i, std::bind1st(predicate, *i))) { - int32_t n = std::count(begin2, end2, *i); + size_t n = std::count(begin2, end2, *i); - if (n == 0 || std::count(i, end1, *i) != n) + if (n == 0 || size_t(std::count(i, end1, *i)) != n) { return false; } diff --git a/include/etl/debug_count.h b/include/etl/debug_count.h index ab80a4c4..48ad3f97 100644 --- a/include/etl/debug_count.h +++ b/include/etl/debug_count.h @@ -88,6 +88,18 @@ namespace etl return *this; } + inline debug_count& operator +=(size_t n) + { + count += int32_t(n); + return *this; + } + + inline debug_count& operator -=(size_t n) + { + count -= int32_t(n); + return *this; + } + inline operator int32_t() { return count; diff --git a/include/etl/memory.h b/include/etl/memory.h index 2d440653..1f1e0ad5 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -92,7 +92,7 @@ namespace etl typename etl::enable_if::value_type>::value, TOutputIterator>::type uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T& value, TCounter& count) { - count += std::distance(o_begin, o_end); + count += int32_t(std::distance(o_begin, o_end)); std::fill(o_begin, o_end, value); @@ -108,7 +108,7 @@ namespace etl typename etl::enable_if::value_type>::value, TOutputIterator>::type uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T& value, TCounter& count) { - count += std::distance(o_begin, o_end); + count += int32_t(std::distance(o_begin, o_end)); etl::uninitialized_fill(o_begin, o_end, value); @@ -181,7 +181,7 @@ namespace etl uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count) { TOutputIterator o_end = std::copy(i_begin, i_end, o_begin); - count += std::distance(o_begin, o_end); + count += int32_t(std::distance(o_begin, o_end)); return o_end; } @@ -197,7 +197,7 @@ namespace etl { TOutputIterator o_end = etl::uninitialized_copy(i_begin, i_end, o_begin); - count += std::distance(o_begin, o_end); + count += int32_t(std::distance(o_begin, o_end)); return o_end; } @@ -305,7 +305,7 @@ namespace etl typename etl::enable_if::value_type>::value, void>::type uninitialized_default_construct(TOutputIterator o_begin, TOutputIterator o_end, TCounter& count) { - count = std::distance(o_begin, o_end); + count = int32_t(std::distance(o_begin, o_end)); } //***************************************************************************** @@ -317,7 +317,7 @@ namespace etl typename etl::enable_if::value_type>::value, void>::type uninitialized_default_construct(TOutputIterator o_begin, TOutputIterator o_end, TCounter& count) { - count += std::distance(o_begin, o_end); + count += int32_t(std::distance(o_begin, o_end)); etl::uninitialized_default_construct(o_begin, o_end); } @@ -533,7 +533,7 @@ namespace etl template void uninitialized_value_construct(TOutputIterator o_begin, TOutputIterator o_end, TCounter& count) { - count += std::distance(o_begin, o_end); + count += int32_t(std::distance(o_begin, o_end)); etl::uninitialized_value_construct(o_begin, o_end); } @@ -649,7 +649,7 @@ namespace etl typename etl::enable_if::value_type>::value, void>::type destroy(TIterator i_begin, TIterator i_end, TCounter& count) { - count -= std::distance(i_begin, i_end); + count -= int32_t(std::distance(i_begin, i_end)); } //***************************************************************************** @@ -661,7 +661,7 @@ namespace etl typename etl::enable_if::value_type>::value, void>::type destroy(TIterator i_begin, TIterator i_end, TCounter& count) { - count -= std::distance(i_begin, i_end); + count -= int32_t(std::distance(i_begin, i_end)); while (i_begin != i_end) { diff --git a/include/etl/platform.h b/include/etl/platform.h index f1a4c4de..8eaba63e 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -28,16 +28,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ +#include + #ifndef __ETL_PLATFORM__ #define __ETL_PLATFORM__ // Some targets do not support 8bit types. #define ETL_8BIT_SUPPORT (CHAR_BIT == 8) +// Define a debug macro #if defined(_DEBUG) || defined(DEBUG) #define ETL_DEBUG #endif +// Undefine all of the macros. +#undef ETL_PLATFORM_16BIT +#undef ETL_PLATFORM_32BIT +#undef ETL_PLATFORM_64BIT #undef ETL_CPP11_SUPPORTED #undef ETL_CPP14_SUPPORTED #undef ETL_CPP17_SUPPORTED @@ -46,8 +53,15 @@ SOFTWARE. #undef ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED #undef ETL_ATOMIC_SUPPORTED +// Determine the bit width of the platform. +#define ETL_PLATFORM_16BIT (UINT16_MAX == UINTPTR_MAX) +#define ETL_PLATFORM_32BIT (UINT32_MAX == UINTPTR_MAX) +#define ETL_PLATFORM_64BIT (UINT64_MAX == UINTPTR_MAX) + #include "etl_profile.h" +// The macros below are dependent on the profile. + #if defined(ETL_COMPILER_MICROSOFT) // Disable warning of deprecated std::iterator. #pragma warning(disable : 4996) diff --git a/test/codeblocks/ETL.cbp b/test/codeblocks/ETL.cbp index a399f5d1..994dbbe8 100644 --- a/test/codeblocks/ETL.cbp +++ b/test/codeblocks/ETL.cbp @@ -40,6 +40,25 @@ + + @@ -278,9 +297,11 @@ diff --git a/test/test_array_wrapper.cpp b/test/test_array_wrapper.cpp index b4eafaaf..c084f72c 100644 --- a/test/test_array_wrapper.cpp +++ b/test/test_array_wrapper.cpp @@ -557,7 +557,11 @@ namespace { Data5 aw5; size_t hash = etl::hash()(aw5); - size_t compare_hash = etl::fnv_1a_32(reinterpret_cast(&data5[0]), reinterpret_cast(&data5[5])); + + + size_t compare_hash = etl::__private_hash__::generic_hash(reinterpret_cast(&data5[0]), reinterpret_cast(&data5[5])); + + CHECK_EQUAL(compare_hash, hash); } }; diff --git a/test/test_hash.cpp b/test/test_hash.cpp index 3bac42dc..c9fbc425 100644 --- a/test/test_hash.cpp +++ b/test/test_hash.cpp @@ -126,10 +126,15 @@ namespace { size_t hash = etl::hash()((long long)(0x5AA555AA3CC333CC)); - if (sizeof(size_t) == sizeof(long long)) - CHECK_EQUAL(0x5AA555AA3CC333CCU, hash); - else + if (ETL_PLATFORM_32BIT) + { CHECK_EQUAL(0xEC6A8D69U, hash); + } + + if (ETL_PLATFORM_64BIT) + { + CHECK_EQUAL(0x5AA555AA3CC333CCU, hash); + } } //************************************************************************* @@ -137,10 +142,15 @@ namespace { size_t hash = etl::hash()((unsigned long long)(0x5AA555AA3CC333CC)); - if (sizeof(size_t) == sizeof(unsigned long long)) - CHECK_EQUAL(0x5AA555AA3CC333CCU, hash); - else + if (ETL_PLATFORM_32BIT) + { CHECK_EQUAL(0xEC6A8D69U, hash); + } + + if (ETL_PLATFORM_64BIT) + { + CHECK_EQUAL(0x5AA555AA3CC333CCU, hash); + } } //************************************************************************* @@ -148,18 +158,31 @@ namespace { size_t hash = etl::hash()((float)(1.2345)); - CHECK_EQUAL(0X3F9E0419U, hash); + if (ETL_PLATFORM_32BIT) + { + CHECK_EQUAL(0X3F9E0419U, hash); + } + + if (ETL_PLATFORM_64BIT) + { + CHECK_EQUAL(9821047038287739023U, hash); + } } //************************************************************************* TEST(test_hash_double) { size_t hash = etl::hash()((double)(1.2345)); - - if (sizeof(size_t) == sizeof(double)) - CHECK_EQUAL(0X3FF3C083126E978DU, hash); - else + + if (ETL_PLATFORM_32BIT) + { CHECK_EQUAL(0x86FBF224U, hash); + } + + if (ETL_PLATFORM_64BIT) + { + CHECK_EQUAL(0x3FF3C083126E978DU, hash); + } } //************************************************************************* diff --git a/test/test_pool.cpp b/test/test_pool.cpp index 57c5363c..8f14c5f2 100644 --- a/test/test_pool.cpp +++ b/test/test_pool.cpp @@ -383,11 +383,17 @@ namespace //************************************************************************* TEST(test_type_error) { + struct Test + { + uint64_t a; + uint64_t b; + }; + etl::pool pool; etl::ipool& ip = pool; - CHECK_THROW(ip.allocate(), etl::pool_element_size); + CHECK_THROW(ip.allocate(), etl::pool_element_size); } //************************************************************************* diff --git a/test/test_string_char.cpp b/test/test_string_char.cpp index 1e8968dd..ea4f8086 100644 --- a/test/test_string_char.cpp +++ b/test/test_string_char.cpp @@ -3022,7 +3022,7 @@ namespace // Test with actual string type. Text text(STR("ABCDEFHIJKL")); size_t hash = etl::hash()(text); - size_t compare_hash = etl::fnv_1a_32(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); + size_t compare_hash = etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); CHECK_EQUAL(compare_hash, hash); // Test with interface string type. diff --git a/test/test_string_u16.cpp b/test/test_string_u16.cpp index 09b93293..8b52b0d0 100644 --- a/test/test_string_u16.cpp +++ b/test/test_string_u16.cpp @@ -3021,7 +3021,7 @@ namespace // Test with actual string type. Text text(STR("ABCDEFHIJKL")); size_t hash = etl::hash()(text); - size_t compare_hash = etl::fnv_1a_32(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); + size_t compare_hash = etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); CHECK_EQUAL(compare_hash, hash); // Test with interface string type. diff --git a/test/test_string_u32.cpp b/test/test_string_u32.cpp index ce1579b0..382ef587 100644 --- a/test/test_string_u32.cpp +++ b/test/test_string_u32.cpp @@ -3021,7 +3021,7 @@ namespace // Test with actual string type. Text text(STR("ABCDEFHIJKL")); size_t hash = etl::hash()(text); - size_t compare_hash = etl::fnv_1a_32(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); + size_t compare_hash = etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); CHECK_EQUAL(compare_hash, hash); // Test with interface string type. diff --git a/test/test_string_wchar_t.cpp b/test/test_string_wchar_t.cpp index 191f53d3..7659fa3b 100644 --- a/test/test_string_wchar_t.cpp +++ b/test/test_string_wchar_t.cpp @@ -3021,7 +3021,7 @@ namespace // Test with actual string type. Text text(STR("ABCDEFHIJKL")); size_t hash = etl::hash()(text); - size_t compare_hash = etl::fnv_1a_32(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); + size_t compare_hash = etl::__private_hash__::generic_hash(reinterpret_cast(&text[0]), reinterpret_cast(&text[text.size()])); CHECK_EQUAL(compare_hash, hash); // Test with interface string type. diff --git a/test/test_vector.cpp b/test/test_vector.cpp index 23770eac..62466aa1 100644 --- a/test/test_vector.cpp +++ b/test/test_vector.cpp @@ -485,12 +485,12 @@ namespace Compare_Data compare_data; Data data; - for (size_t i = 0; i < SIZE; ++i) + for (int i = 0; i < int(SIZE); ++i) { compare_data.push_back(i); } - for (size_t i = 0; i < SIZE; ++i) + for (int i = 0; i < int(SIZE); ++i) { data.push_back(i); } @@ -529,7 +529,7 @@ namespace { Data data; - for (size_t i = 0; i < SIZE; ++i) + for (int i = 0; i < int(SIZE); ++i) { data.push_back(i); } diff --git a/test/vs2017/etl.sln b/test/vs2017/etl.sln index 7c839529..553eb8ef 100644 --- a/test/vs2017/etl.sln +++ b/test/vs2017/etl.sln @@ -7,19 +7,37 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "etl", "etl.vcxproj", "{C21D EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug 64|Win32 = Debug 64|Win32 + Debug 64|x64 = Debug 64|x64 Debug No Unit Tests|Win32 = Debug No Unit Tests|Win32 + Debug No Unit Tests|x64 = Debug No Unit Tests|x64 Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug 64|Win32.ActiveCfg = Debug No Unit Tests|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug 64|Win32.Build.0 = Debug No Unit Tests|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug 64|x64.ActiveCfg = Debug64|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug 64|x64.Build.0 = Debug64|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug No Unit Tests|Win32.ActiveCfg = Debug No Unit Tests|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug No Unit Tests|Win32.Build.0 = Debug No Unit Tests|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug No Unit Tests|x64.ActiveCfg = Debug No Unit Tests|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug No Unit Tests|x64.Build.0 = Debug No Unit Tests|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug|Win32.ActiveCfg = Debug|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug|Win32.Build.0 = Debug|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug|x64.ActiveCfg = Debug|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug|x64.Build.0 = Debug|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Release|Win32.ActiveCfg = Release|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Release|Win32.Build.0 = Release|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Release|x64.ActiveCfg = Release|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0E35F961-E9EF-40C4-8E3E-2EC79B1D44B8} + EndGlobalSection EndGlobal diff --git a/test/vs2017/etl.vcxproj b/test/vs2017/etl.vcxproj index efc88c3b..a7df379f 100644 --- a/test/vs2017/etl.vcxproj +++ b/test/vs2017/etl.vcxproj @@ -1,18 +1,38 @@  + + Debug64 + Win32 + + + Debug64 + x64 + Debug No Unit Tests Win32 + + Debug No Unit Tests + x64 + Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB} @@ -28,12 +48,36 @@ v141 Unicode + + Application + true + v141 + Unicode + + + Application + true + v141 + Unicode + + + Application + true + v141 + Unicode + Application true v141 Unicode + + Application + true + v141 + Unicode + Application false @@ -41,32 +85,75 @@ true Unicode + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + true true \$(IntDir) + + true + true + + + true + true + \$(IntDir) + + + true + true + true true + + true + true + false true + + false + true + @@ -88,7 +175,90 @@ $(OutDir)\etl.exe + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../unittest-cpp/UnitTest++/;../../include/etl;../../include/etl/c;../../test + + + false + stdcpp14 + + + Console + true + + + $(OutDir)\etl.exe + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../unittest-cpp/UnitTest++/;../../include/etl;../../include/etl/c;../../test + + + false + stdcpp14 + + + Console + true + + + $(OutDir)\etl.exe + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../unittest-cpp/UnitTest++/;../../include/etl;../../include/etl/c;../../test + + + false + stdcpp14 + + + Console + true + + + $(OutDir)\etl.exe + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../unittest-cpp/UnitTest++/;../../include/etl;../../include/etl/c;../../test + + + + + Console + true + + + + + + + @@ -130,6 +300,28 @@ $(OutDir)\etl.exe + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../unittest-cpp/UnitTest++/;../../src + false + + + Console + true + true + true + + + $(OutDir)\etl.exe + + @@ -341,7 +533,9 @@ ../../../unittest-cpp + ../../../unittest-cpp false + false @@ -360,8 +554,13 @@ false + false false + false + false + false false + false @@ -370,13 +569,19 @@ true + true true + true false + false + false + false false + false @@ -388,18 +593,33 @@ false + false + false + false false + false + false + false false + false + false + false false + false + false + false false + false + false + false @@ -408,11 +628,19 @@ false + false + false + false false + false true + true false + false + false + false @@ -425,7 +653,11 @@ false + false + false + false false + false @@ -436,6 +668,7 @@ true + true @@ -443,6 +676,7 @@ true + true From 6603ad963290f93be894e4f46f465a44b3e438c5 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 8 Apr 2018 19:50:41 +0100 Subject: [PATCH 2/2] Updated release notes and version numbers --- include/etl/version.h | 4 ++-- support/Release notes.txt | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/etl/version.h b/include/etl/version.h index 39688450..aa0009f1 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -37,9 +37,9 @@ SOFTWARE. /// Definitions of the ETL version ///\ingroup utilities -#define ETL_VERSION "11.3.0" +#define ETL_VERSION "11.4.0" #define ETL_VERSION_MAJOR 11 -#define ETL_VERSION_MINOR 3 +#define ETL_VERSION_MINOR 4 #define ETL_VERSION_PATCH 0 #endif diff --git a/support/Release notes.txt b/support/Release notes.txt index 5e074323..d418f610 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,9 @@ +=============================================================================== +11.4.0 +Added improved atomics. +Added mutex +Added SPSC & MPPC queues + =============================================================================== 11.3.0 Improved compatibility with 64 bit pltforms.