summaryrefslogtreecommitdiff
path: root/mark_rts.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2023-04-11 22:10:09 +0300
committerIvan Maidanski <ivmai@mail.ru>2023-04-11 22:23:14 +0300
commit4c0c2e42923f3e4912d848fd034935650e63fe56 (patch)
treefc43b9e6c7461a4a41d317beaa8504effceafd14 /mark_rts.c
parent6eb3dd3483fa870176ffe6390bd964b67208dce0 (diff)
downloadbdwgc-4c0c2e42923f3e4912d848fd034935650e63fe56.tar.gz
Acquire GC lock in GC_is_tmp_root
* include/gc/gc_mark.h (GC_is_tmp_root): Document function. * include/gc/gc_mark.h (GC_is_tmp_root): Add comment that the function acquires the GC lock. * mark_rts.c [!NO_DEBUGGING] (GC_is_tmp_root): Likewise. * mark_rts.c [!NO_DEBUGGING] (GC_is_tmp_root): Define res local variable; change code to have only single return statement; wrap code into LOCK/UNLOCK.
Diffstat (limited to 'mark_rts.c')
-rw-r--r--mark_rts.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/mark_rts.c b/mark_rts.c
index 5caff4af..289d7024 100644
--- a/mark_rts.c
+++ b/mark_rts.c
@@ -469,23 +469,32 @@ STATIC void GC_remove_roots_inner(ptr_t b, ptr_t e)
/* For the debugging purpose only. */
/* Workaround for the OS mapping and unmapping behind our back: */
/* Is the address p in one of the temporary static root sections? */
+ /* Acquires the GC lock. */
GC_API int GC_CALL GC_is_tmp_root(void *p)
{
static int last_root_set = MAX_ROOT_SETS;
- int i;
+ int res;
+ LOCK();
if (last_root_set < n_root_sets
&& (word)p >= (word)GC_static_roots[last_root_set].r_start
- && (word)p < (word)GC_static_roots[last_root_set].r_end)
- return GC_static_roots[last_root_set].r_tmp;
- for (i = 0; i < n_root_sets; i++) {
+ && (word)p < (word)GC_static_roots[last_root_set].r_end) {
+ res = (int)GC_static_roots[last_root_set].r_tmp;
+ } else {
+ int i;
+
+ res = 0;
+ for (i = 0; i < n_root_sets; i++) {
if ((word)p >= (word)GC_static_roots[i].r_start
&& (word)p < (word)GC_static_roots[i].r_end) {
- last_root_set = i;
- return GC_static_roots[i].r_tmp;
+ res = (int)GC_static_roots[i].r_tmp;
+ last_root_set = i;
+ break;
}
+ }
}
- return FALSE;
+ UNLOCK();
+ return res;
}
#endif /* !NO_DEBUGGING */