From fc8f2c3b608c9ee9b57a05e4a43923f72f67863f Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Mon, 25 Mar 2019 16:38:16 -0400 Subject: [PATCH] move pthread_atfork wrapper to util header --- h_malloc.c | 10 ---------- util.h | 9 +++++++++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/h_malloc.c b/h_malloc.c index ed632bd..46e38a6 100644 --- a/h_malloc.c +++ b/h_malloc.c @@ -21,17 +21,7 @@ #include "random.h" #include "util.h" -// use __register_atfork directly to avoid linking with libpthread for glibc < 2.28 -#if defined(__GLIBC__) && !__GLIBC_PREREQ(2, 28) -extern void *__dso_handle; -extern int __register_atfork(void (*)(void), void (*)(void), void (*)(void), void *); -#define atfork(prepare, parent, child) __register_atfork(prepare, parent, child, __dso_handle) -#else -#define atfork pthread_atfork -#endif - #define SLAB_QUARANTINE (SLAB_QUARANTINE_RANDOM_LENGTH > 0 || SLAB_QUARANTINE_QUEUE_LENGTH > 0) - #define MREMAP_MOVE_THRESHOLD (32 * 1024 * 1024) static_assert(sizeof(void *) == 8, "64-bit only"); diff --git a/util.h b/util.h index ec0db7d..82af552 100644 --- a/util.h +++ b/util.h @@ -38,6 +38,15 @@ typedef uint32_t u32; typedef uint64_t u64; typedef unsigned __int128 u128; +// use __register_atfork directly to avoid linking with libpthread for glibc < 2.28 +#if defined(__GLIBC__) && !__GLIBC_PREREQ(2, 28) +extern void *__dso_handle; +extern int __register_atfork(void (*)(void), void (*)(void), void (*)(void), void *); +#define atfork(prepare, parent, child) __register_atfork(prepare, parent, child, __dso_handle) +#else +#define atfork pthread_atfork +#endif + #ifdef CONFIG_SEAL_METADATA #if defined(__GLIBC__) && __GLIBC_PREREQ(2, 27) #define USE_PKEY