From 32704bf8af77b7d2343d1ffc0e85ef0a735ab890 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 3 Oct 2018 11:02:07 +0300 Subject: [PATCH] Fix memory allocation on GCF (Linux/x64) Issue #225 (bdwgc). GCF (Google Cloud Function) seems to have mmap("/dev/zero") operation unsupported. The workaround is to use mmap(MAP_ANONYMOUS). * include/private/gcconfig.h [X86_64 && LINUX && __GLIBC__ && !__UCLIBC__] (USE_MMAP_ANON): Define macro; add comment. --- include/private/gcconfig.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index 7abdf61..5671402 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -2622,13 +2622,15 @@ EXTERN_C_BEGIN # define DATASTART ((ptr_t)((((word)(etext)) + 0xfff) & ~0xfff)) # endif # if defined(__GLIBC__) && !defined(__UCLIBC__) + /* A workaround for GCF (Google Cloud Function) which does */ + /* not support mmap() for "/dev/zero". Should not cause any */ + /* harm to other targets. */ +# define USE_MMAP_ANON /* At present, there's a bug in GLibc getcontext() on */ /* Linux/x64 (it clears FPU exception mask). We define this */ /* macro to workaround it. */ /* TODO: This seems to be fixed in GLibc v2.14. */ # define GETCONTEXT_FPU_EXCMASK_BUG -# endif -# if defined(__GLIBC__) && !defined(__UCLIBC__) /* Workaround lock elision implementation for some glibc. */ # define GLIBC_2_19_TSX_BUG EXTERN_C_END -- 2.7.4