0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 18:18:56 +02:00

ircd::ctx: #ifdef away linkages for ctx assertions in NDEBUG builds.

This commit is contained in:
Jason Volk 2018-04-27 19:16:56 -07:00
parent 3fcb8a1236
commit dc5ac7c2ac
2 changed files with 10 additions and 4 deletions

View file

@ -64,8 +64,10 @@ namespace ircd::ctx
///
struct ircd::ctx::this_ctx::stack_usage_assertion
{
#ifndef NDEBUG
stack_usage_assertion();
~stack_usage_assertion() noexcept;
#endif
};
/// An instance of critical_assertion detects an attempt to context switch.
@ -79,11 +81,13 @@ struct ircd::ctx::this_ctx::stack_usage_assertion
///
class ircd::ctx::this_ctx::critical_assertion
{
#ifndef NDEBUG
bool theirs;
public:
critical_assertion();
~critical_assertion() noexcept;
#endif
};
/// An instance of exception_handler must be present to allow a context

View file

@ -550,6 +550,7 @@ noexcept
//
// critical_assertion
//
#ifndef NDEBUG
namespace ircd::ctx
{
@ -569,27 +570,28 @@ noexcept
critical_asserted = theirs;
}
#endif // NDEBUG
//
// stack_usage_assertion
//
#ifndef NDEBUG
ircd::ctx::this_ctx::stack_usage_assertion::stack_usage_assertion()
{
#ifndef NDEBUG
const auto stack_usage(stack_usage_here());
assert(stack_usage < cur().stack_max * prof::settings.stack_usage_assertion);
#endif
}
ircd::ctx::this_ctx::stack_usage_assertion::~stack_usage_assertion()
noexcept
{
#ifdef RB_DEBUG
const auto stack_usage(stack_usage_here());
assert(stack_usage < cur().stack_max * prof::settings.stack_usage_assertion);
#endif
}
#endif // NDEBUG
///////////////////////////////////////////////////////////////////////////////
//
// ctx/continuation.h