[threads] Store MonoInternalThread in MonoThreadInfo for use when detaching (#5058)
[mono.git] / mono / metadata / boehm-gc.c
index 4ad522d4dc3bdb39ef7ed0b8728d76960ddc9618..acbd4eae4b0735bdaef0564e5f2225c780bddddf 100644 (file)
@@ -56,12 +56,6 @@ void *pthread_get_stackaddr_np(pthread_t);
 static gboolean gc_initialized = FALSE;
 static mono_mutex_t mono_gc_lock;
 
-static void*
-boehm_thread_attach (MonoThreadInfo* info);
-static void
-boehm_thread_detach_with_lock (MonoThreadInfo *p);
-static void
-boehm_thread_detach (MonoThreadInfo *p);
 static void
 register_test_toggleref_callback (void);
 
@@ -108,7 +102,6 @@ static void on_gc_heap_resize (size_t new_size);
 void
 mono_gc_base_init (void)
 {
-       MonoThreadInfoCallbacks cb;
        const char *env;
 
        if (gc_initialized)
@@ -237,13 +230,8 @@ mono_gc_base_init (void)
                g_strfreev (opts);
        }
 
-       memset (&cb, 0, sizeof (cb));
-       cb.thread_attach = boehm_thread_attach;
-       cb.thread_detach = boehm_thread_detach;
-       cb.thread_detach_with_lock = boehm_thread_detach_with_lock;
-       cb.mono_method_is_critical = (gboolean (*)(void *))mono_runtime_is_critical_method;
-
-       mono_threads_init (&cb, sizeof (MonoThreadInfo));
+       mono_thread_callbacks_init ();
+       mono_thread_info_init (sizeof (MonoThreadInfo));
        mono_os_mutex_init (&mono_gc_lock);
        mono_os_mutex_init_recursive (&handle_section);
 
@@ -375,8 +363,8 @@ mono_gc_is_gc_thread (void)
        return GC_thread_is_registered ();
 }
 
-static void*
-boehm_thread_attach (MonoThreadInfo* info)
+gpointer
+mono_gc_thread_attach (MonoThreadInfo* info)
 {
        struct GC_stack_base sb;
        int res;
@@ -392,8 +380,8 @@ boehm_thread_attach (MonoThreadInfo* info)
        return info;
 }
 
-static void
-boehm_thread_detach_with_lock (MonoThreadInfo *p)
+void
+mono_gc_thread_detach_with_lock (MonoThreadInfo *p)
 {
        MonoNativeThreadId tid;
 
@@ -405,11 +393,10 @@ boehm_thread_detach_with_lock (MonoThreadInfo *p)
        mono_handle_stack_free (p->handle_stack);
 }
 
-static void
-boehm_thread_detach (MonoThreadInfo *p)
+gboolean
+mono_gc_thread_in_critical_region (MonoThreadInfo *info)
 {
-       if (mono_thread_internal_current_is_attached ())
-               mono_thread_detach_internal (mono_thread_internal_current ());
+       return FALSE;
 }
 
 gboolean