forked from boostorg/unordered
simplified reentrancy check config
This commit is contained in:
@ -12,37 +12,10 @@
|
|||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#if !defined(BOOST_UNORDERED_DISABLE_REENTRANCY_CHECK)
|
#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))|| \
|
|
||||||
!defined(BOOST_ASSERT_IS_VOID)
|
!defined(BOOST_ASSERT_IS_VOID)
|
||||||
#define BOOST_UNORDERED_REENTRANCY_CHECK
|
#define BOOST_UNORDERED_REENTRANCY_CHECK
|
||||||
#endif
|
#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 boost{
|
||||||
namespace unordered{
|
namespace unordered{
|
||||||
@ -57,8 +30,7 @@ public:
|
|||||||
entry_trace(const void* px_):px{px_}
|
entry_trace(const void* px_):px{px_}
|
||||||
{
|
{
|
||||||
if(px){
|
if(px){
|
||||||
BOOST_UNORDERED_REENTRANCY_CHECK_ASSERT_MSG(
|
BOOST_ASSERT_MSG(!find(px),"reentrancy not allowed");
|
||||||
!find(px),"reentrancy not allowed");
|
|
||||||
header()=this;
|
header()=this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,19 +2,28 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// https://www.boost.org/LICENSE_1_0.txt
|
// 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;
|
static bool reentrancy_detected = false;
|
||||||
|
|
||||||
namespace boost {
|
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.
|
// within a noexcept function.
|
||||||
|
|
||||||
void boost_unordered_reentrancy_check_failed()
|
void assertion_failed_msg(
|
||||||
{
|
char const*, char const*, char const*, char const*, long)
|
||||||
reentrancy_detected = true;
|
{
|
||||||
throw 0;
|
reentrancy_detected = true;
|
||||||
}
|
throw 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void assertion_failed(char const*, char const*, char const*, long)
|
||||||
|
{
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <boost/unordered/concurrent_flat_map.hpp>
|
#include <boost/unordered/concurrent_flat_map.hpp>
|
||||||
|
Reference in New Issue
Block a user