From 4e24d219d29abb2b111bb9a9ccb13c3f149a855a Mon Sep 17 00:00:00 2001 From: Yuki Okumura Date: Tue, 2 Feb 2016 22:49:11 +0900 Subject: [PATCH] Fix Cygwin64 build On x86_64, Cygwin symbols do not have leading underscore anymore, so an additional underscore is needed on linker-generated symbols access from C. * include/gc.h (GC_DATASTART, GC_DATAEND): Prefix _data_start__, _bss_start__, _data_end__ and _bss_end__ with an extra underscore if __x86_64__ (only if __CYGWIN__); reformat code. --- include/gc.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/include/gc.h b/include/gc.h index 7cf93203..3effc03f 100644 --- a/include/gc.h +++ b/include/gc.h @@ -1733,11 +1733,21 @@ GC_API int GC_CALL GC_get_force_unmap_on_gcollect(void); #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__[]; -# define GC_DATASTART ((GC_word)_data_start__ < (GC_word)_bss_start__ ? \ - (void *)_data_start__ : (void *)_bss_start__) -# define GC_DATAEND ((GC_word)_data_end__ > (GC_word)_bss_end__ ? \ - (void *)_data_end__ : (void *)_bss_end__) +# ifdef __x86_64__ + /* Cygwin/x64 does not add leading underscore to symbols anymore. */ + extern int __data_start__[], __data_end__[]; + extern int __bss_start__[], __bss_end__[]; +# define GC_DATASTART ((GC_word)__data_start__ < (GC_word)__bss_start__ \ + ? (void *)__data_start__ : (void *)__bss_start__) +# define GC_DATAEND ((GC_word)__data_end__ > (GC_word)__bss_end__ \ + ? (void *)__data_end__ : (void *)__bss_end__) +# else + extern int _data_start__[], _data_end__[], _bss_start__[], _bss_end__[]; +# define GC_DATASTART ((GC_word)_data_start__ < (GC_word)_bss_start__ \ + ? (void *)_data_start__ : (void *)_bss_start__) +# define GC_DATAEND ((GC_word)_data_end__ > (GC_word)_bss_end__ \ + ? (void *)_data_end__ : (void *)_bss_end__) +# endif /* !__x86_64__ */ # define GC_INIT_CONF_ROOTS GC_add_roots(GC_DATASTART, GC_DATAEND); \ GC_gcollect() /* For blacklisting. */ /* Required at least if GC is in a DLL. And doesn't hurt. */ -- 2.49.0