From 3c52d24037d597d668f287b4b04961b892f4ce9f Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Thu, 7 Jul 2016 19:31:50 +0200 Subject: [PATCH] [io-layer] Extract thread MonoW32HandleOps --- mono/io-layer/wthreads.c | 36 ------------------------------------ mono/utils/mono-threads-posix.c | 37 +++++++++++++++++++++++++++++++++++++ mono/utils/mono-threads-windows.c | 5 +++++ mono/utils/mono-threads.c | 1 + mono/utils/mono-threads.h | 2 ++ 5 files changed, 45 insertions(+), 36 deletions(-) diff --git a/mono/io-layer/wthreads.c b/mono/io-layer/wthreads.c index 845dccb44e3..1ecb121ecfe 100644 --- a/mono/io-layer/wthreads.c +++ b/mono/io-layer/wthreads.c @@ -38,45 +38,9 @@ #include #endif -static void thread_details (gpointer data); -static const gchar* thread_typename (void); -static gsize thread_typesize (void); - -static MonoW32HandleOps _wapi_thread_ops = { - NULL, /* close */ - NULL, /* signal */ - NULL, /* own */ - NULL, /* is_owned */ - NULL, /* special_wait */ - NULL, /* prewait */ - thread_details, /* details */ - thread_typename, /* typename */ - thread_typesize, /* typesize */ -}; - void _wapi_thread_init (void) { - mono_w32handle_register_ops (MONO_W32HANDLE_THREAD, &_wapi_thread_ops); - - mono_w32handle_register_capabilities (MONO_W32HANDLE_THREAD, MONO_W32HANDLE_CAP_WAIT); -} - -static void thread_details (gpointer data) -{ - MonoW32HandleThread *thread = (MonoW32HandleThread*) data; - g_print ("id: %p, owned_mutexes: %d, priority: %d", - thread->id, thread->owned_mutexes->len, thread->priority); -} - -static const gchar* thread_typename (void) -{ - return "Thread"; -} - -static gsize thread_typesize (void) -{ - return sizeof (MonoW32HandleThread); } void diff --git a/mono/utils/mono-threads-posix.c b/mono/utils/mono-threads-posix.c index 8c1c9430ff6..f10ef37e118 100644 --- a/mono/utils/mono-threads-posix.c +++ b/mono/utils/mono-threads-posix.c @@ -546,6 +546,43 @@ mono_threads_platform_set_priority (MonoThreadInfo *info, MonoThreadPriority pri } +static void thread_details (gpointer data) +{ + MonoW32HandleThread *thread = (MonoW32HandleThread*) data; + g_print ("id: %p, owned_mutexes: %d, priority: %d", + thread->id, thread->owned_mutexes->len, thread->priority); +} + +static const gchar* thread_typename (void) +{ + return "Thread"; +} + +static gsize thread_typesize (void) +{ + return sizeof (MonoW32HandleThread); +} + +static MonoW32HandleOps thread_ops = { + NULL, /* close */ + NULL, /* signal */ + NULL, /* own */ + NULL, /* is_owned */ + NULL, /* special_wait */ + NULL, /* prewait */ + thread_details, /* details */ + thread_typename, /* typename */ + thread_typesize, /* typesize */ +}; + +void +mono_threads_platform_init (void) +{ + mono_w32handle_register_ops (MONO_W32HANDLE_THREAD, &thread_ops); + + mono_w32handle_register_capabilities (MONO_W32HANDLE_THREAD, MONO_W32HANDLE_CAP_WAIT); +} + #endif /* defined(_POSIX_VERSION) || defined(__native_client__) */ #if defined(USE_POSIX_BACKEND) diff --git a/mono/utils/mono-threads-windows.c b/mono/utils/mono-threads-windows.c index 84321d653c2..499aa2fb276 100644 --- a/mono/utils/mono-threads-windows.c +++ b/mono/utils/mono-threads-windows.c @@ -397,4 +397,9 @@ mono_threads_platform_set_priority (MonoThreadInfo *info, MonoThreadPriority pri return SetThreadPriority (info->handle, priority - 2); } +void +mono_threads_platform_init (void) +{ +} + #endif diff --git a/mono/utils/mono-threads.c b/mono/utils/mono-threads.c index 15b06b6d2b3..5b0b6d030f3 100644 --- a/mono/utils/mono-threads.c +++ b/mono/utils/mono-threads.c @@ -676,6 +676,7 @@ mono_threads_init (MonoThreadInfoCallbacks *callbacks, size_t info_size) mono_lls_init (&thread_list, NULL, HAZARD_FREE_NO_LOCK); mono_thread_smr_init (); + mono_threads_platform_init (); mono_threads_suspend_init (); mono_threads_coop_init (); mono_threads_abort_syscall_init (); diff --git a/mono/utils/mono-threads.h b/mono/utils/mono-threads.h index 375a808172c..38547b7e0a9 100644 --- a/mono/utils/mono-threads.h +++ b/mono/utils/mono-threads.h @@ -493,6 +493,8 @@ This is called very early in the runtime, it cannot access any runtime facilitie */ void mono_threads_suspend_init (void); //ok +void mono_threads_platform_init (void); + void mono_threads_coop_init (void); void mono_threads_abort_syscall_init (void); -- 2.11.4.GIT