forked from boostorg/unordered
simplified reentrancy check config
This commit is contained in:
@ -12,37 +12,10 @@
|
||||
#include <boost/assert.hpp>
|
||||
#include <utility>
|
||||
|
||||
#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/config.hpp> /* 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;
|
||||
}
|
||||
}
|
||||
|
@ -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 <cstdlib>
|
||||
|
||||
#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 <boost/unordered/concurrent_flat_map.hpp>
|
||||
|
Reference in New Issue
Block a user