]> granicus.if.org Git - gc/commitdiff
Fix GC_add_roots_inner for Mac OS X (enable GC_dyld_image_add to
authorDaniel R. Grayson <dan@math.uiuc.edu>
Thu, 26 Jan 2012 04:42:33 +0000 (08:42 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 26 Jan 2012 08:49:47 +0000 (12:49 +0400)
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.

include/gc.h
mark_rts.c

index 6ae6f772a5db4ef303605eeec5ee26f6741d5738..cdaf39e403139d106c4657c616386a1cfd923d2e 100644 (file)
@@ -468,7 +468,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 */);
index b7b81320fa92be4b5bb62f0af664acdced463de2..58f31df2d8c5b673b3652051a8a806bda722d590 100644 (file)
@@ -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 */