mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Added ETL_HAS_ATOMIC_ALWAYS_LOCK_FREE macro and has_atomic_always_lock_free trait
Fixed coditional unit tests in test_atomic
This commit is contained in:
parent
1274ba263b
commit
90e432cd43
@ -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);
|
||||
|
||||
@ -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<int>::is_always_lock_free);
|
||||
// CHECK_TRUE(test.is_always_lock_free);
|
||||
//#endif
|
||||
#if ETL_HAS_ATOMIC_ALWAYS_LOCK_FREE
|
||||
CHECK_TRUE(etl::atomic<int>::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<int*>::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<int>::is_always_lock_free);
|
||||
// CHECK_TRUE(etl::atomic<int*>::is_always_lock_free);
|
||||
// CHECK_FALSE(etl::atomic<S>::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<int>::is_always_lock_free);
|
||||
CHECK_TRUE(etl::atomic<int*>::is_always_lock_free);
|
||||
CHECK_FALSE(etl::atomic<S>::is_always_lock_free);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_atomic_integer_load)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user