From dd30162c9ee51f40b6b0a20f4cd0e4e97c403461 Mon Sep 17 00:00:00 2001 From: joaquintides Date: Tue, 25 Jul 2023 09:18:53 +0200 Subject: [PATCH] simplified reentrancy check config --- .../unordered/detail/foa/reentrancy_check.hpp | 32 ++----------------- test/cfoa/reentrancy_check_test.cpp | 23 +++++++++---- 2 files changed, 18 insertions(+), 37 deletions(-) diff --git a/include/boost/unordered/detail/foa/reentrancy_check.hpp b/include/boost/unordered/detail/foa/reentrancy_check.hpp index b0e65c64..2855056a 100644 --- a/include/boost/unordered/detail/foa/reentrancy_check.hpp +++ b/include/boost/unordered/detail/foa/reentrancy_check.hpp @@ -12,37 +12,10 @@ #include #include -#if !defined(BOOST_UNORDERED_DISABLE_REENTRANCY_CHECK) -#if defined(BOOST_UNORDERED_ENABLE_REENTRANCY_CHECK_HANDLER)|| \ - (defined(BOOST_UNORDERED_ENABLE_REENTRANCY_CHECK_DEBUG_HANDLER)&& \ - !defined(NDEBUG))|| \ +#if !defined(BOOST_UNORDERED_DISABLE_REENTRANCY_CHECK)&& \ !defined(BOOST_ASSERT_IS_VOID) #define BOOST_UNORDERED_REENTRANCY_CHECK #endif -#endif - -#if defined(BOOST_UNORDERED_REENTRANCY_CHECK) -#if defined(BOOST_UNORDERED_ENABLE_REENTRANCY_CHECK_HANDLER)|| \ - defined(BOOST_UNORDERED_ENABLE_REENTRANCY_CHECK_DEBUG_HANDLER) - -#include /* BOOST_LIKELY */ - -namespace boost -{ - void boost_unordered_reentrancy_check_failed(); -} - -#define BOOST_UNORDERED_REENTRANCY_CHECK_ASSERT_MSG(expr,msg) \ -(BOOST_LIKELY(!!(expr))?((void)0): \ - ::boost::boost_unordered_reentrancy_check_failed()) - -#else - -#define BOOST_UNORDERED_REENTRANCY_CHECK_ASSERT_MSG(expr,msg) \ -BOOST_ASSERT_MSG(expr,msg) - -#endif -#endif namespace boost{ namespace unordered{ @@ -57,8 +30,7 @@ public: entry_trace(const void* px_):px{px_} { if(px){ - BOOST_UNORDERED_REENTRANCY_CHECK_ASSERT_MSG( - !find(px),"reentrancy not allowed"); + BOOST_ASSERT_MSG(!find(px),"reentrancy not allowed"); header()=this; } } diff --git a/test/cfoa/reentrancy_check_test.cpp b/test/cfoa/reentrancy_check_test.cpp index 09377459..d07c6cdf 100644 --- a/test/cfoa/reentrancy_check_test.cpp +++ b/test/cfoa/reentrancy_check_test.cpp @@ -2,19 +2,28 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt -#define BOOST_UNORDERED_ENABLE_REENTRANCY_CHECK_HANDLER +#include + +#define BOOST_ENABLE_ASSERT_HANDLER static bool reentrancy_detected = false; namespace boost { - // Caveat lector: a proper handler should terminate as it may be executed + // Caveat lector: a proper handler shouldn't throw as it may be executed // within a noexcept function. - void boost_unordered_reentrancy_check_failed() - { - reentrancy_detected = true; - throw 0; - } +void assertion_failed_msg( + char const*, char const*, char const*, char const*, long) +{ + reentrancy_detected = true; + throw 0; +} + +void assertion_failed(char const*, char const*, char const*, long) +{ + std::abort(); +} + } #include