* dirent.c: Fix `struct dirent' overflow on Solaris. See #82678.
[mono.git] / libgc / pthread_stop_world.c
index 68f1dce4306dbd5be23b66c688b45cc8320a766c..1ed16132897ef4498bc890a2544c3912c58a7c92 100644 (file)
@@ -9,6 +9,18 @@
 #include <errno.h>
 #include <unistd.h>
 
+/* work around a dlopen issue (bug #75390), undefs to avoid warnings with redefinitions */
+#undef PACKAGE_BUGREPORT
+#undef PACKAGE_NAME
+#undef PACKAGE_STRING
+#undef PACKAGE_TARNAME
+#undef PACKAGE_VERSION
+#include "mono/utils/mono-compiler.h"
+
+#ifdef MONO_DEBUGGER_SUPPORTED
+#include "include/libgc-mono-debugger.h"
+#endif
+
 #if DEBUG_THREADS
 
 #ifndef NSIG
@@ -294,7 +306,7 @@ void GC_restart_handler(int sig)
 /* world is stopped.  Should not fail if it isn't.                     */
 void GC_push_all_stacks()
 {
-    gc_thread_vtable->push_all_stacks();
+    pthread_push_all_stacks();
 }
 
 /* There seems to be a very rare thread stopping problem.  To help us  */
@@ -353,7 +365,7 @@ static void pthread_stop_world()
     #if DEBUG_THREADS
     GC_printf1("Stopping the world from 0x%lx\n", pthread_self());
     #endif
-       
+
     n_live_threads = GC_suspend_all();
 
       if (GC_retry_signals) {
@@ -412,7 +424,12 @@ void GC_stop_world()
       /* We should have previously waited for it to become zero. */
 #   endif /* PARALLEL_MARK */
     ++GC_stop_count;
-    gc_thread_vtable->stop_world ();
+#ifdef MONO_DEBUGGER_SUPPORTED
+    if (gc_thread_vtable && gc_thread_vtable->stop_world)
+       gc_thread_vtable->stop_world ();
+    else
+#endif
+       pthread_stop_world ();
 #   ifdef PARALLEL_MARK
       GC_release_mark_lock();
 #   endif
@@ -478,7 +495,12 @@ static void pthread_start_world()
 
 void GC_start_world()
 {
-    gc_thread_vtable->start_world();
+#ifdef MONO_DEBUGGER_SUPPORTED
+    if (gc_thread_vtable && gc_thread_vtable->start_world)
+       gc_thread_vtable->start_world();
+    else
+#endif
+       pthread_start_world ();
 }
 
 static void pthread_stop_init() {
@@ -527,20 +549,27 @@ static void pthread_stop_init() {
 /* We hold the allocation lock.        */
 void GC_stop_init()
 {
-    gc_thread_vtable->initialize ();
+#ifdef MONO_DEBUGGER_SUPPORTED
+    if (gc_thread_vtable && gc_thread_vtable->initialize)
+       gc_thread_vtable->initialize ();
+    else
+#endif
+       pthread_stop_init ();
 }
 
-/*
- * This is used by the Mono Debugger to stop/start the world.
- */
-GCThreadFunctions pthread_thread_vtable = {
-    pthread_stop_init,
-    pthread_stop_world,
-    pthread_push_all_stacks,
-    pthread_start_world
-};
-
-GCThreadFunctions *gc_thread_vtable = &pthread_thread_vtable;
+#ifdef MONO_DEBUGGER_SUPPORTED
+
+GCThreadFunctions *gc_thread_vtable = NULL;
+
+void *
+GC_mono_debugger_get_stack_ptr (void)
+{
+       GC_thread me;
+
+       me = GC_lookup_thread (pthread_self ());
+       return &me->stop_info.stack_ptr;
+}
+
+#endif
 
 #endif