From df3304005a21498fff6ca7cc4b0f7e05bda8e662 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 13 Jun 2022 15:08:16 -0700 Subject: [PATCH] ircd: Properly scope various visibility/linkages. --- ircd/allocator_gnu.cc | 6 +++--- ircd/b58.cc | 3 +-- ircd/backtrace.cc | 2 +- ircd/ctx.cc | 2 +- ircd/demangle.cc | 15 +++++++++------ ircd/fs_path.cc | 8 ++++---- ircd/http2.cc | 2 +- 7 files changed, 20 insertions(+), 18 deletions(-) diff --git a/ircd/allocator_gnu.cc b/ircd/allocator_gnu.cc index b18a2197a..a79a7c563 100644 --- a/ircd/allocator_gnu.cc +++ b/ircd/allocator_gnu.cc @@ -21,17 +21,17 @@ extern "C" void (*__free_hook)(void *, const void *); namespace ircd::allocator { - void *(*their_malloc_hook)(size_t, const void *); + static void *(*their_malloc_hook)(size_t, const void *); [[gnu::weak]] void *malloc_hook(size_t, const void *); static void install_malloc_hook(); static void uninstall_malloc_hook(); - void *(*their_realloc_hook)(void *, size_t, const void *); + static void *(*their_realloc_hook)(void *, size_t, const void *); [[gnu::weak]] void *realloc_hook(void *, size_t, const void *); static void install_realloc_hook(); static void uninstall_realloc_hook(); - void (*their_free_hook)(void *, const void *); + static void (*their_free_hook)(void *, const void *); [[gnu::weak]] void free_hook(void *, const void *); static void install_free_hook(); static void uninstall_free_hook(); diff --git a/ircd/b58.cc b/ircd/b58.cc index 8cc3f70e8..2b2ecc27b 100644 --- a/ircd/b58.cc +++ b/ircd/b58.cc @@ -13,8 +13,7 @@ namespace ircd::b58 [[gnu::visibility("internal")]] extern const string_view dict; - [[gnu::visibility("internal")]] - thread_local char conv_tmp_buf[64_KiB]; + static thread_local char conv_tmp_buf[64_KiB]; } decltype(ircd::b58::dict) diff --git a/ircd/backtrace.cc b/ircd/backtrace.cc index e96c3c3f7..f4a5818f4 100644 --- a/ircd/backtrace.cc +++ b/ircd/backtrace.cc @@ -57,7 +57,7 @@ ircd_backtrace_allow_libc_fix() namespace ircd { - thread_local std::array backtrace_buffer; + static thread_local std::array backtrace_buffer; } ircd::backtrace::backtrace() diff --git a/ircd/ctx.cc b/ircd/ctx.cc index 8f10cf8a6..b087815a6 100644 --- a/ircd/ctx.cc +++ b/ircd/ctx.cc @@ -1633,7 +1633,7 @@ ircd::ctx::debug_stats(const pool &pool) namespace ircd::ctx::prof { - thread_local ticker _total; // Totals kept for all contexts. + static thread_local ticker _total; ///< Totals kept for all contexts. static void check_stack(); static void check_slice(); diff --git a/ircd/demangle.cc b/ircd/demangle.cc index c3348b0f4..0f6d0b69a 100644 --- a/ircd/demangle.cc +++ b/ircd/demangle.cc @@ -10,15 +10,19 @@ #include -thread_local char -outbuf[8192]; +namespace ircd +{ + static thread_local char + demangle_outbuf[8192], + demangle_symbuf[8192]; +} std::string ircd::demangle(const char *const &symbol) { const string_view demangled { - demangle(outbuf, symbol) + demangle(demangle_outbuf, symbol) }; return std::string(demangled); @@ -29,7 +33,7 @@ ircd::demangle(const string_view &symbol) { const string_view demangled { - demangle(outbuf, symbol) + demangle(demangle_outbuf, symbol) }; return std::string(demangled); @@ -40,10 +44,9 @@ ircd::demangle(const mutable_buffer &out, const string_view &symbol_) { assert(size(symbol_) < 4096); - thread_local char symbuf[8192]; const string_view symbol { - symbuf, strlcpy(symbuf, symbol_) + demangle_symbuf, strlcpy(demangle_symbuf, symbol_) }; return demangle(out, symbol.data()); diff --git a/ircd/fs_path.cc b/ircd/fs_path.cc index 36fce9854..4305bd49c 100644 --- a/ircd/fs_path.cc +++ b/ircd/fs_path.cc @@ -42,8 +42,8 @@ ircd::fs::PATH_MAX_LEN // Convenience scratch buffers for path making. namespace ircd::fs { - thread_local char _name_scratch[2][NAME_MAX_LEN]; - thread_local char _path_scratch[2][PATH_MAX_LEN]; + static thread_local char _name_scratch[2][NAME_MAX_LEN]; + static thread_local char _path_scratch[2][PATH_MAX_LEN]; } // External mutable_buffer to the scratch @@ -440,8 +440,8 @@ ircd::fs::pathconf(const string_view &path, namespace ircd::fs { static const size_t _PATH_CSTR_BUFS {4}; - thread_local char _path_cstr[_PATH_CSTR_BUFS][PATH_MAX_LEN]; - thread_local size_t _path_cstr_pos; + static thread_local char _path_cstr[_PATH_CSTR_BUFS][PATH_MAX_LEN]; + static thread_local size_t _path_cstr_pos; } const char * diff --git a/ircd/http2.cc b/ircd/http2.cc index ee894bbb0..818e0f750 100644 --- a/ircd/http2.cc +++ b/ircd/http2.cc @@ -99,7 +99,7 @@ static_assert namespace ircd::http2 { - thread_local char error_fmt_buf[512]; + static thread_local char error_fmt_buf[512]; } ircd::http2::error::error()