From 413b6e0eca5f6c236e3bf4dca782eff6eb92ff8d Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Thu, 16 Feb 2012 23:17:23 +0400 Subject: [PATCH] Allow GC_exclude_static_roots() region start to be unaligned (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 | 3 +-- mark_rts.c | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/gc.h b/include/gc.h index ba49b481..80d104c0 100644 --- a/include/gc.h +++ b/include/gc.h @@ -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 */); diff --git a/mark_rts.c b/mark_rts.c index 3799a43e..ceba6aea 100644 --- a/mark_rts.c +++ b/mark_rts.c @@ -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(); -- 2.40.0