summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorivmai <ivmai>2011-03-20 11:31:14 +0100
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:56 +0200
commitad269687a9cb0d834eed41ad67c9c4acbad205c9 (patch)
treea0260f0f9cbd1b1e2b887acfc42ec4686c3ae644 /misc.c
parentc2dddb53a10205f986ae782e5b1e7105f0ea80c5 (diff)
2011-03-20 Ivan Maidanski <ivmai@mail.ru>
* blacklst.c (GC_bl_init_no_interiors): New function (the code moved from GC_bl_init). * blacklst.c (GC_bl_init): Invoke GC_bl_init_no_interiors unless GC_all_interior_pointers mode; remove unnecessarily parameter cast for GC_scratch_alloc call. * include/private/gc_priv.h (GC_bl_init): Move the function declaration to misc.c file. * misc.c (GC_bl_init_no_interiors): Add a prototype. * misc.c (GC_set_all_interior_pointers): Allow values other than 0 and 1; allow altering GC_set_all_interior_pointers value even after GC initialization. * obj_map.c (GC_initialize_offsets): Clear GC_valid_offsets and GC_modws_valid_offsets if GC_all_interior_pointers is off. * misc.c (GC_init): Don't call GC_initialize_offsets() unless GC_all_interior_pointers mode.
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/misc.c b/misc.c
index 75b92b0..a81b11c 100644
--- a/misc.c
+++ b/misc.c
@@ -631,6 +631,7 @@ STATIC void GC_exit_check(void)
#endif
GC_INNER void GC_initialize_offsets(void); /* defined in obj_map.c */
+GC_INNER void GC_bl_init(void); /* defined in blacklst.c */
GC_API void GC_CALL GC_init(void)
{
@@ -946,7 +947,8 @@ GC_API void GC_CALL GC_init(void)
GC_err_printf("Can't start up: not enough memory\n");
EXIT();
}
- GC_initialize_offsets();
+ if (GC_all_interior_pointers)
+ GC_initialize_offsets();
GC_register_displacement_inner(0L);
# if defined(GC_LINUX_THREADS) && defined(REDIRECT_MALLOC)
if (!GC_all_interior_pointers) {
@@ -1694,11 +1696,23 @@ GC_API int GC_CALL GC_get_find_leak(void)
return GC_find_leak;
}
+GC_INNER void GC_bl_init_no_interiors(void); /* defined in blacklst.c */
+
GC_API void GC_CALL GC_set_all_interior_pointers(int value)
{
- GC_ASSERT(!GC_is_initialized || value == GC_all_interior_pointers);
- GC_ASSERT(value == 0 || value == 1);
- GC_all_interior_pointers = value;
+ DCL_LOCK_STATE;
+
+ GC_all_interior_pointers = value ? 1 : 0;
+ if (GC_is_initialized) {
+ /* It is not recommended to change GC_all_interior_pointers value */
+ /* after GC is initialized but it seems GC could work correctly */
+ /* even after switching the mode. */
+ LOCK();
+ GC_initialize_offsets(); /* NOTE: this resets manual offsets as well */
+ if (!GC_all_interior_pointers)
+ GC_bl_init_no_interiors();
+ UNLOCK();
+ }
}
GC_API int GC_CALL GC_get_all_interior_pointers(void)