2
0
mirror of https://github.com/boostorg/atomic.git synced 2026-02-02 20:32:09 +00:00

Changed is_lock_free() implementation to always use is_always_lock_free.

This is to follow C++17, which says is_lock_free(), for any object of a given
atomic<> type, must return values consistent with is_always_lock_free.
This commit is contained in:
Andrey Semashev
2017-05-25 13:38:39 +03:00
parent b7dba02b73
commit 7919698b2a
14 changed files with 7 additions and 121 deletions

View File

@@ -181,11 +181,6 @@ public:
return compare_exchange_weak(expected, desired, order, atomics::detail::deduce_failure_order(order));
}
BOOST_FORCEINLINE bool is_lock_free() const volatile BOOST_NOEXCEPT
{
return operations::is_lock_free(m_storage.value);
}
BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&))
BOOST_DELETED_FUNCTION(base_atomic& operator=(base_atomic const&))
@@ -337,11 +332,6 @@ public:
return static_cast< value_type >(operations::fetch_xor(m_storage.value, static_cast< storage_type >(v), order));
}
BOOST_FORCEINLINE bool is_lock_free() const volatile BOOST_NOEXCEPT
{
return operations::is_lock_free(m_storage.value);
}
BOOST_FORCEINLINE value_type operator++(int) volatile BOOST_NOEXCEPT
{
return fetch_add(1);
@@ -476,11 +466,6 @@ public:
return compare_exchange_weak(expected, desired, order, atomics::detail::deduce_failure_order(order));
}
BOOST_FORCEINLINE bool is_lock_free() const volatile BOOST_NOEXCEPT
{
return operations::is_lock_free(m_storage.value);
}
BOOST_DELETED_FUNCTION(base_atomic(base_atomic const&))
BOOST_DELETED_FUNCTION(base_atomic& operator=(base_atomic const&))
};
@@ -584,11 +569,6 @@ public:
return compare_exchange_weak(expected, desired, order, atomics::detail::deduce_failure_order(order));
}
BOOST_FORCEINLINE bool is_lock_free() const volatile BOOST_NOEXCEPT
{
return operations::is_lock_free(m_storage.value);
}
BOOST_FORCEINLINE value_type operator++(int) volatile BOOST_NOEXCEPT
{
return fetch_add(1);
@@ -655,11 +635,17 @@ public:
return v;
}
BOOST_FORCEINLINE operator value_type() volatile const BOOST_NOEXCEPT
BOOST_FORCEINLINE operator value_type() const volatile BOOST_NOEXCEPT
{
return this->load();
}
BOOST_FORCEINLINE bool is_lock_free() const volatile BOOST_NOEXCEPT
{
// C++17 requires all instances of atomic<> return a value consistent with is_always_lock_free here
return is_always_lock_free;
}
BOOST_FORCEINLINE storage_type& storage() BOOST_NOEXCEPT { return this->m_storage.value; }
BOOST_FORCEINLINE storage_type volatile& storage() volatile BOOST_NOEXCEPT { return this->m_storage.value; }
BOOST_FORCEINLINE storage_type const& storage() const BOOST_NOEXCEPT { return this->m_storage.value; }

View File

@@ -142,11 +142,6 @@ struct emulated_operations
{
store(storage, (storage_type)0, order);
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return false;
}
};
template< std::size_t Size, bool Signed >

View File

@@ -339,11 +339,6 @@ struct operations< 4u, Signed > :
{
store(storage, 0, order);
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
};
@@ -851,11 +846,6 @@ struct operations< 8u, Signed > :
{
store(storage, 0, order);
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
};

View File

@@ -404,11 +404,6 @@ struct operations< 4u, Signed > :
{
store(storage, 0, order);
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
};
@@ -946,11 +941,6 @@ struct operations< 8u, Signed > :
{
store(storage, 0, order);
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
};
#endif // defined(BOOST_ATOMIC_DETAIL_ARM_HAS_LDREXD_STREXD)

View File

@@ -161,11 +161,6 @@ struct gcc_atomic_operations
{
__atomic_clear(const_cast< storage_type* >(&storage), atomics::detail::convert_memory_order_to_gcc(order));
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile& storage) BOOST_NOEXCEPT
{
return __atomic_is_lock_free(sizeof(storage_type), &storage);
}
};
#if BOOST_ATOMIC_INT128_LOCK_FREE > 0

View File

@@ -331,11 +331,6 @@ struct operations< 4u, Signed > :
{
store(storage, 0, order);
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
};
@@ -758,11 +753,6 @@ struct operations< 8u, Signed > :
{
store(storage, 0, order);
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
};
#endif // defined(__powerpc64__) || defined(__PPC64__)

View File

@@ -120,11 +120,6 @@ struct gcc_sparc_cas32 :
fence_after(order);
return v;
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
};
template< bool Signed >
@@ -192,11 +187,6 @@ struct gcc_sparc_cas64 :
{
return compare_exchange_strong(storage, expected, desired, success_order, failure_order);
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
};
template< bool Signed >

View File

@@ -145,11 +145,6 @@ struct gcc_sync_operations :
if (order == memory_order_seq_cst)
__sync_synchronize();
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
};
#if BOOST_ATOMIC_INT8_LOCK_FREE > 0

View File

@@ -104,11 +104,6 @@ struct gcc_x86_operations :
{
store(storage, (storage_type)0, order);
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
};
template< bool Signed >

View File

@@ -354,11 +354,6 @@ struct gcc_dcas_x86
#endif // defined(__PIC__)
#endif
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
};
#endif // defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B)
@@ -611,11 +606,6 @@ struct gcc_dcas_x86_64
return v;
#endif
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
};
#endif // defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B)

View File

@@ -136,11 +136,6 @@ struct linux_arm_cas :
return false;
}
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
};
template< bool Signed >

View File

@@ -124,11 +124,6 @@ struct msvc_arm_operations :
{
Derived::store(storage, (storage_type)0, order);
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
};
template< bool Signed >

View File

@@ -154,11 +154,6 @@ struct msvc_x86_operations :
{
store(storage, (storage_type)0, order);
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
};
template< bool Signed >
@@ -799,11 +794,6 @@ struct msvc_dcas_x86
return v;
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
};
template< bool Signed >
@@ -893,11 +883,6 @@ struct msvc_dcas_x86_64
{
return compare_exchange_strong(storage, expected, desired, success_order, failure_order);
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
};
template< bool Signed >

View File

@@ -99,11 +99,6 @@ struct windows_operations :
{
store(storage, (storage_type)0, order);
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
};
template< bool Signed >