From 7acebaa837c8990057cac6150d53b9912ab8f5fe Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Tue, 26 Mar 2019 01:45:15 -0400 Subject: [PATCH] overhaul glibc compatibility workarounds --- util.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/util.h b/util.h index 82af552..3e76fd7 100644 --- a/util.h +++ b/util.h @@ -39,20 +39,30 @@ 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) +#ifdef __GLIBC__ +#if !__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 +#endif +#endif + +#ifndef atfork #define atfork pthread_atfork #endif #ifdef CONFIG_SEAL_METADATA -#if defined(__GLIBC__) && __GLIBC_PREREQ(2, 27) + +#ifdef __GLIBC__ +#if __GLIBC_PREREQ(2, 27) #define USE_PKEY -#else -#error "CONFIG_SEAL_METADATA requires Memory Protection Key support" #endif #endif +#ifndef USE_PKEY +#error "CONFIG_SEAL_METADATA requires Memory Protection Key support" +#endif + +#endif // CONFIG_SEAL_METADATA + #endif