Allow disabling the Debug-mode check in the ABA

This commit is contained in:
Istvan Haller
2021-07-05 13:08:42 +01:00
committed by Matthew Parkinson
parent b598add0d1
commit dcd47a0449

View File

@@ -13,7 +13,7 @@
*/
namespace snmalloc
{
#ifndef NDEBUG
#if !defined(NDEBUG) && !defined(SNMALLOC_DISABLE_ABA_VERIFY)
// LL/SC typically can only perform one operation at a time
// check this on other platforms using a thread_local.
inline thread_local bool operation_in_flight = false;
@@ -75,7 +75,7 @@ namespace snmalloc
Cmp read()
{
# ifndef NDEBUG
# if !defined(NDEBUG) && !defined(SNMALLOC_DISABLE_ABA_VERIFY)
if (operation_in_flight)
error("Only one inflight ABA operation at a time is allowed.");
operation_in_flight = true;
@@ -127,7 +127,7 @@ namespace snmalloc
~Cmp()
{
# ifndef NDEBUG
# if !defined(NDEBUG) && !defined(SNMALLOC_DISABLE_ABA_VERIFY)
operation_in_flight = false;
# endif
}
@@ -170,7 +170,7 @@ namespace snmalloc
while (lock.test_and_set(std::memory_order_acquire))
Aal::pause();
# ifndef NDEBUG
# if !defined(NDEBUG) && !defined(SNMALLOC_DISABLE_ABA_VERIFY)
if (operation_in_flight)
error("Only one inflight ABA operation at a time is allowed.");
operation_in_flight = true;
@@ -198,7 +198,7 @@ namespace snmalloc
~Cmp()
{
parent->lock.clear(std::memory_order_release);
# ifndef NDEBUG
# if !defined(NDEBUG) && !defined(SNMALLOC_DISABLE_ABA_VERIFY)
operation_in_flight = false;
# endif
}