From 574da35b103d7cc33b30d586e9c657d1bd0d8fd8 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 3 Feb 2025 15:03:28 +0000 Subject: [PATCH] Attempt to fix Github CI errors --- .gitignore | 1 + include/etl/atomic/atomic_gcc_sync.h | 53 ++-- include/etl/memory.h | 22 ++ test/run-tests.sh | 371 --------------------------- test/test_atomic.cpp | 12 +- 5 files changed, 57 insertions(+), 402 deletions(-) diff --git a/.gitignore b/.gitignore index 3983d1c62..66fab5a7c 100644 --- a/.gitignore +++ b/.gitignore @@ -394,3 +394,4 @@ examples/QueuedMessageRouter/vs2022/.vs/QueuedMessageRouter/v17 test/etl_error_handler/assert_errors/build-make test/etl_error_handler/assert_function/build-make test/syntax_check/bgcc +test/syntax_check/bclang diff --git a/include/etl/atomic/atomic_gcc_sync.h b/include/etl/atomic/atomic_gcc_sync.h index 5b653925d..67c7c8bfe 100644 --- a/include/etl/atomic/atomic_gcc_sync.h +++ b/include/etl/atomic/atomic_gcc_sync.h @@ -83,7 +83,7 @@ namespace etl // Only integral and pointer types are supported. //*************************************************************************** - enum memory_order + typedef enum memory_order { memory_order_relaxed = __ATOMIC_RELAXED, memory_order_consume = __ATOMIC_CONSUME, @@ -91,13 +91,22 @@ namespace etl memory_order_release = __ATOMIC_RELEASE, memory_order_acq_rel = __ATOMIC_ACQ_REL, memory_order_seq_cst = __ATOMIC_SEQ_CST + } memory_order; + + template + struct atomic_traits + { + static ETL_CONSTANT bool is_always_lock_free = Is_Always_Lock_Free; }; + template + ETL_CONSTANT bool atomic_traits::is_always_lock_free; + //*************************************************************************** /// For all types except bool, pointers and types that are always lock free. //*************************************************************************** template ::value> - class atomic + class atomic : public atomic_traits { public: @@ -377,8 +386,6 @@ namespace etl return __atomic_compare_exchange_n(&value, &expected, desired, false, success, failure); } - static ETL_CONSTANT bool is_always_lock_free = true; - private: atomic& operator =(const atomic&) ETL_DELETE; @@ -391,7 +398,7 @@ namespace etl /// Specialisation for pointers //*************************************************************************** template - class atomic + class atomic : public atomic_traits { public: @@ -621,8 +628,6 @@ namespace etl return __atomic_compare_exchange_n(&value, &expected_v, uintptr_t(desired), false, success, failure); } - static ETL_CONSTANT bool is_always_lock_free = true; - private: atomic& operator =(const atomic&) ETL_DELETE; @@ -635,7 +640,7 @@ namespace etl /// Specialisation for bool //*************************************************************************** template <> - class atomic + class atomic : public atomic_traits { public: @@ -785,8 +790,6 @@ namespace etl return __atomic_compare_exchange_n(&value, &expected_v, desired_v, false, success, failure); } - static ETL_CONSTANT bool is_always_lock_free = true; - private: atomic& operator =(const atomic&) ETL_DELETE; @@ -800,7 +803,7 @@ namespace etl /// Uses a mutex to control access. //*************************************************************************** template - class atomic + class atomic : public atomic_traits { public: @@ -1005,8 +1008,6 @@ namespace etl return compare_exchange_weak(expected, desired); } - static ETL_CONSTANT bool is_always_lock_free = false; - private: mutable char flag; @@ -1038,11 +1039,20 @@ namespace etl memory_order_seq_cst } memory_order; + template + struct atomic_traits + { + static ETL_CONSTANT bool is_always_lock_free = Is_Always_Lock_Free; + }; + + template + ETL_CONSTANT bool atomic_traits::is_always_lock_free; + //*************************************************************************** /// For all types except bool and pointers //*************************************************************************** template ::value> - class atomic + class atomic : public atomic_traits { public: @@ -1436,8 +1446,6 @@ namespace etl return true; } - static ETL_CONSTANT bool is_always_lock_free = true; - private: atomic& operator =(const atomic&) ETL_DELETE; @@ -1450,7 +1458,7 @@ namespace etl /// Specialisation for pointers //*************************************************************************** template - class atomic + class atomic : public atomic_traits { public: @@ -1748,8 +1756,6 @@ namespace etl return true; } - static ETL_CONSTANT bool is_always_lock_free = true; - private: atomic& operator =(const atomic&) ETL_DELETE; @@ -1762,7 +1768,7 @@ namespace etl /// Specialisation for bool //*************************************************************************** template <> - class atomic + class atomic : public atomic_traits { public: @@ -1972,8 +1978,6 @@ namespace etl return true; } - static ETL_CONSTANT bool is_always_lock_free = true; - private: atomic& operator =(const atomic&) ETL_DELETE; @@ -1987,7 +1991,7 @@ namespace etl /// Uses a mutex to control access. //*************************************************************************** template - class atomic + class atomic : public atomic_traits { public: @@ -2174,8 +2178,6 @@ namespace etl return compare_exchange_weak(expected, desired); } - static ETL_CONSTANT bool is_always_lock_free = false; - private: mutable char flag; @@ -2250,3 +2252,4 @@ namespace etl } #endif + diff --git a/include/etl/memory.h b/include/etl/memory.h index f70d93e3a..ca72656b9 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -54,6 +54,27 @@ SOFTWARE. namespace etl { +#if ETL_USING_STL && ETL_USING_CPP20 + //***************************************************************************** + /// Obtain the address represented by p without forming a reference to the object pointed to by p. + /// Defined when using the STL and C++20 + //***************************************************************************** + template + constexpr auto to_address(const TPtr& p) noexcept + { + return std::to_address(p); + } + + //***************************************************************************** + /// Obtain the address represented by p without forming a reference to the object pointed to by p. + /// Defined when using the STL and C++20 + //***************************************************************************** + template + constexpr T* to_address(T* p) noexcept + { + return std::to_address(p); + } +#else //***************************************************************************** /// Obtain the address represented by p without forming a reference to the object pointed to by p. /// Defined when not using the STL or C++20 @@ -74,6 +95,7 @@ namespace etl { return itr.operator->(); } +#endif #if ETL_USING_STL //***************************************************************************** diff --git a/test/run-tests.sh b/test/run-tests.sh index 34af8d07f..a8f301b50 100644 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -186,77 +186,6 @@ etl_version=$(echo $etl_version_raw | sed -e 's/\r//g') # Remove trailing \r gcc_compiler=$(g++ --version | grep g++) clang_compiler=$(clang++ --version | grep clang) -#****************************************************************************** -# GCC -#****************************************************************************** -if [ "$compiler_enabled" = "gcc" ] || [ "$compiler_enabled" = "All compilers" ]; then -compiler=$gcc_compiler -SetConfigurationName "STL" -PrintHeader -rm * -rf -cmake -DCMAKE_C_COMPILER="gcc" -DCMAKE_CXX_COMPILER="g++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize -DETL_MESSAGES_ARE_NOT_VIRTUAL=OFF .. -cmake --build . -if [ $? -eq 0 ]; then - PassedCompilation -else - FailedCompilation - exit $? -fi -./etl_tests -if [ $? -eq 0 ]; then - PassedTests -else - FailedTests - exit $? -fi -fi - -#****************************************************************************** -if [ "$compiler_enabled" = "gcc" ] || [ "$compiler_enabled" = "All compilers" ]; then -compiler=$gcc_compiler -SetConfigurationName "STL - Non-virtual messages" -PrintHeader -rm * -rf -cmake -DCMAKE_C_COMPILER="gcc" -DCMAKE_CXX_COMPILER="g++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize -DETL_MESSAGES_ARE_NOT_VIRTUAL=ON .. -cmake --build . -if [ $? -eq 0 ]; then - PassedCompilation -else - FailedCompilation - exit $? -fi -./etl_tests -if [ $? -eq 0 ]; then - PassedTests -else - FailedTests - exit $? -fi -fi - -#****************************************************************************** -if [ "$compiler_enabled" = "gcc" ] || [ "$compiler_enabled" = "All compilers" ]; then -compiler=$gcc_compiler -SetConfigurationName "STL - Force C++03" -PrintHeader -rm * -rf -cmake -DCMAKE_C_COMPILER="gcc" -DCMAKE_CXX_COMPILER="g++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize -DETL_MESSAGES_ARE_NOT_VIRTUAL=OFF .. -cmake --build . -if [ $? -eq 0 ]; then - PassedCompilation -else - FailedCompilation - exit $? -fi -./etl_tests -if [ $? -eq 0 ]; then - PassedTests -else - FailedTests - exit $? -fi -fi - #****************************************************************************** if [ "$compiler_enabled" = "gcc" ] || [ "$compiler_enabled" = "All compilers" ]; then compiler=$gcc_compiler @@ -306,50 +235,6 @@ fi #****************************************************************************** # CLANG #****************************************************************************** -if [ "$compiler_enabled" = "clang" ] || [ "$compiler_enabled" = "All compilers" ]; then -compiler=$clang_compiler -SetConfigurationName "STL" -PrintHeader -rm * -rf -cmake -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize -DETL_MESSAGES_ARE_NOT_VIRTUAL=OFF .. -cmake --build . -if [ $? -eq 0 ]; then - PassedCompilation -else - FailedCompilation - exit $? -fi -./etl_tests -if [ $? -eq 0 ]; then - PassedTests -else - FailedTests - exit $? -fi -fi - -#****************************************************************************** -if [ "$compiler_enabled" = "clang" ] || [ "$compiler_enabled" = "All compilers" ]; then -compiler=$clang_compiler -SetConfigurationName "STL - Force C++03" -PrintHeader -rm * -rf -cmake -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=ON -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize -DETL_MESSAGES_ARE_NOT_VIRTUAL=OFF .. -cmake --build . -if [ $? -eq 0 ]; then - PassedCompilation -else - FailedCompilation - exit $? -fi -./etl_tests -if [ $? -eq 0 ]; then - PassedTests -else - FailedTests - exit $? -fi -fi #****************************************************************************** if [ "$compiler_enabled" = "clang" ] || [ "$compiler_enabled" = "All compilers" ]; then @@ -397,262 +282,6 @@ else fi fi -#****************************************************************************** -if [ "$compiler_enabled" = "gcc" ] || [ "$compiler_enabled" = "All compilers" ]; then -compiler=$gcc_compiler -SetConfigurationName "Initializer list test" -PrintHeader -cd ../etl_initializer_list/ -mkdir -p build-make || exit 1 -cd build-make || exit 1 -rm * -rf -cmake -DCMAKE_C_COMPILER="gcc" -DCMAKE_C_COMPILER="gcc" -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize .. -cmake --build . -if [ $? -eq 0 ]; then - PassedCompilation -else - FailedCompilation - exit $? -fi -./etl_tests -if [ $? -eq 0 ]; then - PassedTests -else - FailedTests - exit $? -fi -fi - -#****************************************************************************** -if [ "$compiler_enabled" = "clang" ] || [ "$compiler_enabled" = "All compilers" ]; then -compiler=$clang_compiler -SetConfigurationName "Initializer list test" -PrintHeader -rm * -rf -cmake -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize .. -cmake --build . -if [ $? -eq 0 ]; then - PassedCompilation -else - FailedCompilation - exit $? -fi -./etl_tests -if [ $? -eq 0 ]; then - PassedTests -else - FailedTests - exit $? -fi -fi - -#****************************************************************************** -if [ "$compiler_enabled" = "gcc" ] || [ "$compiler_enabled" = "All compilers" ]; then -compiler=$gcc_compiler -SetConfigurationName "Error macros 'log_errors' test" -PrintHeader -cd ../../etl_error_handler/log_errors -mkdir -p build-make || exit 1 -cd build-make || exit 1 -rm * -rf -cmake -DCMAKE_C_COMPILER="gcc" -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize .. -cmake --build . -if [ $? -eq 0 ]; then - PassedCompilation -else - FailedCompilation - exit $? -fi -./etl_tests -if [ $? -eq 0 ]; then - PassedTests -else - FailedTests - exit $? -fi -fi - -#****************************************************************************** -if [ "$compiler_enabled" = "gcc" ] || [ "$compiler_enabled" = "All compilers" ]; then -compiler=$gcc_compiler -SetConfigurationName "Error macros 'exceptions' test" -PrintHeader -cd ../../../etl_error_handler/exceptions -mkdir -p build-make || exit 1 -cd build-make || exit 1 -rm * -rf -cmake -DCMAKE_C_COMPILER="gcc" -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize .. -cmake --build . -if [ $? -eq 0 ]; then - PassedCompilation -else - FailedCompilation - exit $? -fi -./etl_tests -if [ $? -eq 0 ]; then - PassedTests -else - FailedTests - exit $? -fi -fi - -#****************************************************************************** -if [ "$compiler_enabled" = "gcc" ] || [ "$compiler_enabled" = "All compilers" ]; then -compiler=$gcc_compiler -SetConfigurationName "Error macros 'log_errors and exceptions' test" -PrintHeader -cd ../../../etl_error_handler/log_errors_and_exceptions -mkdir -p build-make || exit 1 -cd build-make || exit 1 -rm * -rf -cmake -DCMAKE_C_COMPILER="gcc" -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize .. -cmake --build . -if [ $? -eq 0 ]; then - PassedCompilation -else - FailedCompilation - exit $? -fi -./etl_tests -if [ $? -eq 0 ]; then - PassedTests -else - FailedTests - exit $? -fi -fi - -#****************************************************************************** -if [ "$compiler_enabled" = "gcc" ] || [ "$compiler_enabled" = "All compilers" ]; then -compiler=$gcc_compiler -SetConfigurationName "Error macros 'assert function' test" -PrintHeader -cd ../../../etl_error_handler/assert_function -mkdir -p build-make || exit 1 -cd build-make || exit 1 -rm * -rf -cmake -DCMAKE_C_COMPILER="gcc" -DCMAKE_CXX_COMPILER="g++" -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize .. -cmake --build . -if [ $? -eq 0 ]; then - PassedCompilation -else - FailedCompilation - exit $? -fi -./etl_tests -if [ $? -eq 0 ]; then - PassedTests -else - FailedTests - exit $? -fi -fi - -#****************************************************************************** -if [ "$compiler_enabled" = "clang" ] || [ "$compiler_enabled" = "All compilers" ]; then -compiler=$clang_compiler -SetConfigurationName "Error macros 'log_errors' test" -PrintHeader -cd ../../../etl_error_handler/log_errors -mkdir -p build-make || exit 1 -cd build-make || exit 1 -rm * -rf -cmake -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize .. -cmake --build . -if [ $? -eq 0 ]; then - PassedCompilation -else - FailedCompilation - exit $? -fi -./etl_tests -if [ $? -eq 0 ]; then - PassedTests -else - FailedTests - exit $? -fi -fi - -#****************************************************************************** -if [ "$compiler_enabled" = "clang" ] || [ "$compiler_enabled" = "All compilers" ]; then -compiler=$clang_compiler -SetConfigurationName "Error macros 'exceptions' test" -PrintHeader -cd ../../../etl_error_handler/exceptions -mkdir -p build-make || exit 1 -cd build-make || exit 1 -rm * -rf -cmake -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize .. -cmake --build . -if [ $? -eq 0 ]; then - PassedCompilation -else - FailedCompilation - exit $? -fi -./etl_tests -if [ $? -eq 0 ]; then - PassedTests -else - FailedTests - exit $? -fi -fi - -#****************************************************************************** -if [ "$compiler_enabled" = "clang" ] || [ "$compiler_enabled" = "All compilers" ]; then -compiler=$clang_compiler -SetConfigurationName "Error macros 'log_errors and exceptions' test" -PrintHeader -cd ../../../etl_error_handler/log_errors_and_exceptions -mkdir -p build-make || exit 1 -cd build-make || exit 1 -rm * -rf -cmake -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize .. -cmake --build . -if [ $? -eq 0 ]; then - PassedCompilation -else - FailedCompilation - exit $? -fi -./etl_tests -if [ $? -eq 0 ]; then - PassedTests -else - FailedTests - exit $? -fi -fi - -#****************************************************************************** -if [ "$compiler_enabled" = "clang" ] || [ "$compiler_enabled" = "All compilers" ]; then -compiler=$clang_compiler -SetConfigurationName "Error macros 'assert function' test" -PrintHeader -cd ../../../etl_error_handler/assert_function -mkdir -p build-make || exit 1 -cd build-make || exit 1 -rm * -rf -cmake -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DETL_OPTIMISATION=$opt -DETL_CXX_STANDARD=$cxx_standard -DETL_ENABLE_SANITIZER=$sanitize .. -cmake --build . -if [ $? -eq 0 ]; then - PassedCompilation -else - FailedCompilation - exit $? -fi -./etl_tests -if [ $? -eq 0 ]; then - PassedTests -else - FailedTests - exit $? -fi -fi cd ../.. diff --git a/test/test_atomic.cpp b/test/test_atomic.cpp index a4f16fd1c..572a9b47d 100644 --- a/test/test_atomic.cpp +++ b/test/test_atomic.cpp @@ -66,7 +66,7 @@ namespace ETL_END_ENUM_TYPE }; - SUITE(test_atomic_std) + SUITE(test_atomic) { //************************************************************************* TEST(test_atomic_integer_is_lock_free) @@ -76,7 +76,7 @@ namespace CHECK_EQUAL(compare.is_lock_free(), test.is_lock_free()); -//#if ETL_NOT_USING_STL && (defined(ETL_COMPILER_ARM5) || defined(ETL_COMPILER_ARM6) || defined(ETL_COMPILER_GCC) || defined(ETL_COMPILER_CLANG)) +//#if ETL_NOT_USING_STL && ETL_HAS_ATOMIC // CHECK_TRUE(etl::atomic::is_always_lock_free); // CHECK_TRUE(test.is_always_lock_free); //#endif @@ -90,10 +90,10 @@ namespace CHECK_EQUAL(compare.is_lock_free(), test.is_lock_free()); -//#if ETL_NOT_USING_STL && (defined(ETL_COMPILER_ARM5) || defined(ETL_COMPILER_ARM6) || defined(ETL_COMPILER_GCC) || defined(ETL_COMPILER_CLANG)) -// CHECK_TRUE(etl::atomic::is_always_lock_free); -// CHECK_TRUE(test.is_always_lock_free); -//#endif +#if ETL_NOT_USING_STL && ETL_HAS_ATOMIC + CHECK_TRUE(etl::atomic::is_always_lock_free); + CHECK_TRUE(test.is_always_lock_free); +#endif } //#if ETL_NOT_USING_STL && ETL_HAS_ATOMIC