From 68db7cf9e2f0fb2d78acbd356a9dd98029ece11d Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 28 May 2022 00:11:51 -0700 Subject: [PATCH] ircd::allocator::je: Minor cleanup; consistent defs; simplify casts; remove tiny tls. --- ircd/allocator_je.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ircd/allocator_je.cc b/ircd/allocator_je.cc index e48f9ec56..38d74cc33 100644 --- a/ircd/allocator_je.cc +++ b/ircd/allocator_je.cc @@ -16,9 +16,11 @@ namespace ircd::allocator::je { - static std::function stats_callback; + using callback_prototype = void (std::ostream &, const string_view &); + static void stats_handler(void *, const char *) noexcept; + static std::function stats_callback; extern info::versions malloc_version_api; extern info::versions malloc_version_abi; } @@ -57,7 +59,10 @@ ircd::allocator::je::malloc_version_abi #ifdef IRCD_ALLOCATOR_JEMALLOC const string_view val { - *reinterpret_cast(data(allocator::get("version", buf))) + *reinterpret_cast + ( + data(allocator::get("version", buf)) + ) }; if(!val) @@ -94,7 +99,7 @@ ircd::string_view ircd::allocator::get(const string_view &key_, const mutable_buffer &buf) { - thread_local char key[128]; + char key[128]; strlcpy(key, key_); size_t len(size(buf)); @@ -112,11 +117,11 @@ ircd::allocator::set(const string_view &key_, const string_view &val, const mutable_buffer &cur) { - thread_local char key[128]; + char key[128]; strlcpy(key, key_); size_t curlen(size(cur)); - syscall(::mallctl, key, data(cur), &curlen, const_cast(data(val)), size(val)); + syscall(::mallctl, key, data(cur), &curlen, mutable_cast(data(val)), size(val)); return string_view { data(cur), std::min(curlen, size(cur)) @@ -156,7 +161,7 @@ ircd::allocator::info(const mutable_buffer &buf, out << msg; }; - thread_local char opts_buf[64]; + char opts_buf[64]; const char *const opts { opts_?