[Gc] Patch for Cygwin enabling USE_MMAP

Ivan Maidanski ivmai at mail.ru
Sun Oct 19 13:51:30 PDT 2008


Hi!

I suggest a small patch that makes it possible to compile GC for Cygwin target with -DUSE_MMAP. It is tested (and it works ok) with/without -DGC_THREADS and -DTHREAD_LOCAL_ALLOC.

Still it does not work with -DUSE_MUNMAP because of a failure in mmap(PROT_NONE+MAP_FIXED).

Note, however, that I don't know whether it's better (e.g., works more reliable or faster) to use USE_MMAP on Cygwin or not.

Bye.


-------------- next part --------------
diff -ru bdwgc/include/private/gc_priv.h updated/bdwgc/include/private/gc_priv.h
--- bdwgc/include/private/gc_priv.h     2008-10-17 10:52:28.000000000 +0400
+++ updated/bdwgc/include/private/gc_priv.h     2008-10-19 23:49:26.000000000 +0400
@@ -2032,7 +2032,7 @@
 /* were possible, and a couple of routines to facilitate       */
 /* catching accesses to bad addresses when that's              */
 /* possible/needed.                                            */
-#ifdef UNIX_LIKE
+#if defined(UNIX_LIKE) || (defined(NEED_FIND_LIMIT) && defined(CYGWIN32))
 # include <setjmp.h>
 # if defined(SUNOS5SIGS) && !defined(FREEBSD)
 #  include <sys/siginfo.h>
diff -ru bdwgc/include/private/gcconfig.h updated/bdwgc/include/private/gcconfig.h
--- bdwgc/include/private/gcconfig.h    2008-10-11 12:58:22.000000000 +0400
+++ updated/bdwgc/include/private/gcconfig.h    2008-10-19 23:09:32.000000000 +0400
@@ -1165,6 +1165,10 @@
 #      undef STACK_GRAN
 #       define STACK_GRAN 0x10000
 #       define HEURISTIC1
+#      ifdef USE_MMAP
+#        define NEED_FIND_LIMIT
+#        define USE_MMAP_ANON
+#      endif
 #   endif
 #   ifdef OS2
 #      define OS_TYPE "OS2"
diff -ru bdwgc/os_dep.c updated/bdwgc/os_dep.c
--- bdwgc/os_dep.c      2008-10-16 16:28:27.000000000 +0400
+++ updated/bdwgc/os_dep.c      2008-10-19 20:54:24.000000000 +0400
@@ -63,7 +63,7 @@
 #   include <signal.h>
 # endif
 
-#ifdef UNIX_LIKE
+#if defined(UNIX_LIKE) || defined(CYGWIN32)
 # include <fcntl.h>
 #endif
 
@@ -626,7 +626,8 @@
  * With threads, GC_mark_roots needs to know how to do this.
  * Called with allocator lock held.
  */
-# if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32)
+# if defined(MSWIN32) || defined(MSWINCE) \
+       || (defined(CYGWIN32) && !defined(USE_MMAP))
 # define is_writable(prot) ((prot) == PAGE_READWRITE \
                            || (prot) == PAGE_WRITECOPY \
                            || (prot) == PAGE_EXECUTE_READWRITE \
@@ -1004,7 +1005,7 @@
 
 #if !defined(BEOS) && !defined(AMIGA) && !defined(MSWIN32) \
     && !defined(MSWINCE) && !defined(OS2) && !defined(NOSYS) && !defined(ECOS) \
-    && !defined(CYGWIN32)
+    && (!defined(CYGWIN32) || defined(USE_MMAP))
 
 ptr_t GC_get_main_stack_base(void)
 {


More information about the Gc mailing list