aboutsummaryrefslogtreecommitdiff
path: root/libjava/boehm.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/boehm.cc')
-rw-r--r--libjava/boehm.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/libjava/boehm.cc b/libjava/boehm.cc
index 36b544863b1..ba60ba0b6aa 100644
--- a/libjava/boehm.cc
+++ b/libjava/boehm.cc
@@ -69,6 +69,9 @@ static ptr_t *obj_free_list;
// Freelist used for Java arrays.
static ptr_t *array_free_list;
+// Lock used to protect access to Boehm's GC_enable/GC_disable functions.
+static _Jv_Mutex_t disable_gc_mutex;
+
// This is called by the GC during the mark phase. It marks a Java
@@ -391,6 +394,26 @@ _Jv_GCSetMaximumHeapSize (size_t size)
GC_set_max_heap_size ((GC_word) size);
}
+// From boehm's misc.c
+extern "C" void GC_enable();
+extern "C" void GC_disable();
+
+void
+_Jv_DisableGC (void)
+{
+ _Jv_MutexLock (&disable_gc_mutex);
+ GC_disable();
+ _Jv_MutexUnlock (&disable_gc_mutex);
+}
+
+void
+_Jv_EnableGC (void)
+{
+ _Jv_MutexLock (&disable_gc_mutex);
+ GC_enable();
+ _Jv_MutexUnlock (&disable_gc_mutex);
+}
+
void
_Jv_InitGC (void)
{
@@ -443,6 +466,8 @@ _Jv_InitGC (void)
GC_obj_kinds[array_kind_x].ok_relocate_descr = FALSE;
GC_obj_kinds[array_kind_x].ok_init = TRUE;
+ _Jv_MutexInit (&disable_gc_mutex);
+
UNLOCK ();
ENABLE_SIGNALS ();
}