From: Daniel R. Grayson Date: Thu, 26 Jan 2012 04:42:33 +0000 (+0400) Subject: Fix GC_add_roots_inner for Mac OS X (enable GC_dyld_image_add to X-Git-Tag: gc7_2~77 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a16036324480dfae2b094f0fa6567db1b867c617;p=gc Fix GC_add_roots_inner for Mac OS X (enable GC_dyld_image_add to pass unaligned segment start to GC_add_roots) * mark_rts.c (GC_add_roots_inner): Round "b" pointer up to word boundary. * include/gc.h (GC_add_roots): Update the comment. --- diff --git a/include/gc.h b/include/gc.h index 81a3a7b8..b48ea268 100644 --- a/include/gc.h +++ b/include/gc.h @@ -452,7 +452,7 @@ GC_API void GC_CALL GC_exclude_static_roots(void * /* low_address */, GC_API void GC_CALL GC_clear_roots(void); /* Add a root segment. Wizards only. */ -/* The segment (referred to by low_address) must be pointer-aligned. */ +/* Both segment start and end are not needed to be pointer-aligned. */ /* low_address must not be greater than high_address_plus_1. */ GC_API void GC_CALL GC_add_roots(void * /* low_address */, void * /* high_address_plus_1 */); diff --git a/mark_rts.c b/mark_rts.c index 4cd97bdc..5eb4d140 100644 --- a/mark_rts.c +++ b/mark_rts.c @@ -156,11 +156,12 @@ void GC_add_roots_inner(ptr_t b, ptr_t e, GC_bool tmp) { struct roots * old; - /* Adjust and check range boundaries for safety */ - GC_ASSERT((word)b % sizeof(word) == 0); - e = (ptr_t)((word)e & ~(sizeof(word) - 1)); GC_ASSERT(b <= e); - if (b == e) return; /* nothing to do? */ + b = (ptr_t)(((word)b + (sizeof(word) - 1)) & ~(sizeof(word) - 1)); + /* round b up to word boundary */ + e = (ptr_t)((word)e & ~(sizeof(word) - 1)); + /* round e down to word boundary */ + if (b >= e) return; /* nothing to do */ # if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32) /* Spend the time to ensure that there are no overlapping */