[mono] Add some strong types for a few variables, document some methods (#3777)
[mono.git] / mono / metadata / threads.c
index 61c69e0ba92819f02eb87b6e18e6021cecbc63fd..2ae43aab0ae3be675b979e4cb5756fc1d6ed169a 100644 (file)
 #include <signal.h>
 #endif
 
+#if defined(HOST_WIN32)
+#include <objbase.h>
+#endif
+
 #if defined(PLATFORM_ANDROID) && !defined(TARGET_ARM64) && !defined(TARGET_AMD64)
 #define USE_TKILL_ON_ANDROID 1
 #endif
@@ -906,6 +910,7 @@ create_thread (MonoThread *thread, MonoInternalThread *internal, MonoObject *sta
        HANDLE thread_handle;
        MonoNativeThreadId tid;
        gboolean ret;
+       gsize stack_set_size;
 
        if (start_delegate)
                g_assert (!start_func && !start_func_arg);
@@ -947,9 +952,11 @@ create_thread (MonoThread *thread, MonoInternalThread *internal, MonoObject *sta
        mono_coop_sem_init (&start_info->registered, 0);
 
        if (stack_size == 0)
-               stack_size = default_stacksize_for_thread (internal);
+               stack_set_size = default_stacksize_for_thread (internal);
+       else
+               stack_set_size = 0;
 
-       thread_handle = mono_threads_create_thread (start_wrapper, start_info, stack_size, &tid);
+       thread_handle = mono_threads_create_thread (start_wrapper, start_info, &stack_set_size, &tid);
 
        if (thread_handle == NULL) {
                /* The thread couldn't be created, so set an exception */
@@ -963,6 +970,8 @@ create_thread (MonoThread *thread, MonoInternalThread *internal, MonoObject *sta
                goto done;
        }
 
+       internal->stack_size = (int) stack_set_size;
+
        THREAD_DEBUG (g_message ("%s: (%"G_GSIZE_FORMAT") Launching thread %p (%"G_GSIZE_FORMAT")", __func__, mono_native_thread_id_get (), internal, (gsize)internal->tid));
 
        /*
@@ -4917,7 +4926,7 @@ mono_threads_join_threads (void)
                        if (thread != pthread_self ()) {
                                MONO_ENTER_GC_SAFE;
                                /* This shouldn't block */
-                               pthread_join (thread, NULL);
+                               mono_native_thread_join (thread);
                                MONO_EXIT_GC_SAFE;
                        }
                } else {
@@ -4953,7 +4962,7 @@ mono_thread_join (gpointer tid)
                return;
        thread = (pthread_t)tid;
        MONO_ENTER_GC_SAFE;
-       pthread_join (thread, NULL);
+       mono_native_thread_join (thread);
        MONO_EXIT_GC_SAFE;
 #endif
 }
@@ -5121,6 +5130,7 @@ mono_thread_try_resume_interruption (void)
        return mono_thread_resume_interruption ();
 }
 
+#if 0
 /* Returns TRUE if the current thread is ready to be interrupted. */
 gboolean
 mono_threads_is_ready_to_be_interrupted (void)
@@ -5142,6 +5152,7 @@ mono_threads_is_ready_to_be_interrupted (void)
        UNLOCK_THREAD (thread);
        return TRUE;
 }
+#endif
 
 void
 mono_thread_internal_describe (MonoInternalThread *internal, GString *text)