Fix (enable) Cygwin-64 build
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Thu, 22 May 2014 21:53:21 +0000 (01:53 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 22 May 2014 21:53:21 +0000 (01:53 +0400)
* include/gc.h (GC_DATASTART, GC_DATAEND): Define for Cygwin-64.
* include/private/gcconfig.h (X86_64): Likewise.
* include/private/gcconfig.h (OS_TYPE, DATASTART, DATAEND, STACK_GRAN,
NEED_FIND_LIMIT, USE_MMAP_ANON): Define for Cygwin-64 (code copied
from Cygwin-32 block).
* os_dep.c (GC_get_stack_base): Get the stack base for Cygwin-64
(implementation based on NtCurrentTeb call).

include/gc.h
include/private/gcconfig.h
os_dep.c

index 64a2663..52c82a0 100644 (file)
@@ -1600,7 +1600,7 @@ GC_API int GC_CALL GC_get_force_unmap_on_gcollect(void);
 /* THREAD_LOCAL_ALLOC defined and the initial allocation call is not    */
 /* to GC_malloc() or GC_malloc_atomic().                                */
 
-#ifdef __CYGWIN32__
+#if defined(__CYGWIN32__) || defined(__CYGWIN__)
   /* Similarly gnu-win32 DLLs need explicit initialization from the     */
   /* main program, as does AIX.                                         */
   extern int _data_start__[], _data_end__[], _bss_start__[], _bss_end__[];
index 5aaf550..7d0fc0d 100644 (file)
 #   define mach_type_known
 # endif
 # if defined(__CYGWIN32__) || defined(__CYGWIN__)
-#   define I386
+#   if defined(__LP64__)
+#     define X86_64
+#   else
+#     define I386
+#   endif
 #   define CYGWIN32
 #   define mach_type_known
 # endif
 #         endif /* __INTEL_COMPILER */
 #       endif
 #   endif
+#   ifdef CYGWIN32
+#       define OS_TYPE "CYGWIN32"
+#       define DATASTART ((ptr_t)GC_DATASTART)  /* From gc.h */
+#       define DATAEND   ((ptr_t)GC_DATAEND)
+#       undef STACK_GRAN
+#       define STACK_GRAN 0x10000
+#       ifdef USE_MMAP
+#         define NEED_FIND_LIMIT
+#         define USE_MMAP_ANON
+#       endif
+#   endif
 #   ifdef MSWIN32
       /* FIXME: This is a very partial guess.  There is no port, yet.   */
 #     define OS_TYPE "MSWIN32"
index 09327f5..f8f3e0f 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -795,11 +795,15 @@ GC_INNER word GC_page_size = 0;
     /* gcc version of boehm-gc).                                        */
     GC_API int GC_CALL GC_get_stack_base(struct GC_stack_base *sb)
     {
-      void * _tlsbase;
+#     ifdef X86_64
+        sb -> mem_base = ((NT_TIB*)NtCurrentTeb())->StackBase;
+#     else
+        void * _tlsbase;
 
-      __asm__ ("movl %%fs:4, %0"
-               : "=r" (_tlsbase));
-      sb -> mem_base = _tlsbase;
+        __asm__ ("movl %%fs:4, %0"
+                 : "=r" (_tlsbase));
+        sb -> mem_base = _tlsbase;
+#     endif
       return GC_SUCCESS;
     }
 # endif /* CYGWIN32 */