Fix Cygwin64 build
authorYuki Okumura <mjt@cltn.org>
Tue, 2 Feb 2016 13:49:11 +0000 (22:49 +0900)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 3 Feb 2016 20:47:01 +0000 (23:47 +0300)
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

index 7cf9320..3effc03 100644 (file)
@@ -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. */