From 8abcf666cb638152634790a882875f52f7f0432b Mon Sep 17 00:00:00 2001 From: stijn Date: Thu, 12 Jun 2014 17:45:41 +0200 Subject: 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. --- unix/gccollect.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'unix/gccollect.c') diff --git a/unix/gccollect.c b/unix/gccollect.c index 1014a2629b..792913821f 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**)®s, ((machine_uint_t)stack_top - (machine_uint_t)®s) / 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 ®s to void** directly so use a union. + union { regs_t *r; void **ptr; } cast_regs = { ®s }; + void **regs_ptr = cast_regs.ptr; +#else + void **regs_ptr = (void**)®s; +#endif + gc_collect_root(regs_ptr, ((machine_uint_t)stack_top - (machine_uint_t)®s) / sizeof(machine_uint_t)); gc_collect_end(); //printf("-----\n"); -- cgit v1.2.3 From de5ce6d4613093f06de34746e865b32bcc243dd9 Mon Sep 17 00:00:00 2001 From: stijn Date: Thu, 19 Jun 2014 13:53:15 +0200 Subject: gc: Use simple cast instead of union to silence compiler --- unix/gccollect.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'unix/gccollect.c') diff --git a/unix/gccollect.c b/unix/gccollect.c index 792913821f..f24cc52495 100644 --- a/unix/gccollect.c +++ b/unix/gccollect.c @@ -144,15 +144,7 @@ void gc_collect(void) { regs_t regs; gc_helper_get_regs(regs); // GC stack (and regs because we captured them) -#ifdef __MINGW32__ - // The Mingw cross-compiler on Travis complains - // 'warning: dereferencing type-punned pointer will break strict-aliasing rules' - // when casting ®s to void** directly so use a union. - union { regs_t *r; void **ptr; } cast_regs = { ®s }; - void **regs_ptr = cast_regs.ptr; -#else - void **regs_ptr = (void**)®s; -#endif + void **regs_ptr = (void**)(void*)®s; gc_collect_root(regs_ptr, ((machine_uint_t)stack_top - (machine_uint_t)®s) / sizeof(machine_uint_t)); gc_collect_end(); -- cgit v1.2.3