Merge pull request #1840 from ludovic-henry/iolayer-thread-interrupt
[mono.git] / mono / utils / mono-threads-posix.c
index b74bf6448705c17ba613ecc7cd151ffe9c8ea52c..b2e4bd37bcc93a8ec42eb3e9a6f844ecf36e353e 100644 (file)
@@ -20,6 +20,7 @@
 #include <mono/utils/mono-tls.h>
 #include <mono/utils/mono-mmap.h>
 #include <mono/metadata/threads-types.h>
+#include <mono/metadata/gc-internal.h>
 #include <limits.h>
 
 #include <errno.h>
@@ -95,22 +96,8 @@ inner_start_thread (void *arg)
        /* Run the actual main function of the thread */
        result = start_func (t_arg);
 
-       /*
-       mono_thread_info_detach ();
-       */
-
-#if defined(__native_client__)
-       nacl_shutdown_gc_thread();
-#endif
-
-       wapi_thread_handle_set_exited (handle, GPOINTER_TO_UINT (result));
-       /* This is needed by mono_threads_core_unregister () which is called later */
-       info->handle = NULL;
-
-       g_assert (mono_threads_get_callbacks ()->thread_exit);
-       mono_threads_get_callbacks ()->thread_exit (NULL);
+       mono_threads_core_exit (GPOINTER_TO_UINT (result));
        g_assert_not_reached ();
-       return result;
 }
 
 HANDLE
@@ -152,7 +139,7 @@ mono_threads_core_create_thread (LPTHREAD_START_ROUTINE start_routine, gpointer
        MONO_SEM_INIT (&(start_info.registered), 0);
 
        /* Actually start the thread */
-       res = mono_threads_get_callbacks ()->mono_gc_pthread_create (&thread, &attr, inner_start_thread, &start_info);
+       res = mono_gc_pthread_create (&thread, &attr, inner_start_thread, &start_info);
        if (res) {
                MONO_SEM_DESTROY (&(start_info.registered));
                return NULL;
@@ -198,8 +185,9 @@ mono_threads_core_exit (int exit_code)
 
        wapi_thread_handle_set_exited (current->handle, exit_code);
 
-       g_assert (mono_threads_get_callbacks ()->thread_exit);
-       mono_threads_get_callbacks ()->thread_exit (NULL);
+       mono_thread_info_detach ();
+
+       pthread_exit (NULL);
 }
 
 void
@@ -248,30 +236,6 @@ mono_threads_core_open_thread_handle (HANDLE handle, MonoNativeThreadId tid)
        return handle;
 }
 
-gpointer
-mono_threads_core_prepare_interrupt (HANDLE thread_handle)
-{
-       return wapi_prepare_interrupt_thread (thread_handle);
-}
-
-void
-mono_threads_core_finish_interrupt (gpointer wait_handle)
-{
-       wapi_finish_interrupt_thread (wait_handle);
-}
-
-void
-mono_threads_core_self_interrupt (void)
-{
-       wapi_self_interrupt ();
-}
-
-void
-mono_threads_core_clear_interruption (void)
-{
-       wapi_clear_interruption ();
-}
-
 int
 mono_threads_pthread_kill (MonoThreadInfo *info, int signum)
 {
@@ -287,6 +251,8 @@ mono_threads_pthread_kill (MonoThreadInfo *info, int signum)
 #elif defined(__native_client__)
        /* Workaround pthread_kill abort() in NaCl glibc. */
        return 0;
+#elif !defined(HAVE_PTHREAD_KILL)
+       g_error ("pthread_kill() is not supported by this platform");
 #else
        return pthread_kill (mono_thread_info_get_tid (info), signum);
 #endif