From b598add0d1adc9b8ad311b0928f63254fe69073c Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Thu, 1 Jul 2021 11:07:31 +0100 Subject: [PATCH] Fix the build with GCC and libc cleanup. (#341) GCC is a lot more picky about extern "C" definitions in namespaces than clang and so the `friend` declaration wasn't picked up by the version of the function declared in the `snmalloc` namespace. Move it out to where GCC is happy with it. --- src/mem/threadalloc.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/mem/threadalloc.h b/src/mem/threadalloc.h index 306c782..0fd0dc4 100644 --- a/src/mem/threadalloc.h +++ b/src/mem/threadalloc.h @@ -254,14 +254,6 @@ namespace snmalloc }; # ifdef SNMALLOC_USE_THREAD_CLEANUP - /** - * Entry point that allows libc to call into the allocator for per-thread - * cleanup. - */ - extern "C" void _malloc_thread_cleanup() - { - ThreadAllocLibcCleanup::inner_release(); - } using ThreadAlloc = ThreadAllocLibcCleanup; # else using ThreadAlloc = ThreadAllocThreadDestructor; @@ -306,3 +298,13 @@ namespace snmalloc } #endif } // namespace snmalloc +#ifdef SNMALLOC_USE_THREAD_CLEANUP +/** + * Entry point that allows libc to call into the allocator for per-thread + * cleanup. + */ +void _malloc_thread_cleanup() +{ + snmalloc::ThreadAllocLibcCleanup::inner_release(); +} +#endif