summaryrefslogtreecommitdiff
path: root/unix/gccollect.c
diff options
context:
space:
mode:
authorstijn <stinos@zoho.com>2014-06-12 17:45:41 +0200
committerstijn <stinos@zoho.com>2014-06-22 11:31:16 +0200
commit8abcf666cb638152634790a882875f52f7f0432b (patch)
treede8e071187cc0dad925f597d0659e7c52e1f907e /unix/gccollect.c
parenta96cc824bdacb34ced0edef523181c215fba313b (diff)
windows: Enable GC and implement bss start and end symbols
The pointers to the bss section are acquired in init.c() by inspecting the PE header. Works for msvc and mingw.
Diffstat (limited to 'unix/gccollect.c')
-rw-r--r--unix/gccollect.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/unix/gccollect.c b/unix/gccollect.c
index 1014a2629..792913821 100644
--- a/unix/gccollect.c
+++ b/unix/gccollect.c
@@ -130,8 +130,11 @@ void gc_collect(void) {
gc_collect_start();
// this traces the .bss section
-#ifdef __CYGWIN__
+#if defined( __CYGWIN__ )
#define BSS_START __bss_start__
+#elif defined( _MSC_VER ) || defined( __MINGW32__ )
+#define BSS_START *bss_start
+#define _end *bss_end
#else
#define BSS_START __bss_start
#endif
@@ -141,7 +144,16 @@ void gc_collect(void) {
regs_t regs;
gc_helper_get_regs(regs);
// GC stack (and regs because we captured them)
- gc_collect_root((void**)&regs, ((machine_uint_t)stack_top - (machine_uint_t)&regs) / sizeof(machine_uint_t));
+#ifdef __MINGW32__
+ // The Mingw cross-compiler on Travis complains
+ // 'warning: dereferencing type-punned pointer will break strict-aliasing rules'
+ // when casting &regs to void** directly so use a union.
+ union { regs_t *r; void **ptr; } cast_regs = { &regs };
+ void **regs_ptr = cast_regs.ptr;
+#else
+ void **regs_ptr = (void**)&regs;
+#endif
+ gc_collect_root(regs_ptr, ((machine_uint_t)stack_top - (machine_uint_t)&regs) / sizeof(machine_uint_t));
gc_collect_end();
//printf("-----\n");