0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01: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
{
extern const bool active;
size_t errors() noexcept;
bool defined(const const_buffer &) noexcept;
void set_defined(const const_buffer &) noexcept;
void set_undefined(const const_buffer &) noexcept;
void set_noaccess(const const_buffer &) noexcept;
[[gnu::hot]] size_t errors() noexcept;
[[gnu::hot]] bool defined(const void *, const size_t) noexcept;
template<class T> bool defined(const T *const &, const size_t & = sizeof(T));
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
{
uint add(const mutable_buffer &) noexcept;
void del(const uint &id) noexcept;
uint add(const mutable_buffer) 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")]]
void
ircd::vg::set_noaccess(const const_buffer &buf)
ircd::vg::set_noaccess(const const_buffer buf)
noexcept
{
#ifdef HAVE_VALGRIND_MEMCHECK_H
@ -24,7 +24,7 @@ noexcept
[[gnu::visibility("protected")]]
void
ircd::vg::set_undefined(const const_buffer &buf)
ircd::vg::set_undefined(const const_buffer buf)
noexcept
{
#ifdef HAVE_VALGRIND_MEMCHECK_H
@ -34,7 +34,7 @@ noexcept
[[gnu::visibility("protected")]]
void
ircd::vg::set_defined(const const_buffer &buf)
ircd::vg::set_defined(const const_buffer buf)
noexcept
{
#ifdef HAVE_VALGRIND_MEMCHECK_H
@ -44,11 +44,12 @@ noexcept
[[gnu::visibility("protected")]]
bool
ircd::vg::defined(const const_buffer &buf)
ircd::vg::defined(const void *const ptr,
const size_t size)
noexcept
{
#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
return true;
#endif
@ -82,7 +83,7 @@ ircd::vg::active{[]() -> bool
[[gnu::visibility("protected")]]
void
ircd::vg::stack::del(const uint &id)
ircd::vg::stack::del(const uint id)
noexcept
{
#ifdef HAVE_VALGRIND_MEMCHECK_H
@ -92,7 +93,7 @@ noexcept
[[gnu::visibility("protected")]]
uint
ircd::vg::stack::add(const mutable_buffer &buf)
ircd::vg::stack::add(const mutable_buffer buf)
noexcept
{
#ifdef HAVE_VALGRIND_MEMCHECK_H