diff --git a/include/etl/platform.h b/include/etl/platform.h index 5f92528e..6738b499 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -434,6 +434,15 @@ SOFTWARE. #else #define ETL_HAS_ATOMIC 0 #endif + #if ((ETL_USING_CPP17 && (ETL_USING_STL || defined(ETL_IN_UNIT_TEST))) || \ + defined(ETL_COMPILER_ARM5) || \ + defined(ETL_COMPILER_ARM6) || \ + defined(ETL_COMPILER_GCC) || \ + defined(ETL_COMPILER_CLANG)) + #define ETL_HAS_ATOMIC_ALWAYS_LOCK_FREE 1 + #else + #define ETL_HAS_ATOMIC_ALWAYS_LOCK_FREE 0 + #endif #endif //************************************* @@ -524,6 +533,7 @@ namespace etl static ETL_CONSTANT bool has_8bit_types = (ETL_USING_8BIT_TYPES == 1); static ETL_CONSTANT bool has_64bit_types = (ETL_USING_64BIT_TYPES == 1); static ETL_CONSTANT bool has_atomic = (ETL_HAS_ATOMIC == 1); + static ETL_CONSTANT bool has_atomic_always_lock_free = (ETL_HAS_ATOMIC_ALWAYS_LOCK_FREE == 1); static ETL_CONSTANT bool has_nullptr = (ETL_HAS_NULLPTR == 1); static ETL_CONSTANT bool has_char8_t = (ETL_HAS_CHAR8_T == 1); static ETL_CONSTANT bool has_native_char8_t = (ETL_HAS_NATIVE_CHAR8_T == 1); diff --git a/test/test_atomic.cpp b/test/test_atomic.cpp index 572a9b47..281b7650 100644 --- a/test/test_atomic.cpp +++ b/test/test_atomic.cpp @@ -76,10 +76,10 @@ namespace CHECK_EQUAL(compare.is_lock_free(), test.is_lock_free()); -//#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_HAS_ATOMIC_ALWAYS_LOCK_FREE + CHECK_TRUE(etl::atomic::is_always_lock_free); + CHECK_TRUE(test.is_always_lock_free); +#endif } //************************************************************************* @@ -90,28 +90,28 @@ namespace CHECK_EQUAL(compare.is_lock_free(), test.is_lock_free()); -#if ETL_NOT_USING_STL && ETL_HAS_ATOMIC +#if ETL_HAS_ATOMIC_ALWAYS_LOCK_FREE CHECK_TRUE(etl::atomic::is_always_lock_free); CHECK_TRUE(test.is_always_lock_free); #endif } -//#if ETL_NOT_USING_STL && ETL_HAS_ATOMIC -// //************************************************************************* -// TEST(test_atomic_is_always_lock_free) -// { -// struct S -// { -// int a; -// int b; -// int c; -// }; -// -// CHECK_TRUE(etl::atomic::is_always_lock_free); -// CHECK_TRUE(etl::atomic::is_always_lock_free); -// CHECK_FALSE(etl::atomic::is_always_lock_free); -// } -//#endif +#if ETL_HAS_ATOMIC_ALWAYS_LOCK_FREE + //************************************************************************* + TEST(test_atomic_is_always_lock_free) + { + struct S + { + int a; + int b; + int c; + }; + + CHECK_TRUE(etl::atomic::is_always_lock_free); + CHECK_TRUE(etl::atomic::is_always_lock_free); + CHECK_FALSE(etl::atomic::is_always_lock_free); + } +#endif //************************************************************************* TEST(test_atomic_integer_load)