0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-12 13:01:07 +01:00

ircd::vg: Add stack register/deregister to interface.

ircd::vg: Use extern const bool for active(); minor reorg.
This commit is contained in:
Jason Volk 2020-10-16 09:48:33 -07:00
parent 8759f9d209
commit f6bc11b76a
6 changed files with 38 additions and 9 deletions

View file

@ -14,7 +14,7 @@
/// Valgrind memcheck hypercall suite /// Valgrind memcheck hypercall suite
namespace ircd::vg namespace ircd::vg
{ {
bool active() noexcept; extern const bool active;
size_t errors() noexcept; size_t errors() noexcept;
bool defined(const const_buffer &) noexcept; bool defined(const const_buffer &) noexcept;
@ -22,3 +22,9 @@ namespace ircd::vg
void set_undefined(const const_buffer &) noexcept; void set_undefined(const const_buffer &) noexcept;
void set_noaccess(const const_buffer &) noexcept; void set_noaccess(const const_buffer &) noexcept;
} }
namespace ircd::vg::stack
{
uint add(const mutable_buffer &) noexcept;
void del(const uint &id) noexcept;
}

View file

@ -121,10 +121,10 @@ libircd_la_LIBADD = \
libircd_la_SOURCES =# libircd_la_SOURCES =#
libircd_la_SOURCES += assert.cc libircd_la_SOURCES += assert.cc
libircd_la_SOURCES += info.cc libircd_la_SOURCES += info.cc
libircd_la_SOURCES += vg.cc
libircd_la_SOURCES += allocator.cc libircd_la_SOURCES += allocator.cc
libircd_la_SOURCES += allocator_gnu.cc libircd_la_SOURCES += allocator_gnu.cc
libircd_la_SOURCES += allocator_je.cc libircd_la_SOURCES += allocator_je.cc
libircd_la_SOURCES += vg.cc
libircd_la_SOURCES += exception.cc libircd_la_SOURCES += exception.cc
libircd_la_SOURCES += util.cc libircd_la_SOURCES += util.cc
libircd_la_SOURCES += demangle.cc libircd_la_SOURCES += demangle.cc

View file

@ -70,7 +70,7 @@ ircd::db::database::allocator::mlock_enabled
mlock_limit == -1UL mlock_limit == -1UL
// mlock2() not supported by valgrind // mlock2() not supported by valgrind
&& !vg::active() && !vg::active
}; };
decltype(ircd::db::database::allocator::mlock_current) decltype(ircd::db::database::allocator::mlock_current)

View file

@ -283,8 +283,8 @@ ircd::info::dump_cpu_info_x86()
hardware::virtualized? hardware::virtualized?
"virtual"_sv: "virtual"_sv:
"physical"_sv, "physical"_sv,
vg::active()? vg::active?
" valgrind "_sv: " valgrind"_sv:
""_sv, ""_sv,
support, support,
}; };

View file

@ -61,15 +61,38 @@ noexcept
#endif #endif
} }
bool decltype(ircd::vg::active)
ircd::vg::active() ircd::vg::active{[]() -> bool
noexcept
{ {
#ifdef HAVE_VALGRIND_VALGRIND_H #ifdef HAVE_VALGRIND_VALGRIND_H
return RUNNING_ON_VALGRIND; return RUNNING_ON_VALGRIND;
#else #else
return false; return false;
#endif #endif
}()};
//
// vg::stack
//
void
ircd::vg::stack::del(const uint &id)
noexcept
{
#ifdef HAVE_VALGRIND_MEMCHECK_H
VALGRIND_STACK_DEREGISTER(id);
#endif
}
uint
ircd::vg::stack::add(const mutable_buffer &buf)
noexcept
{
#ifdef HAVE_VALGRIND_MEMCHECK_H
return VALGRIND_STACK_REGISTER(ircd::data(buf) + ircd::size(buf), ircd::data(buf));
#else
return 0;
#endif
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View file

@ -1339,7 +1339,7 @@ console_cmd__mem__get(opt &out, const string_view &line)
bool bool
console_cmd__vg(opt &out, const string_view &line) console_cmd__vg(opt &out, const string_view &line)
{ {
if(vg::active()) if(vg::active)
out << "running on valgrind" << std::endl; out << "running on valgrind" << std::endl;
else else
out << "bare metal" << std::endl; out << "bare metal" << std::endl;