From: Bernd Edlinger Date: Thu, 22 May 2014 21:53:21 +0000 (+0400) Subject: Fix (enable) Cygwin-64 build X-Git-Tag: gc7_4_2~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a75dfe9f74ea7ffe49e15e91be9b2bac7b6020c7;p=gc Fix (enable) Cygwin-64 build * 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). --- diff --git a/include/gc.h b/include/gc.h index 3715df31..2ed29184 100644 --- a/include/gc.h +++ b/include/gc.h @@ -1592,7 +1592,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__[]; diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index f866cc4e..c753cc2b 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -481,7 +481,11 @@ # 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 @@ -1892,6 +1896,17 @@ # 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" diff --git a/os_dep.c b/os_dep.c index 2ff72efa..08c501df 100644 --- 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 */