]> 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 16:47:46 +0000 (20:47 +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 81a3a7b83b8e7bf0bd603c13774288b1b9124656..b48ea26861a28ad06587453bba46fd7abfc5ea85 100644 (file)
@@ -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 */);
index 4cd97bdc22a36241bf6af082b88d928503903036..5eb4d140f1a54dbd96e606b6d81624728ab4251a 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 */