0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-20 03:43:47 +02:00

ircd::vg: Add template convenience defined(); improve call interface.

This commit is contained in:
Jason Volk 2022-06-14 18:39:03 -07:00
parent f40b77c307
commit 4a18caf245
2 changed files with 32 additions and 14 deletions

View file

@ -15,16 +15,33 @@
namespace ircd::vg namespace ircd::vg
{ {
extern const bool active; extern const bool active;
size_t errors() noexcept;
bool defined(const const_buffer &) noexcept; [[gnu::hot]] size_t errors() noexcept;
void set_defined(const const_buffer &) noexcept; [[gnu::hot]] bool defined(const void *, const size_t) noexcept;
void set_undefined(const const_buffer &) noexcept; template<class T> bool defined(const T *const &, const size_t & = sizeof(T));
void set_noaccess(const const_buffer &) noexcept; bool defined(const const_buffer &);
void set_defined(const const_buffer) noexcept;
void set_undefined(const const_buffer) noexcept;
void set_noaccess(const const_buffer) noexcept;
} }
namespace ircd::vg::stack namespace ircd::vg::stack
{ {
uint add(const mutable_buffer &) noexcept; uint add(const mutable_buffer) noexcept;
void del(const uint &id) noexcept; void del(const uint id) noexcept;
}
inline bool
ircd::vg::defined(const const_buffer &buf)
{
return vg::defined(data(buf), size(buf));
}
template<class T>
inline bool
ircd::vg::defined(const T *const &t,
const size_t &size)
{
return vg::defined(static_cast<const void *>(t), size);
} }

View file

@ -14,7 +14,7 @@
[[gnu::visibility("protected")]] [[gnu::visibility("protected")]]
void void
ircd::vg::set_noaccess(const const_buffer &buf) ircd::vg::set_noaccess(const const_buffer buf)
noexcept noexcept
{ {
#ifdef HAVE_VALGRIND_MEMCHECK_H #ifdef HAVE_VALGRIND_MEMCHECK_H
@ -24,7 +24,7 @@ noexcept
[[gnu::visibility("protected")]] [[gnu::visibility("protected")]]
void void
ircd::vg::set_undefined(const const_buffer &buf) ircd::vg::set_undefined(const const_buffer buf)
noexcept noexcept
{ {
#ifdef HAVE_VALGRIND_MEMCHECK_H #ifdef HAVE_VALGRIND_MEMCHECK_H
@ -34,7 +34,7 @@ noexcept
[[gnu::visibility("protected")]] [[gnu::visibility("protected")]]
void void
ircd::vg::set_defined(const const_buffer &buf) ircd::vg::set_defined(const const_buffer buf)
noexcept noexcept
{ {
#ifdef HAVE_VALGRIND_MEMCHECK_H #ifdef HAVE_VALGRIND_MEMCHECK_H
@ -44,11 +44,12 @@ noexcept
[[gnu::visibility("protected")]] [[gnu::visibility("protected")]]
bool bool
ircd::vg::defined(const const_buffer &buf) ircd::vg::defined(const void *const ptr,
const size_t size)
noexcept noexcept
{ {
#ifdef HAVE_VALGRIND_MEMCHECK_H #ifdef HAVE_VALGRIND_MEMCHECK_H
return VALGRIND_CHECK_MEM_IS_DEFINED(data(buf), size(buf)) == 0; return VALGRIND_CHECK_MEM_IS_DEFINED(ptr, size) == 0;
#else #else
return true; return true;
#endif #endif
@ -82,7 +83,7 @@ ircd::vg::active{[]() -> bool
[[gnu::visibility("protected")]] [[gnu::visibility("protected")]]
void void
ircd::vg::stack::del(const uint &id) ircd::vg::stack::del(const uint id)
noexcept noexcept
{ {
#ifdef HAVE_VALGRIND_MEMCHECK_H #ifdef HAVE_VALGRIND_MEMCHECK_H
@ -92,7 +93,7 @@ noexcept
[[gnu::visibility("protected")]] [[gnu::visibility("protected")]]
uint uint
ircd::vg::stack::add(const mutable_buffer &buf) ircd::vg::stack::add(const mutable_buffer buf)
noexcept noexcept
{ {
#ifdef HAVE_VALGRIND_MEMCHECK_H #ifdef HAVE_VALGRIND_MEMCHECK_H