From d19e5eaeae3fa7394ca4803e8b319ca8baa47a41 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Thu, 7 Jul 2016 14:25:35 +0200 Subject: [PATCH] [io-layer] Make _wapi_getpid, _wapi_thread_own_mutex, _wapi_thread_disown_mutex and _wapi_mutex_abandon functions public --- mono/io-layer/io.c | 2 +- mono/io-layer/mutex-private.h | 2 -- mono/io-layer/mutexes.c | 6 +++--- mono/io-layer/mutexes.h | 5 +++++ mono/io-layer/processes.c | 4 ++-- mono/io-layer/thread-private.h | 2 -- mono/io-layer/threads.h | 6 ++++++ mono/io-layer/wapi-private.h | 3 --- mono/io-layer/wapi.c | 2 +- mono/io-layer/wapi.h | 3 +++ mono/io-layer/wthreads.c | 10 +++++----- 11 files changed, 26 insertions(+), 19 deletions(-) diff --git a/mono/io-layer/io.c b/mono/io-layer/io.c index 50ed3496b0c..2fc21d2a94e 100644 --- a/mono/io-layer/io.c +++ b/mono/io-layer/io.c @@ -139,7 +139,7 @@ _wapi_handle_get_or_set_share (guint64 device, guint64 inode, guint32 new_sharem file_share->device = device; file_share->inode = inode; - file_share->opened_by_pid = _wapi_getpid (); + file_share->opened_by_pid = wapi_getpid (); file_share->sharemode = new_sharemode; file_share->access = new_access; file_share->handle_refs = 1; diff --git a/mono/io-layer/mutex-private.h b/mono/io-layer/mutex-private.h index 74dbb841224..50e5b14e063 100644 --- a/mono/io-layer/mutex-private.h +++ b/mono/io-layer/mutex-private.h @@ -32,6 +32,4 @@ struct _WapiHandle_namedmutex void _wapi_mutex_init (void); -extern void _wapi_mutex_abandon (gpointer data, pid_t pid, pthread_t tid); - #endif /* _WAPI_MUTEX_PRIVATE_H_ */ diff --git a/mono/io-layer/mutexes.c b/mono/io-layer/mutexes.c index 0bddd29ed0f..11bff3d7f05 100644 --- a/mono/io-layer/mutexes.c +++ b/mono/io-layer/mutexes.c @@ -96,7 +96,7 @@ mutex_handle_own (gpointer handle, MonoW32HandleType type) MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: owning %s handle %p, tid %p, recursion %u", __func__, mutex_handle_type_to_string (type), handle, (gpointer) mutex_handle->tid, mutex_handle->recursion); - _wapi_thread_own_mutex (handle); + wapi_thread_own_mutex (handle); mutex_handle->tid = pthread_self (); mutex_handle->recursion++; @@ -239,7 +239,7 @@ static gsize namedmutex_typesize (void) } /* When a thread exits, any mutexes it still holds need to be signalled. */ -void _wapi_mutex_abandon (gpointer handle, pid_t pid, pthread_t tid) +void wapi_mutex_abandon (gpointer handle, pid_t pid, pthread_t tid) { MonoW32HandleType type; struct _WapiHandle_mutex *mutex_handle; @@ -450,7 +450,7 @@ gboolean ReleaseMutex(gpointer handle) mutex_handle->recursion--; if (mutex_handle->recursion == 0) { - _wapi_thread_disown_mutex (handle); + wapi_thread_disown_mutex (handle); MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unlocking %s handle %p", __func__, mutex_handle_type_to_string (type), handle); diff --git a/mono/io-layer/mutexes.h b/mono/io-layer/mutexes.h index ef9e46d9e94..d1b7a68d67c 100644 --- a/mono/io-layer/mutexes.h +++ b/mono/io-layer/mutexes.h @@ -12,6 +12,8 @@ #include +#include + G_BEGIN_DECLS extern gpointer CreateMutex (WapiSecurityAttributes *security, gboolean owned, @@ -20,6 +22,9 @@ extern gboolean ReleaseMutex (gpointer handle); extern gpointer OpenMutex (guint32 access, gboolean inherit, const gunichar2 *name); +void +wapi_mutex_abandon (gpointer data, pid_t pid, pthread_t tid); + G_END_DECLS #endif /* _WAPI_MUTEXES_H_ */ diff --git a/mono/io-layer/processes.c b/mono/io-layer/processes.c index 7eff27e35f4..af9fc5da8ce 100644 --- a/mono/io-layer/processes.c +++ b/mono/io-layer/processes.c @@ -1132,7 +1132,7 @@ process_set_name (WapiHandle_process *process_handle) void _wapi_processes_init (void) { - pid_t pid = _wapi_getpid (); + pid_t pid = wapi_getpid (); WapiHandle_process process_handle = {0}; mono_w32handle_register_ops (MONO_W32HANDLE_PROCESS, &_wapi_process_ops); @@ -1294,7 +1294,7 @@ GetExitCodeProcess (gpointer process, guint32 *code) return FALSE; } - if (process_handle->id == _wapi_getpid ()) { + if (process_handle->id == wapi_getpid ()) { *code = STILL_ACTIVE; return TRUE; } diff --git a/mono/io-layer/thread-private.h b/mono/io-layer/thread-private.h index c50e53271a9..0f124656583 100644 --- a/mono/io-layer/thread-private.h +++ b/mono/io-layer/thread-private.h @@ -23,8 +23,6 @@ void _wapi_thread_init (void); extern gboolean _wapi_thread_cur_apc_pending (void); -extern void _wapi_thread_own_mutex (gpointer mutex); -extern void _wapi_thread_disown_mutex (gpointer mutex); extern void _wapi_thread_cleanup (void); #endif /* _WAPI_THREAD_PRIVATE_H_ */ diff --git a/mono/io-layer/threads.h b/mono/io-layer/threads.h index 5ba122b86fe..637aa70f391 100644 --- a/mono/io-layer/threads.h +++ b/mono/io-layer/threads.h @@ -54,5 +54,11 @@ extern gboolean SetThreadPriority (gpointer handle, gint32 priority); extern int wapi_thread_priority_to_posix_priority (WapiThreadPriority, int); extern void wapi_init_thread_info_priority (gpointer, gint32); +void +wapi_thread_own_mutex (gpointer mutex); + +void +wapi_thread_disown_mutex (gpointer mutex); + G_END_DECLS #endif /* _WAPI_THREADS_H_ */ diff --git a/mono/io-layer/wapi-private.h b/mono/io-layer/wapi-private.h index 8d3617f1f3e..060135abf2a 100644 --- a/mono/io-layer/wapi-private.h +++ b/mono/io-layer/wapi-private.h @@ -67,9 +67,6 @@ struct _WapiFileShare typedef struct _WapiFileShare _WapiFileShare; -pid_t -_wapi_getpid (void); - gpointer _wapi_search_handle_namespace (MonoW32HandleType type, gchar *utf8_name); diff --git a/mono/io-layer/wapi.c b/mono/io-layer/wapi.c index 81e6f6ff027..5ab47ac9bc6 100644 --- a/mono/io-layer/wapi.c +++ b/mono/io-layer/wapi.c @@ -48,7 +48,7 @@ _wapi_pid_init (void) } pid_t -_wapi_getpid (void) +wapi_getpid (void) { mono_lazy_initialize (&_wapi_pid_init_lazy, _wapi_pid_init); return _wapi_pid; diff --git a/mono/io-layer/wapi.h b/mono/io-layer/wapi.h index 85da1991103..e0d4d48c09f 100644 --- a/mono/io-layer/wapi.h +++ b/mono/io-layer/wapi.h @@ -43,4 +43,7 @@ gboolean DuplicateHandle (gpointer srcprocess, gpointer src, gpointer targetprocess, gpointer *target, guint32 access G_GNUC_UNUSED, gboolean inherit G_GNUC_UNUSED, guint32 options G_GNUC_UNUSED); +pid_t +wapi_getpid (void); + #endif /* _WAPI_WAPI_H_ */ diff --git a/mono/io-layer/wthreads.c b/mono/io-layer/wthreads.c index 503fb033d90..9c4e7fe3e58 100644 --- a/mono/io-layer/wthreads.c +++ b/mono/io-layer/wthreads.c @@ -121,7 +121,7 @@ wapi_thread_handle_set_exited (gpointer handle, guint32 exitstatus) { MonoW32HandleThread *thread_handle; int i, thr_ret; - pid_t pid = _wapi_getpid (); + pid_t pid = wapi_getpid (); pthread_t tid = pthread_self (); if (mono_w32handle_issignalled (handle) || @@ -141,8 +141,8 @@ wapi_thread_handle_set_exited (gpointer handle, guint32 exitstatus) for (i = 0; i < thread_handle->owned_mutexes->len; i++) { gpointer mutex = g_ptr_array_index (thread_handle->owned_mutexes, i); - _wapi_mutex_abandon (mutex, pid, tid); - _wapi_thread_disown_mutex (mutex); + wapi_mutex_abandon (mutex, pid, tid); + wapi_thread_disown_mutex (mutex); } g_ptr_array_free (thread_handle->owned_mutexes, TRUE); @@ -216,7 +216,7 @@ _wapi_thread_cur_apc_pending (void) } void -_wapi_thread_own_mutex (gpointer mutex) +wapi_thread_own_mutex (gpointer mutex) { MonoW32HandleThread *thread; @@ -228,7 +228,7 @@ _wapi_thread_own_mutex (gpointer mutex) } void -_wapi_thread_disown_mutex (gpointer mutex) +wapi_thread_disown_mutex (gpointer mutex) { MonoW32HandleThread *thread; -- 2.25.1