]> granicus.if.org Git - gc/commitdiff
Allow GC_exclude_static_roots() region start to be unaligned
authorIvan Maidanski <ivmai@mail.ru>
Thu, 16 Feb 2012 19:17:23 +0000 (23:17 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 16 Feb 2012 19:17:53 +0000 (23:17 +0400)
(let the client not to care about the alignment of excluded memory area)

* include/gc.h (GC_exclude_static_roots): Update the comment.
* mark_rts.c (GC_exclude_static_roots): Allow the lower boundary to be
unaligned as well; reverse boundary rounding direction (since the
boundaries specify exclusion region); update the comment.

include/gc.h
mark_rts.c

index ba49b4818e40d7a290b885e34eb5de1b55293ee0..80d104c057f6fa9df5de1660c244fdc330920e2b 100644 (file)
@@ -473,8 +473,7 @@ GC_API void GC_CALL GC_set_max_heap_size(GC_word /* n */);
 /* need not be scanned.  This is sometimes important if the application */
 /* maps large read/write files into the address space, which could be   */
 /* mistaken for dynamic library data segments on some systems.          */
-/* The section (referred to by low_address) must be pointer-aligned.    */
-/* low_address must not be greater than high_address_plus_1.            */
+/* Both section start and end are not needed to be pointer-aligned.     */
 GC_API void GC_CALL GC_exclude_static_roots(void * /* low_address */,
                                             void * /* high_address_plus_1 */);
 
index 3799a43ef3906004d4c6bcbabc781bc5318614b2..ceba6aea400844c4c69ab2f1437b4cd83626c035 100644 (file)
@@ -471,11 +471,13 @@ GC_API void GC_CALL GC_exclude_static_roots(void *b, void *e)
 {
     DCL_LOCK_STATE;
 
-    /* Adjust the upper boundary for safety (round down) */
-    e = (void *)((word)e & ~(sizeof(word) - 1));
-
     if (b == e) return;  /* nothing to exclude? */
 
+    /* Round boundaries (in direction reverse to that of GC_add_roots). */
+    b = (void *)((word)b & ~(sizeof(word) - 1));
+    e = (void *)(((word)e + (sizeof(word) - 1)) & ~(sizeof(word) - 1));
+    if (0 == e) e = (void *)(~(sizeof(word) - 1)); /* handle overflow */
+
     LOCK();
     GC_exclude_static_roots_inner(b, e);
     UNLOCK();