From f39e7647ed47615a604869d86740914262d92ba6 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 10 Apr 2019 23:25:50 +0300 Subject: [PATCH] Fix 'un-mprotect failed' gctest error on Cygwin (fix of commit fa7f7a72b) Issue #272 (bdwgc). * include/private/gcconfig.h [(I386 || X86_64) && CYGWIN32] (MPROTECT_VDB): Do not define if USE_WINALLOC. * os_dep.c [CYGWIN32 && MPROTECT_VDB] (GC_setpagesize): Set GC_page_size to dwAllocationGranularity. --- include/private/gcconfig.h | 18 +++++++++++------- os_dep.c | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index 0c0aa82..9b5e8b1 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -1542,12 +1542,14 @@ EXTERN_C_BEGIN # define OS_TYPE "CYGWIN32" # define DATASTART ((ptr_t)GC_DATASTART) /* From gc.h */ # define DATAEND ((ptr_t)GC_DATAEND) -# define MPROTECT_VDB # ifdef USE_WINALLOC # define GWW_VDB -# elif defined(USE_MMAP) -# define NEED_FIND_LIMIT -# define USE_MMAP_ANON +# else +# define MPROTECT_VDB +# ifdef USE_MMAP +# define NEED_FIND_LIMIT +# define USE_MMAP_ANON +# endif # endif # endif # ifdef INTERIX @@ -2771,11 +2773,13 @@ EXTERN_C_BEGIN # endif # ifdef CYGWIN32 # define OS_TYPE "CYGWIN32" -# define MPROTECT_VDB # ifdef USE_WINALLOC # define GWW_VDB -# elif defined(USE_MMAP) -# define USE_MMAP_ANON +# else +# define MPROTECT_VDB +# ifdef USE_MMAP +# define USE_MMAP_ANON +# endif # endif # endif # ifdef MSWIN_XBOX1 diff --git a/os_dep.c b/os_dep.c index 49f6a01..23a83e4 100644 --- a/os_dep.c +++ b/os_dep.c @@ -710,7 +710,7 @@ GC_INNER size_t GC_page_size = 0; GC_INNER void GC_setpagesize(void) { GetSystemInfo(&GC_sysinfo); -# if defined(CYGWIN32) && defined(USE_MUNMAP) +# if defined(CYGWIN32) && (defined(MPROTECT_VDB) || defined(USE_MUNMAP)) /* Allocations made with mmap() are aligned to the allocation */ /* granularity, which (at least on 64-bit Windows OS) is not the */ /* same as the page size. Probably a separate variable could */ -- 2.7.4