[runtime] Use the mono_mutex types/functions instead of CriticalSection's.
authorZoltan Varga <vargaz@gmail.com>
Tue, 5 Aug 2014 21:36:06 +0000 (23:36 +0200)
committerZoltan Varga <vargaz@gmail.com>
Tue, 5 Aug 2014 21:36:06 +0000 (23:36 +0200)
45 files changed:
mono/interpreter/interp.c
mono/interpreter/transform.c
mono/io-layer/handles.c
mono/io-layer/io.c [changed mode: 0755->0644]
mono/metadata/appdomain.c
mono/metadata/assembly.c
mono/metadata/attach.c
mono/metadata/class.c
mono/metadata/cominterop.c
mono/metadata/domain-internals.h
mono/metadata/domain.c
mono/metadata/gc-internal.h
mono/metadata/gc.c
mono/metadata/icall.c
mono/metadata/image.c
mono/metadata/loader.c
mono/metadata/lock-tracer.c
mono/metadata/lock-tracer.h
mono/metadata/marshal.c
mono/metadata/mempool-internals.h [changed mode: 0755->0644]
mono/metadata/mempool.c
mono/metadata/metadata-internals.h
mono/metadata/metadata.c
mono/metadata/monitor.c
mono/metadata/mono-debug-debugger.c
mono/metadata/mono-perfcounters.c
mono/metadata/object-internals.h
mono/metadata/object.c
mono/metadata/process.c [changed mode: 0755->0644]
mono/metadata/profiler.c
mono/metadata/reflection-internals.h
mono/metadata/sgen-archdep.h [changed mode: 0755->0644]
mono/metadata/sgen-marksweep.c [changed mode: 0755->0644]
mono/metadata/sgen-os-win32.c [changed mode: 0755->0644]
mono/metadata/sgen-qsort.h
mono/metadata/sgen-stw.c [changed mode: 0755->0644]
mono/metadata/threadpool.c
mono/metadata/threads.c [changed mode: 0755->0644]
mono/metadata/tpool-epoll.c
mono/metadata/tpool-kqueue.c
mono/metadata/tpool-poll.c
mono/mini/mini.c
mono/utils/atomic.c [changed mode: 0755->0644]
mono/utils/hazard-pointer.c
mono/utils/mono-codeman.c

index bab4d6fb48c84d4a0685fd2942479155c9547019..4525ff69ab35c533d92938550de86dddec4ed887 100644 (file)
@@ -254,7 +254,7 @@ interp_create_remoting_trampoline (MonoMethod *method, MonoRemotingTarget target
        return mono_interp_get_runtime_method (mono_marshal_get_remoting_invoke_for_target (method, target));
 }
 
-static CRITICAL_SECTION runtime_method_lookup_section;
+static mono_mutex_t runtime_method_lookup_section;
 
 RuntimeMethod*
 mono_interp_get_runtime_method (MonoMethod *method)
@@ -262,9 +262,9 @@ mono_interp_get_runtime_method (MonoMethod *method)
        MonoDomain *domain = mono_domain_get ();
        RuntimeMethod *rtm;
 
-       EnterCriticalSection (&runtime_method_lookup_section);
+       mono_mutex_lock (&runtime_method_lookup_section);
        if ((rtm = mono_internal_hash_table_lookup (&domain->jit_code_hash, method))) {
-               LeaveCriticalSection (&runtime_method_lookup_section);
+               mono_mutex_unlock (&runtime_method_lookup_section);
                return rtm;
        }
        rtm = mono_mempool_alloc (domain->mp, sizeof (RuntimeMethod));
@@ -274,7 +274,7 @@ mono_interp_get_runtime_method (MonoMethod *method)
        rtm->hasthis = mono_method_signature (method)->hasthis;
        rtm->valuetype = method->klass->valuetype;
        mono_internal_hash_table_insert (&domain->jit_code_hash, method, rtm);
-       LeaveCriticalSection (&runtime_method_lookup_section);
+       mono_mutex_unlock (&runtime_method_lookup_section);
 
        return rtm;
 }
@@ -1301,7 +1301,7 @@ do_icall (ThreadContext *context, int op, stackval *sp, gpointer ptr)
        return sp;
 }
 
-static CRITICAL_SECTION create_method_pointer_mutex;
+static mono_mutex_t create_method_pointer_mutex;
 
 static MonoGHashTable *method_pointer_hash = NULL;
 
@@ -1311,14 +1311,14 @@ mono_create_method_pointer (MonoMethod *method)
        gpointer addr;
        MonoJitInfo *ji;
 
-       EnterCriticalSection (&create_method_pointer_mutex);
+       mono_mutex_lock (&create_method_pointer_mutex);
        if (!method_pointer_hash) {
                MONO_GC_REGISTER_ROOT (method_pointer_hash);
                method_pointer_hash = mono_g_hash_table_new (NULL, NULL);
        }
        addr = mono_g_hash_table_lookup (method_pointer_hash, method);
        if (addr) {
-               LeaveCriticalSection (&create_method_pointer_mutex);
+               mono_mutex_unlock (&create_method_pointer_mutex);
                return addr;
        }
 
@@ -1338,7 +1338,7 @@ mono_create_method_pointer (MonoMethod *method)
                addr = mono_arch_create_method_pointer (method);
 
        mono_g_hash_table_insert (method_pointer_hash, method, addr);
-       LeaveCriticalSection (&create_method_pointer_mutex);
+       mono_mutex_unlock (&create_method_pointer_mutex);
 
        return addr;
 }
@@ -4394,8 +4394,8 @@ mono_interp_init(const char *file)
 
        thread_context_id = TlsAlloc ();
        TlsSetValue (thread_context_id, NULL);
-       InitializeCriticalSection (&runtime_method_lookup_section);
-       InitializeCriticalSection (&create_method_pointer_mutex);
+       mono_mutex_init_recursive (&runtime_method_lookup_section);
+       mono_mutex_init_recursive (&create_method_pointer_mutex);
 
        mono_runtime_install_handlers ();
        mono_interp_transform_init ();
index b47e594ef4959764748f33a6cc370aaaae7b55a9..2bd3f258183bffb4e3183669efe8f89c346c44af 100644 (file)
@@ -2791,12 +2791,12 @@ generate(MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start)
        g_hash_table_destroy (td.data_hash);
 }
 
-static CRITICAL_SECTION calc_section;
+static mono_mutex_t calc_section;
 
 void 
 mono_interp_transform_init (void)
 {
-       InitializeCriticalSection(&calc_section);
+       mono_mutex_init_recursive(&calc_section);
 }
 
 MonoException *
@@ -2845,9 +2845,9 @@ mono_interp_transform_method (RuntimeMethod *runtime_method, ThreadContext *cont
 
        if (method->iflags & (METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL | METHOD_IMPL_ATTRIBUTE_RUNTIME)) {
                MonoMethod *nm = NULL;
-               EnterCriticalSection(&calc_section);
+               mono_mutex_lock(&calc_section);
                if (runtime_method->transformed) {
-                       LeaveCriticalSection(&calc_section);
+                       mono_mutex_unlock(&calc_section);
                        mono_profiler_method_end_jit (method, MONO_PROFILE_OK);
                        return NULL;
                }
@@ -2880,13 +2880,13 @@ mono_interp_transform_method (RuntimeMethod *runtime_method, ThreadContext *cont
                        runtime_method->stack_size = sizeof (stackval); /* for tracing */
                        runtime_method->alloca_size = runtime_method->stack_size;
                        runtime_method->transformed = TRUE;
-                       LeaveCriticalSection(&calc_section);
+                       mono_mutex_unlock(&calc_section);
                        mono_profiler_method_end_jit (method, MONO_PROFILE_OK);
                        return NULL;
                }
                method = nm;
                header = mono_method_get_header (nm);
-               LeaveCriticalSection(&calc_section);
+               mono_mutex_unlock(&calc_section);
        }
        g_assert ((signature->param_count + signature->hasthis) < 1000);
        g_assert (header->max_stack < 10000);
@@ -2996,9 +2996,9 @@ mono_interp_transform_method (RuntimeMethod *runtime_method, ThreadContext *cont
        }
 
        /* the rest needs to be locked so it is only done once */
-       EnterCriticalSection(&calc_section);
+       mono_mutex_lock(&calc_section);
        if (runtime_method->transformed) {
-               LeaveCriticalSection(&calc_section);
+               mono_mutex_unlock(&calc_section);
                g_free (is_bb_start);
                mono_profiler_method_end_jit (method, MONO_PROFILE_OK);
                return NULL;
@@ -3042,7 +3042,7 @@ mono_interp_transform_method (RuntimeMethod *runtime_method, ThreadContext *cont
 
        mono_profiler_method_end_jit (method, MONO_PROFILE_OK);
        runtime_method->transformed = TRUE;
-       LeaveCriticalSection(&calc_section);
+       mono_mutex_unlock(&calc_section);
 
        return NULL;
 }
index 146c275cb5de7ba3198e16624933bd8b0398d963..32e2e33568d6d6620a405b9737b3022f267a0f6b 100644 (file)
@@ -131,10 +131,10 @@ struct _WapiFileShareLayout *_wapi_fileshare_layout = NULL;
  * 4MB array.
  */
 static GHashTable *file_share_hash;
-static CRITICAL_SECTION file_share_hash_mutex;
+static mono_mutex_t file_share_hash_mutex;
 
-#define file_share_hash_lock() EnterCriticalSection (&file_share_hash_mutex)
-#define file_share_hash_unlock() LeaveCriticalSection (&file_share_hash_mutex)
+#define file_share_hash_lock() mono_mutex_lock (&file_share_hash_mutex)
+#define file_share_hash_unlock() mono_mutex_unlock (&file_share_hash_mutex)
 
 guint32 _wapi_fd_reserve;
 
@@ -207,7 +207,7 @@ static void handle_cleanup (void)
 
        if (file_share_hash) {
                g_hash_table_destroy (file_share_hash);
-               DeleteCriticalSection (&file_share_hash_mutex);
+               mono_mutex_destroy (&file_share_hash_mutex);
        }
 
        for (i = 0; i < _WAPI_PRIVATE_MAX_SLOTS; ++i)
@@ -1664,7 +1664,7 @@ gboolean _wapi_handle_get_or_set_share (dev_t device, ino_t inode,
                 */
                if (!file_share_hash) {
                        file_share_hash = g_hash_table_new_full (wapi_share_info_hash, wapi_share_info_equal, NULL, g_free);
-                       InitializeCriticalSection (&file_share_hash_mutex);
+                       mono_mutex_init_recursive (&file_share_hash_mutex);
                }
                        
                tmp.device = device;
old mode 100755 (executable)
new mode 100644 (file)
index 1f0a4f59d7279e1e06228bb7849d1a2b75922db3..45b9a606ab6ff7ed8e719e52af416ddffd417694 100644 (file)
@@ -88,9 +88,9 @@ typedef struct
        gchar *filename;
 } RuntimeConfig;
 
-CRITICAL_SECTION mono_delegate_section;
+mono_mutex_t mono_delegate_section;
 
-CRITICAL_SECTION mono_strtod_mutex;
+mono_mutex_t mono_strtod_mutex;
 
 static gunichar2 process_guid [36];
 static gboolean process_guid_set = FALSE;
@@ -250,9 +250,9 @@ mono_runtime_init (MonoDomain *domain, MonoThreadStartCB start_cb,
        domain->domain = ad;
        domain->setup = setup;
 
-       InitializeCriticalSection (&mono_delegate_section);
+       mono_mutex_init_recursive (&mono_delegate_section);
 
-       InitializeCriticalSection (&mono_strtod_mutex);
+       mono_mutex_init_recursive (&mono_strtod_mutex);
        
        mono_thread_attach (domain);
        mono_context_init (domain);
index a4988a82432266b992b05b4d1064d5b2f081f9c8..afda4dd45fa155abd72e344680223a653016a655 100644 (file)
@@ -170,9 +170,9 @@ mono_set_corlib_data (void *data, size_t size)
 #endif
 
 /* This protects loaded_assemblies and image->references */
-#define mono_assemblies_lock() EnterCriticalSection (&assemblies_mutex)
-#define mono_assemblies_unlock() LeaveCriticalSection (&assemblies_mutex)
-static CRITICAL_SECTION assemblies_mutex;
+#define mono_assemblies_lock() mono_mutex_lock (&assemblies_mutex)
+#define mono_assemblies_unlock() mono_mutex_unlock (&assemblies_mutex)
+static mono_mutex_t assemblies_mutex;
 
 /* If defined, points to the bundled assembly information */
 const MonoBundledAssembly **bundles;
@@ -739,7 +739,7 @@ mono_assemblies_init (void)
        check_path_env ();
        check_extra_gac_path_env ();
 
-       InitializeCriticalSection (&assemblies_mutex);
+       mono_mutex_init_recursive (&assemblies_mutex);
        mono_mutex_init (&assembly_binding_mutex);
 }
 
@@ -3142,7 +3142,7 @@ mono_assemblies_cleanup (void)
 {
        GSList *l;
 
-       DeleteCriticalSection (&assemblies_mutex);
+       mono_mutex_destroy (&assemblies_mutex);
        mono_mutex_destroy (&assembly_binding_mutex);
 
        for (l = loaded_assembly_bindings; l; l = l->next) {
index 83b06dc6ff99249d68be869f85df6cff191e8085..0a053661b8e411892419e95a41ffa1bb3be6a0c0 100644 (file)
@@ -99,9 +99,9 @@ static gboolean stop_receiver_thread;
 
 static gboolean needs_to_start, started;
 
-#define agent_lock() EnterCriticalSection (&agent_mutex)
-#define agent_unlock() LeaveCriticalSection (&agent_mutex)
-static CRITICAL_SECTION agent_mutex;
+#define agent_lock() mono_mutex_lock (&agent_mutex)
+#define agent_unlock() mono_mutex_unlock (&agent_mutex)
+static mono_mutex_t agent_mutex;
 
 static void transport_connect (void);
 
@@ -193,7 +193,7 @@ mono_attach_parse_options (char *options)
 void
 mono_attach_init (void)
 {
-       InitializeCriticalSection (&agent_mutex);
+       mono_mutex_init_recursive (&agent_mutex);
 
        config.enabled = TRUE;
 }
index df1eda26820cc45243b96f9ec5d2874c9f234c6a..d438803266c9de14353e3f53d8573be775264e57 100644 (file)
@@ -6407,11 +6407,11 @@ mono_bounded_array_class_get (MonoClass *eclass, guint32 rank, gboolean bounded)
                 * from mono_class_from_mono_type (), mono_array_new (), 
                 * Array:CreateInstance (), etc, so use a separate cache + a separate lock.
                 */
-               EnterCriticalSection (&image->szarray_cache_lock);
+               mono_mutex_lock (&image->szarray_cache_lock);
                if (!image->szarray_cache)
                        image->szarray_cache = g_hash_table_new (mono_aligned_addr_hash, NULL);
                class = g_hash_table_lookup (image->szarray_cache, eclass);
-               LeaveCriticalSection (&image->szarray_cache_lock);
+               mono_mutex_unlock (&image->szarray_cache_lock);
                if (class)
                        return class;
 
@@ -6548,14 +6548,14 @@ mono_bounded_array_class_get (MonoClass *eclass, guint32 rank, gboolean bounded)
        if (rank == 1 && !bounded) {
                MonoClass *prev_class;
 
-               EnterCriticalSection (&image->szarray_cache_lock);
+               mono_mutex_lock (&image->szarray_cache_lock);
                prev_class = g_hash_table_lookup (image->szarray_cache, eclass);
                if (prev_class)
                        /* Someone got in before us */
                        class = prev_class;
                else
                        g_hash_table_insert (image->szarray_cache, eclass, class);
-               LeaveCriticalSection (&image->szarray_cache_lock);
+               mono_mutex_unlock (&image->szarray_cache_lock);
        } else {
                list = g_slist_append (rootlist, class);
                g_hash_table_insert (image->array_cache, eclass, list);
index f722716d1e6f80c2defff89c66e0395d25f37b88..b3ed7197d4f5db149c8a75e49ff130cf9c521775 100644 (file)
@@ -76,9 +76,9 @@ enum {
 #undef OPDEF
 
 /* This mutex protects the various cominterop related caches in MonoImage */
-#define mono_cominterop_lock() EnterCriticalSection (&cominterop_mutex)
-#define mono_cominterop_unlock() LeaveCriticalSection (&cominterop_mutex)
-static CRITICAL_SECTION cominterop_mutex;
+#define mono_cominterop_lock() mono_mutex_lock (&cominterop_mutex)
+#define mono_cominterop_unlock() mono_mutex_unlock (&cominterop_mutex)
+static mono_mutex_t cominterop_mutex;
 
 /* STDCALL on windows, CDECL everywhere else to work with XPCOM and MainWin COM */
 #ifdef  HOST_WIN32
@@ -535,7 +535,7 @@ mono_cominterop_init (void)
 {
        const char* com_provider_env;
 
-       InitializeCriticalSection (&cominterop_mutex);
+       mono_mutex_init_recursive (&cominterop_mutex);
 
        com_provider_env = g_getenv ("MONO_COM");
        if (com_provider_env && !strcmp(com_provider_env, "MS"))
@@ -567,7 +567,7 @@ mono_cominterop_init (void)
 void
 mono_cominterop_cleanup (void)
 {
-       DeleteCriticalSection (&cominterop_mutex);
+       mono_mutex_destroy (&cominterop_mutex);
 }
 
 void
index a9031eb97eaaa2fd7ac1acb48cc0dccb81befc4c..43982f44af09af9d6d44b04dd95407ede4122ed4 100644 (file)
@@ -15,8 +15,8 @@
 #include <mono/io-layer/io-layer.h>
 #include <mono/metadata/mempool-internals.h>
 
-extern CRITICAL_SECTION mono_delegate_section;
-extern CRITICAL_SECTION mono_strtod_mutex;
+extern mono_mutex_t mono_delegate_section;
+extern mono_mutex_t mono_strtod_mutex;
 
 /*
  * If this is set, the memory belonging to appdomains is not freed when a domain is
@@ -281,7 +281,7 @@ struct _MonoDomain {
         * i.e. if both are taken by the same thread, the loader lock
         * must taken first.
         */
-       CRITICAL_SECTION    lock;
+       mono_mutex_t    lock;
        MonoMemPool        *mp;
        MonoCodeManager    *code_mp;
        /*
@@ -331,7 +331,7 @@ struct _MonoDomain {
        GHashTable         *proxy_vtable_hash;
        /* Protected by 'jit_code_hash_lock' */
        MonoInternalHashTable jit_code_hash;
-       CRITICAL_SECTION    jit_code_hash_lock;
+       mono_mutex_t    jit_code_hash_lock;
        int                 num_jit_info_tables;
        MonoJitInfoTable * 
          volatile          jit_info_table;
@@ -360,9 +360,9 @@ struct _MonoDomain {
        GHashTable         *finalizable_objects_hash;
 
        /* Protects the three hashes above */
-       CRITICAL_SECTION   finalizable_objects_hash_lock;
+       mono_mutex_t   finalizable_objects_hash_lock;
        /* Used when accessing 'domain_assemblies' */
-       CRITICAL_SECTION    assemblies_lock;
+       mono_mutex_t    assemblies_lock;
 
        GHashTable         *method_rgctx_hash;
 
index f42554f739f0a64391a8ce5bb25f1934425f0209..f7e22bb99f91b4960575ce46a89c21f84388e4da 100644 (file)
@@ -93,9 +93,9 @@ static gboolean debug_domain_unload;
 
 gboolean mono_dont_free_domains;
 
-#define mono_appdomains_lock() EnterCriticalSection (&appdomains_mutex)
-#define mono_appdomains_unlock() LeaveCriticalSection (&appdomains_mutex)
-static CRITICAL_SECTION appdomains_mutex;
+#define mono_appdomains_lock() mono_mutex_lock (&appdomains_mutex)
+#define mono_appdomains_unlock() mono_mutex_unlock (&appdomains_mutex)
+static mono_mutex_t appdomains_mutex;
 
 static MonoDomain *mono_root_domain = NULL;
 
@@ -1304,10 +1304,10 @@ mono_domain_create (void)
        domain->finalizable_objects_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
        domain->ftnptrs_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
 
-       InitializeCriticalSection (&domain->lock);
-       InitializeCriticalSection (&domain->assemblies_lock);
-       InitializeCriticalSection (&domain->jit_code_hash_lock);
-       InitializeCriticalSection (&domain->finalizable_objects_hash_lock);
+       mono_mutex_init_recursive (&domain->lock);
+       mono_mutex_init_recursive (&domain->assemblies_lock);
+       mono_mutex_init_recursive (&domain->jit_code_hash_lock);
+       mono_mutex_init_recursive (&domain->finalizable_objects_hash_lock);
 
        domain->method_rgctx_hash = NULL;
 
@@ -1381,7 +1381,7 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
        MONO_FAST_TLS_INIT (tls_appdomain);
        mono_native_tls_alloc (&appdomain_thread_id, NULL);
 
-       InitializeCriticalSection (&appdomains_mutex);
+       mono_mutex_init_recursive (&appdomains_mutex);
 
        mono_metadata_init ();
        mono_images_init ();
@@ -1789,7 +1789,7 @@ mono_cleanup (void)
        mono_metadata_cleanup ();
 
        mono_native_tls_free (appdomain_thread_id);
-       DeleteCriticalSection (&appdomains_mutex);
+       mono_mutex_destroy (&appdomains_mutex);
 
 #ifndef HOST_WIN32
        wapi_cleanup ();
@@ -2137,10 +2137,10 @@ mono_domain_free (MonoDomain *domain, gboolean force)
                domain->ftnptrs_hash = NULL;
        }
 
-       DeleteCriticalSection (&domain->finalizable_objects_hash_lock);
-       DeleteCriticalSection (&domain->assemblies_lock);
-       DeleteCriticalSection (&domain->jit_code_hash_lock);
-       DeleteCriticalSection (&domain->lock);
+       mono_mutex_destroy (&domain->finalizable_objects_hash_lock);
+       mono_mutex_destroy (&domain->assemblies_lock);
+       mono_mutex_destroy (&domain->jit_code_hash_lock);
+       mono_mutex_destroy (&domain->lock);
        domain->setup = NULL;
 
        mono_gc_deregister_root ((char*)&(domain->MONO_DOMAIN_FIRST_GC_TRACKED));
index 62fdb109d45310a18a6b159053726093d1d9a5c9..55ee713cbf26cf1614751d4f5d728c3f37b694b7 100644 (file)
@@ -31,8 +31,8 @@ typedef struct {
 #endif
 } GCStats;
 
-#define mono_domain_finalizers_lock(domain) EnterCriticalSection (&(domain)->finalizable_objects_hash_lock);
-#define mono_domain_finalizers_unlock(domain) LeaveCriticalSection (&(domain)->finalizable_objects_hash_lock);
+#define mono_domain_finalizers_lock(domain) mono_mutex_lock (&(domain)->finalizable_objects_hash_lock);
+#define mono_domain_finalizers_unlock(domain) mono_mutex_unlock (&(domain)->finalizable_objects_hash_lock);
 
 /* Register a memory area as a conservatively scanned GC root */
 #define MONO_GC_REGISTER_ROOT_PINNING(x) mono_gc_register_root ((char*)&(x), sizeof(x), NULL)
index 3d4532648a78e9e44ada94531dce8ca4b1498ab3..5a6af22abf1591b422a511e69cf8ac39bd06d40f 100644 (file)
@@ -59,10 +59,10 @@ static gboolean gc_disabled = FALSE;
 
 static gboolean finalizing_root_domain = FALSE;
 
-#define mono_finalizer_lock() EnterCriticalSection (&finalizer_mutex)
-#define mono_finalizer_unlock() LeaveCriticalSection (&finalizer_mutex)
-static CRITICAL_SECTION finalizer_mutex;
-static CRITICAL_SECTION reference_queue_mutex;
+#define mono_finalizer_lock() mono_mutex_lock (&finalizer_mutex)
+#define mono_finalizer_unlock() mono_mutex_unlock (&finalizer_mutex)
+static mono_mutex_t finalizer_mutex;
+static mono_mutex_t reference_queue_mutex;
 
 static GSList *domains_to_finalize= NULL;
 static MonoMList *threads_to_finalize = NULL;
@@ -502,10 +502,10 @@ ves_icall_System_GC_get_ephemeron_tombstone (void)
        return mono_domain_get ()->ephemeron_tombstone;
 }
 
-#define mono_allocator_lock() EnterCriticalSection (&allocator_section)
-#define mono_allocator_unlock() LeaveCriticalSection (&allocator_section)
-static CRITICAL_SECTION allocator_section;
-static CRITICAL_SECTION handle_section;
+#define mono_allocator_lock() mono_mutex_lock (&allocator_section)
+#define mono_allocator_unlock() mono_mutex_unlock (&allocator_section)
+static mono_mutex_t allocator_section;
+static mono_mutex_t handle_section;
 
 typedef enum {
        HANDLE_WEAK,
@@ -605,8 +605,8 @@ static HandleData gc_handles [] = {
        {NULL, NULL, 0, HANDLE_PINNED, 0}
 };
 
-#define lock_handles(handles) EnterCriticalSection (&handle_section)
-#define unlock_handles(handles) LeaveCriticalSection (&handle_section)
+#define lock_handles(handles) mono_mutex_lock (&handle_section)
+#define unlock_handles(handles) mono_mutex_unlock (&handle_section)
 
 static int
 find_first_unset (guint32 bitmap)
@@ -1140,11 +1140,11 @@ mono_gc_init_finalizer_thread (void)
 void
 mono_gc_init (void)
 {
-       InitializeCriticalSection (&handle_section);
-       InitializeCriticalSection (&allocator_section);
+       mono_mutex_init_recursive (&handle_section);
+       mono_mutex_init_recursive (&allocator_section);
 
-       InitializeCriticalSection (&finalizer_mutex);
-       InitializeCriticalSection (&reference_queue_mutex);
+       mono_mutex_init_recursive (&finalizer_mutex);
+       mono_mutex_init_recursive (&reference_queue_mutex);
 
        MONO_GC_REGISTER_ROOT_FIXED (gc_handles [HANDLE_NORMAL].entries);
        MONO_GC_REGISTER_ROOT_FIXED (gc_handles [HANDLE_PINNED].entries);
@@ -1242,10 +1242,10 @@ mono_gc_cleanup (void)
 
        mono_reference_queue_cleanup ();
 
-       DeleteCriticalSection (&handle_section);
-       DeleteCriticalSection (&allocator_section);
-       DeleteCriticalSection (&finalizer_mutex);
-       DeleteCriticalSection (&reference_queue_mutex);
+       mono_mutex_destroy (&handle_section);
+       mono_mutex_destroy (&allocator_section);
+       mono_mutex_destroy (&finalizer_mutex);
+       mono_mutex_destroy (&reference_queue_mutex);
 }
 
 #else
@@ -1258,7 +1258,7 @@ mono_gc_finalize_notify (void)
 
 void mono_gc_init (void)
 {
-       InitializeCriticalSection (&handle_section);
+       mono_mutex_init_recursive (&handle_section);
 }
 
 void mono_gc_cleanup (void)
@@ -1438,7 +1438,7 @@ reference_queue_proccess_all (void)
                reference_queue_proccess (queue);
 
 restart:
-       EnterCriticalSection (&reference_queue_mutex);
+       mono_mutex_lock (&reference_queue_mutex);
        for (iter = &ref_queues; *iter;) {
                queue = *iter;
                if (!queue->should_be_deleted) {
@@ -1446,14 +1446,14 @@ restart:
                        continue;
                }
                if (queue->queue) {
-                       LeaveCriticalSection (&reference_queue_mutex);
+                       mono_mutex_unlock (&reference_queue_mutex);
                        reference_queue_proccess (queue);
                        goto restart;
                }
                *iter = queue->next;
                g_free (queue);
        }
-       LeaveCriticalSection (&reference_queue_mutex);
+       mono_mutex_unlock (&reference_queue_mutex);
 }
 
 static void
@@ -1511,10 +1511,10 @@ mono_gc_reference_queue_new (mono_reference_queue_callback callback)
        MonoReferenceQueue *res = g_new0 (MonoReferenceQueue, 1);
        res->callback = callback;
 
-       EnterCriticalSection (&reference_queue_mutex);
+       mono_mutex_lock (&reference_queue_mutex);
        res->next = ref_queues;
        ref_queues = res;
-       LeaveCriticalSection (&reference_queue_mutex);
+       mono_mutex_unlock (&reference_queue_mutex);
 
        return res;
 }
index 0559152fa60c19d73660ad2cc9ab0925ab9eaefb..98b09a50c0490e8bb3c24d75e339fa3412b5569d 100644 (file)
@@ -129,9 +129,9 @@ mono_double_ParseImpl (char *ptr, double *result)
 
        if (*ptr){
                /* mono_strtod () is not thread-safe */
-               EnterCriticalSection (&mono_strtod_mutex);
+               mono_mutex_lock (&mono_strtod_mutex);
                *result = mono_strtod (ptr, &endptr);
-               LeaveCriticalSection (&mono_strtod_mutex);
+               mono_mutex_unlock (&mono_strtod_mutex);
        }
 
        if (!*ptr || (endptr && *endptr))
index 3a4d69c3b5806b9ade330af3af817c41f9be10ea..d5c05bef527831e5190aa8f95b0a5c931dbc8671 100644 (file)
@@ -54,10 +54,10 @@ static GHashTable *loaded_images_refonly_hash;
 
 static gboolean debug_assembly_unload = FALSE;
 
-#define mono_images_lock() if (mutex_inited) EnterCriticalSection (&images_mutex)
-#define mono_images_unlock() if (mutex_inited) LeaveCriticalSection (&images_mutex)
+#define mono_images_lock() if (mutex_inited) mono_mutex_lock (&images_mutex)
+#define mono_images_unlock() if (mutex_inited) mono_mutex_unlock (&images_mutex)
 static gboolean mutex_inited;
-static CRITICAL_SECTION images_mutex;
+static mono_mutex_t images_mutex;
 
 typedef struct ImageUnloadHook ImageUnloadHook;
 struct ImageUnloadHook {
@@ -184,7 +184,7 @@ mono_image_rva_map (MonoImage *image, guint32 addr)
 void
 mono_images_init (void)
 {
-       InitializeCriticalSection (&images_mutex);
+       mono_mutex_init_recursive (&images_mutex);
 
        loaded_images_hash = g_hash_table_new (g_str_hash, g_str_equal);
        loaded_images_refonly_hash = g_hash_table_new (g_str_hash, g_str_equal);
@@ -205,7 +205,7 @@ mono_images_cleanup (void)
        GHashTableIter iter;
        MonoImage *image;
 
-       DeleteCriticalSection (&images_mutex);
+       mono_mutex_destroy (&images_mutex);
 
        g_hash_table_iter_init (&iter, loaded_images_hash);
        while (g_hash_table_iter_next (&iter, NULL, (void**)&image))
@@ -671,20 +671,15 @@ class_next_value (gpointer value)
 void
 mono_image_init (MonoImage *image)
 {
-       InitializeCriticalSection (&image->lock);
-       InitializeCriticalSection (&image->szarray_cache_lock);
+       mono_mutex_init_recursive (&image->lock);
+       mono_mutex_init_recursive (&image->szarray_cache_lock);
 
        image->mempool = mono_mempool_new_size (512);
        mono_internal_hash_table_init (&image->class_cache,
                                       g_direct_hash,
                                       class_key_extract,
                                       class_next_value);
-#ifdef HOST_WIN32
-       // FIXME:
        image->field_cache = mono_conc_hashtable_new (&image->lock, NULL, NULL);
-#else
-       image->field_cache = mono_conc_hashtable_new (&image->lock.mutex, NULL, NULL);
-#endif
 
        image->typespec_cache = g_hash_table_new (NULL, NULL);
        image->memberref_signatures = g_hash_table_new (NULL, NULL);
@@ -1699,8 +1694,8 @@ mono_image_close_except_pools (MonoImage *image)
        if (image->modules_loaded)
                g_free (image->modules_loaded);
 
-       DeleteCriticalSection (&image->szarray_cache_lock);
-       DeleteCriticalSection (&image->lock);
+       mono_mutex_destroy (&image->szarray_cache_lock);
+       mono_mutex_destroy (&image->lock);
 
        /*g_print ("destroy image %p (dynamic: %d)\n", image, image->dynamic);*/
        if (image_is_dynamic (image)) {
index 941f4d039cae21b1c229cefc9794a0ae814bf0e6..7cbc0810c00a585771a779980e266b96da26add4 100644 (file)
@@ -55,7 +55,7 @@ MonoDefaults mono_defaults;
  * See domain-internals.h for locking policy in combination with the
  * domain lock.
  */
-static CRITICAL_SECTION loader_mutex;
+static mono_mutex_t loader_mutex;
 static gboolean loader_lock_inited;
 
 /* Statistics */
@@ -83,7 +83,7 @@ mono_loader_init ()
        static gboolean inited;
 
        if (!inited) {
-               InitializeCriticalSection (&loader_mutex);
+               mono_mutex_init_recursive (&loader_mutex);
                loader_lock_inited = TRUE;
 
                mono_native_tls_alloc (&loader_error_thread_id, NULL);
@@ -110,7 +110,7 @@ mono_loader_cleanup (void)
        mono_native_tls_free (loader_error_thread_id);
        mono_native_tls_free (loader_lock_nest_id);
 
-       DeleteCriticalSection (&loader_mutex);
+       mono_mutex_destroy (&loader_mutex);
        loader_lock_inited = FALSE;     
 }
 
index 0f04817ced9d077f54b828f963f7947fd2da0a96..959dd36aa3c282a90216973f6402dac5990bb871 100644 (file)
@@ -31,8 +31,8 @@
  * 
  * To log more kind of locks just do the following:
  *     - add an entry into the RuntimeLocks enum
- *  - change EnterCriticalSection(mutex) to mono_locks_acquire (mutex, LockName)
- *  - change LeaveCriticalSection to mono_locks_release (mutex, LockName)
+ *  - change mono_mutex_lock(mutex) to mono_locks_acquire (mutex, LockName)
+ *  - change mono_mutex_unlock to mono_locks_release (mutex, LockName)
  *  - change the decoder to understand the new lock kind.
  *
  * TODO:
@@ -54,7 +54,7 @@
 #endif
 
 static FILE *trace_file;
-static CRITICAL_SECTION tracer_lock;
+static mono_mutex_t tracer_lock;
 static size_t base_address;
 
 typedef enum {
@@ -71,7 +71,7 @@ mono_locks_tracer_init (void)
        Dl_info info;
        int res;
        char *name;
-       InitializeCriticalSection (&tracer_lock);
+       mono_mutex_init_recursive (&tracer_lock);
        if (!g_getenv ("MONO_ENABLE_LOCK_TRACER"))
                return;
        name = g_strdup_printf ("locks.%d", getpid ());
index 215b683ba4beb910514d98422f2c3fc8b039e78e..4069e97173fe1a355aff3aac47a22c93d5eed9f5 100644 (file)
@@ -37,13 +37,13 @@ void mono_locks_lock_released (RuntimeLocks kind, gpointer lock) MONO_INTERNAL;
 #endif
 
 #define mono_locks_acquire(LOCK, NAME) do { \
-       EnterCriticalSection (LOCK); \
+       mono_mutex_lock (LOCK); \
        mono_locks_lock_acquired (NAME, LOCK); \
 } while (0)
 
 #define mono_locks_release(LOCK, NAME) do { \
        mono_locks_lock_released (NAME, LOCK); \
-       LeaveCriticalSection (LOCK); \
+       mono_mutex_unlock (LOCK); \
 } while (0)
 
 #define mono_locks_mutex_acquire(LOCK, NAME) do { \
index 4555510e80131af50660e4c699dd6102d9d9514c..22ccc5f18bd9aca295ea89442205f3d75cea39df 100644 (file)
@@ -80,7 +80,7 @@ typedef struct _MonoRemotingMethods MonoRemotingMethods;
  */
 #define mono_marshal_lock() mono_locks_acquire (&marshal_mutex, MarshalLock)
 #define mono_marshal_unlock() mono_locks_release (&marshal_mutex, MarshalLock)
-static CRITICAL_SECTION marshal_mutex;
+static mono_mutex_t marshal_mutex;
 static gboolean marshal_mutex_initialized;
 
 static MonoNativeTlsKey last_error_tls_id;
@@ -230,7 +230,7 @@ mono_marshal_init (void)
 
        if (!module_initialized) {
                module_initialized = TRUE;
-               InitializeCriticalSection (&marshal_mutex);
+               mono_mutex_init_recursive (&marshal_mutex);
                marshal_mutex_initialized = TRUE;
 
                register_icall (ves_icall_System_Threading_Thread_ResetAbort, "ves_icall_System_Threading_Thread_ResetAbort", "void", TRUE);
@@ -300,7 +300,7 @@ mono_marshal_cleanup (void)
 
        mono_native_tls_free (load_type_info_tls_id);
        mono_native_tls_free (last_error_tls_id);
-       DeleteCriticalSection (&marshal_mutex);
+       mono_mutex_destroy (&marshal_mutex);
        marshal_mutex_initialized = FALSE;
 }
 
old mode 100755 (executable)
new mode 100644 (file)
index 32084479b507c20ea624d5d677030736f280b9f1..221a2a904b14c4afb66a8918ac4acc6d62691ce0 100644 (file)
@@ -207,7 +207,7 @@ mono_mempool_stats (MonoMemPool *pool)
 #include "metadata/appdomain.h"
 #include "metadata/metadata-internals.h"
 
-static CRITICAL_SECTION mempool_tracing_lock;
+static mono_mutex_t mempool_tracing_lock;
 #define BACKTRACE_DEPTH 7
 static void
 mono_backtrace (int size)
@@ -218,11 +218,11 @@ mono_backtrace (int size)
         static gboolean inited;
 
         if (!inited) {
-            InitializeCriticalSection (&mempool_tracing_lock);
+            mono_mutex_init_recursive (&mempool_tracing_lock);
             inited = TRUE;
         }
 
-        EnterCriticalSection (&mempool_tracing_lock);
+        mono_mutex_lock (&mempool_tracing_lock);
         g_print ("Allocating %d bytes\n", size);
         symbols = backtrace (array, BACKTRACE_DEPTH);
         names = backtrace_symbols (array, symbols);
@@ -230,7 +230,7 @@ mono_backtrace (int size)
                 g_print ("\t%s\n", names [i]);
         }
         free (names);
-        LeaveCriticalSection (&mempool_tracing_lock);
+        mono_mutex_unlock (&mempool_tracing_lock);
 }
 
 #endif
index f165929b27394f0535ba0301eac6b96ff328ccc5..5ffb254c1ba227b8dcb0a80e98e281e0f17e9ec5 100644 (file)
@@ -249,7 +249,7 @@ struct _MonoImage {
 
        GHashTable *szarray_cache;
        /* This has a separate lock to improve scalability */
-       CRITICAL_SECTION szarray_cache_lock;
+       mono_mutex_t szarray_cache_lock;
 
        /*
         * indexed by MonoMethodSignature 
@@ -346,7 +346,7 @@ struct _MonoImage {
         * No other runtime locks must be taken while holding this lock.
         * It's meant to be used only to mutate and query structures part of this image.
         */
-       CRITICAL_SECTION    lock;
+       mono_mutex_t    lock;
 };
 
 /*
@@ -362,7 +362,7 @@ typedef struct {
 
        GHashTable *gclass_cache, *ginst_cache, *gmethod_cache, *gsignature_cache;
 
-       CRITICAL_SECTION    lock;
+       mono_mutex_t    lock;
 
        /*
         * Memory for generic instances owned by this image set should be allocated from
index 95a07fa5a492157444e4c8a077204a33f0fe5281..091ab5046e3c2b45db4e17c1e1559f5e8f41c57b 100644 (file)
@@ -1376,7 +1376,7 @@ static int next_generic_inst_id = 0;
 static MonoImageSet *mscorlib_image_set;
 /* Protected by image_sets_mutex */
 static GPtrArray *image_sets;
-static CRITICAL_SECTION image_sets_mutex;
+static mono_mutex_t image_sets_mutex;
 
 static guint mono_generic_class_hash (gconstpointer data);
 
@@ -1490,7 +1490,7 @@ mono_metadata_init (void)
        for (i = 0; i < NBUILTIN_TYPES (); ++i)
                g_hash_table_insert (type_cache, (gpointer) &builtin_types [i], (gpointer) &builtin_types [i]);
 
-       InitializeCriticalSection (&image_sets_mutex);
+       mono_mutex_init_recursive (&image_sets_mutex);
 }
 
 /**
@@ -1506,7 +1506,7 @@ mono_metadata_cleanup (void)
        type_cache = NULL;
        g_ptr_array_free (image_sets, TRUE);
        image_sets = NULL;
-       DeleteCriticalSection (&image_sets_mutex);
+       mono_mutex_destroy (&image_sets_mutex);
 }
 
 /**
@@ -2192,13 +2192,13 @@ retry:
 static inline void
 image_sets_lock (void)
 {
-       EnterCriticalSection (&image_sets_mutex);
+       mono_mutex_lock (&image_sets_mutex);
 }
 
 static inline void
 image_sets_unlock (void)
 {
-       LeaveCriticalSection (&image_sets_mutex);
+       mono_mutex_unlock (&image_sets_mutex);
 }
 
 /*
@@ -2255,7 +2255,7 @@ get_image_set (MonoImage **images, int nimages)
                set = g_new0 (MonoImageSet, 1);
                set->nimages = nimages;
                set->images = g_new0 (MonoImage*, nimages);
-               InitializeCriticalSection (&set->lock);
+               mono_mutex_init_recursive (&set->lock);
                for (i = 0; i < nimages; ++i)
                        set->images [i] = images [i];
                set->gclass_cache = g_hash_table_new_full (mono_generic_class_hash, mono_generic_class_equal, NULL, (GDestroyNotify)free_generic_class);
@@ -2301,20 +2301,20 @@ delete_image_set (MonoImageSet *set)
        if (set->mempool)
                mono_mempool_destroy (set->mempool);
        g_free (set->images);
-       DeleteCriticalSection (&set->lock);
+       mono_mutex_destroy (&set->lock);
        g_free (set);
 }
 
 static void
 mono_image_set_lock (MonoImageSet *set)
 {
-       EnterCriticalSection (&set->lock);
+       mono_mutex_lock (&set->lock);
 }
 
 static void
 mono_image_set_unlock (MonoImageSet *set)
 {
-       LeaveCriticalSection (&set->lock);
+       mono_mutex_unlock (&set->lock);
 }
 
 gpointer
index fc9814b33a1f4d9c51b38b05ca6aad8bcc18b71b..d713709991219948a556661e3b6e97a4d95ea656 100644 (file)
@@ -83,9 +83,9 @@ struct _MonitorArray {
        MonoThreadsSync monitors [MONO_ZERO_LEN_ARRAY];
 };
 
-#define mono_monitor_allocator_lock() EnterCriticalSection (&monitor_mutex)
-#define mono_monitor_allocator_unlock() LeaveCriticalSection (&monitor_mutex)
-static CRITICAL_SECTION monitor_mutex;
+#define mono_monitor_allocator_lock() mono_mutex_lock (&monitor_mutex)
+#define mono_monitor_allocator_unlock() mono_mutex_unlock (&monitor_mutex)
+static mono_mutex_t monitor_mutex;
 static MonoThreadsSync *monitor_freelist;
 static MonitorArray *monitor_allocated;
 static int array_size = 16;
@@ -109,7 +109,7 @@ static __thread gsize tls_pthread_self MONO_TLS_FAST;
 void
 mono_monitor_init (void)
 {
-       InitializeCriticalSection (&monitor_mutex);
+       mono_mutex_init_recursive (&monitor_mutex);
 }
  
 void
@@ -118,7 +118,7 @@ mono_monitor_cleanup (void)
        MonoThreadsSync *mon;
        /* MonitorArray *marray, *next = NULL; */
 
-       /*DeleteCriticalSection (&monitor_mutex);*/
+       /*mono_mutex_destroy (&monitor_mutex);*/
 
        /* The monitors on the freelist don't have weak links - mark them */
        for (mon = monitor_freelist; mon; mon = mon->data)
index 2891c2eb46b6297d7962f159d01df5d6a858437b..8168b2cf15a15d488ae8126f2f836fedaca1adb0 100644 (file)
@@ -28,7 +28,7 @@
 #include <mono/metadata/mono-endian.h>
 
 static guint32 debugger_lock_level = 0;
-static CRITICAL_SECTION debugger_lock_mutex;
+static mono_mutex_t debugger_lock_mutex;
 
 typedef struct
 {
@@ -43,7 +43,7 @@ void
 mono_debugger_lock (void)
 {
        g_assert (initialized);
-       EnterCriticalSection (&debugger_lock_mutex);
+       mono_mutex_lock (&debugger_lock_mutex);
        debugger_lock_level++;
 }
 
@@ -52,13 +52,13 @@ mono_debugger_unlock (void)
 {
        g_assert (initialized);
        debugger_lock_level--;
-       LeaveCriticalSection (&debugger_lock_mutex);
+       mono_mutex_unlock (&debugger_lock_mutex);
 }
 
 void
 mono_debugger_initialize ()
 {
-       InitializeCriticalSection (&debugger_lock_mutex);
+       mono_mutex_init_recursive (&debugger_lock_mutex);
        initialized = 1;
 }
 
index ec72516a2b394f8fc4db25163ad9a6354000bbf7..f28839fa1d2cd59d9c0a9ccc70e5c778125a888b 100644 (file)
@@ -147,9 +147,9 @@ enum {
        NUM_COUNTERS
 };
 
-static CRITICAL_SECTION perfctr_mutex;
-#define perfctr_lock() EnterCriticalSection (&perfctr_mutex)
-#define perfctr_unlock() LeaveCriticalSection (&perfctr_mutex)
+static mono_mutex_t perfctr_mutex;
+#define perfctr_lock() mono_mutex_lock (&perfctr_mutex)
+#define perfctr_unlock() mono_mutex_unlock (&perfctr_mutex)
 
 typedef struct {
        char reserved [16];
@@ -456,7 +456,7 @@ mono_perfcounters_init (void)
        d_offset += 7;
        d_offset &= ~7;
 
-       InitializeCriticalSection (&perfctr_mutex);
+       mono_mutex_init_recursive (&perfctr_mutex);
 
        shared_area = mono_shared_area ();
        shared_area->counters_start = G_STRUCT_OFFSET (MonoSharedArea, counters);
index 9ec3893765a22731c39b454ae05c7497d5a1dfa7..b690e783e22404704387398628d6827acfdff2af 100644 (file)
@@ -419,7 +419,7 @@ struct _MonoInternalThread {
        gpointer suspend_event;
        gpointer suspended_event;
        gpointer resume_event;
-       CRITICAL_SECTION *synch_cs;
+       mono_mutex_t *synch_cs;
        MonoBoolean threadpool_thread;
        MonoBoolean thread_dump_requested;
        MonoBoolean thread_interrupt_requested;
index 305a48820b980825278dd59f8c6005160cab9611..8fe6b05a5605e91f767fb2c5531c8ab586bb808e 100644 (file)
@@ -88,9 +88,9 @@ static char *
 mono_string_to_utf8_internal (MonoMemPool *mp, MonoImage *image, MonoString *s, gboolean ignore_error, MonoError *error);
 
 
-#define ldstr_lock() EnterCriticalSection (&ldstr_section)
-#define ldstr_unlock() LeaveCriticalSection (&ldstr_section)
-static CRITICAL_SECTION ldstr_section;
+#define ldstr_lock() mono_mutex_lock (&ldstr_section)
+#define ldstr_unlock() mono_mutex_unlock (&ldstr_section)
+static mono_mutex_t ldstr_section;
 
 static gboolean profile_allocs = TRUE;
 
@@ -137,13 +137,13 @@ typedef struct
        guint32 initializing_tid;
        guint32 waiting_count;
        gboolean done;
-       CRITICAL_SECTION initialization_section;
+       mono_mutex_t initialization_section;
 } TypeInitializationLock;
 
 /* for locking access to type_initialization_hash and blocked_thread_hash */
-#define mono_type_initialization_lock() EnterCriticalSection (&type_initialization_section)
-#define mono_type_initialization_unlock() LeaveCriticalSection (&type_initialization_section)
-static CRITICAL_SECTION type_initialization_section;
+#define mono_type_initialization_lock() mono_mutex_lock (&type_initialization_section)
+#define mono_type_initialization_unlock() mono_mutex_unlock (&type_initialization_section)
+static mono_mutex_t type_initialization_section;
 
 /* from vtable to lock */
 static GHashTable *type_initialization_hash;
@@ -188,10 +188,10 @@ mono_thread_get_main (void)
 void
 mono_type_initialization_init (void)
 {
-       InitializeCriticalSection (&type_initialization_section);
+       mono_mutex_init_recursive (&type_initialization_section);
        type_initialization_hash = g_hash_table_new (NULL, NULL);
        blocked_thread_hash = g_hash_table_new (NULL, NULL);
-       InitializeCriticalSection (&ldstr_section);
+       mono_mutex_init_recursive (&ldstr_section);
 }
 
 void
@@ -201,11 +201,11 @@ mono_type_initialization_cleanup (void)
        /* This is causing race conditions with
         * mono_release_type_locks
         */
-       DeleteCriticalSection (&type_initialization_section);
+       mono_mutex_destroy (&type_initialization_section);
        g_hash_table_destroy (type_initialization_hash);
        type_initialization_hash = NULL;
 #endif
-       DeleteCriticalSection (&ldstr_section);
+       mono_mutex_destroy (&ldstr_section);
        g_hash_table_destroy (blocked_thread_hash);
        blocked_thread_hash = NULL;
 
@@ -334,12 +334,12 @@ mono_runtime_class_init_full (MonoVTable *vtable, gboolean raise_exception)
                                }
                        }
                        lock = g_malloc (sizeof(TypeInitializationLock));
-                       InitializeCriticalSection (&lock->initialization_section);
+                       mono_mutex_init_recursive (&lock->initialization_section);
                        lock->initializing_tid = tid;
                        lock->waiting_count = 1;
                        lock->done = FALSE;
                        /* grab the vtable lock while this thread still owns type_initialization_section */
-                       EnterCriticalSection (&lock->initialization_section);
+                       mono_mutex_lock (&lock->initialization_section);
                        g_hash_table_insert (type_initialization_hash, vtable, lock);
                        do_initialization = 1;
                } else {
@@ -404,11 +404,11 @@ mono_runtime_class_init_full (MonoVTable *vtable, gboolean raise_exception)
                        if (last_domain)
                                mono_domain_set (last_domain, TRUE);
                        lock->done = TRUE;
-                       LeaveCriticalSection (&lock->initialization_section);
+                       mono_mutex_unlock (&lock->initialization_section);
                } else {
                        /* this just blocks until the initializing thread is done */
-                       EnterCriticalSection (&lock->initialization_section);
-                       LeaveCriticalSection (&lock->initialization_section);
+                       mono_mutex_lock (&lock->initialization_section);
+                       mono_mutex_unlock (&lock->initialization_section);
                }
 
                mono_type_initialization_lock ();
@@ -416,7 +416,7 @@ mono_runtime_class_init_full (MonoVTable *vtable, gboolean raise_exception)
                        g_hash_table_remove (blocked_thread_hash, GUINT_TO_POINTER (tid));
                --lock->waiting_count;
                if (lock->waiting_count == 0) {
-                       DeleteCriticalSection (&lock->initialization_section);
+                       mono_mutex_destroy (&lock->initialization_section);
                        g_hash_table_remove (type_initialization_hash, vtable);
                        g_free (lock);
                }
@@ -452,10 +452,10 @@ gboolean release_type_locks (gpointer key, gpointer value, gpointer user)
                 * and get_type_init_exception_for_class () needs to be aware of this.
                 */
                vtable->init_failed = 1;
-               LeaveCriticalSection (&lock->initialization_section);
+               mono_mutex_unlock (&lock->initialization_section);
                --lock->waiting_count;
                if (lock->waiting_count == 0) {
-                       DeleteCriticalSection (&lock->initialization_section);
+                       mono_mutex_destroy (&lock->initialization_section);
                        g_free (lock);
                        return TRUE;
                }
old mode 100755 (executable)
new mode 100644 (file)
index ea779238aa063df21656b422516b854df810bfaf..53f8ff0c9071485f227887de4d64ce54c885ebc9 100644 (file)
@@ -103,9 +103,9 @@ struct _ProfilerDesc {
 
 static ProfilerDesc *prof_list = NULL;
 
-#define mono_profiler_coverage_lock() EnterCriticalSection (&profiler_coverage_mutex)
-#define mono_profiler_coverage_unlock() LeaveCriticalSection (&profiler_coverage_mutex)
-static CRITICAL_SECTION profiler_coverage_mutex;
+#define mono_profiler_coverage_lock() mono_mutex_lock (&profiler_coverage_mutex)
+#define mono_profiler_coverage_unlock() mono_mutex_unlock (&profiler_coverage_mutex)
+static mono_mutex_t profiler_coverage_mutex;
 
 /* this is directly accessible to other mono libs.
  * It is the ORed value of all the profiler's events.
@@ -128,7 +128,7 @@ mono_profiler_install (MonoProfiler *prof, MonoProfileFunc callback)
 {
        ProfilerDesc *desc = g_new0 (ProfilerDesc, 1);
        if (!prof_list)
-               InitializeCriticalSection (&profiler_coverage_mutex);
+               mono_mutex_init_recursive (&profiler_coverage_mutex);
        desc->profiler = prof;
        desc->shutdown_callback = callback;
        desc->next = prof_list;
index 4b32053f951775325ba139712f5f82787e8c7fd3..be3b1fd0d51646f51a46881649c113c4f8d4b723 100644 (file)
@@ -11,4 +11,4 @@
 MonoObject*
 mono_custom_attrs_get_attr_checked (MonoCustomAttrInfo *ainfo, MonoClass *attr_klass, MonoError *error) MONO_INTERNAL;
 
-#endif
\ No newline at end of file
+#endif
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index b0cfdff25adc6fd60fae5076736067a52fc436d8..75577e57122c354f36d195e5ba23e5da3bbfc876 100644 (file)
@@ -49,4 +49,4 @@ static void qsort_##NAME (ARRAY_TYPE base[], size_t nel) {    \
 }      \
 
 
-#endif
\ No newline at end of file
+#endif
old mode 100755 (executable)
new mode 100644 (file)
index f0bcf61114aabd68706c6e4e4d28edac5f39ea0c..39ade54daa14f83a12c5982a15be9d014e30f289 100644 (file)
@@ -84,7 +84,7 @@ enum {
 };
 
 typedef struct {
-       CRITICAL_SECTION io_lock; /* access to sock_to_state */
+       mono_mutex_t io_lock; /* access to sock_to_state */
        int inited; // 0 -> not initialized , 1->initializing, 2->initialized, 3->cleaned up
        MonoGHashTable *sock_to_state;
 
@@ -160,7 +160,7 @@ static MonoClass *socket_async_call_klass;
 static MonoClass *process_async_call_klass;
 
 static GPtrArray *wsqs;
-CRITICAL_SECTION wsqs_lock;
+mono_mutex_t wsqs_lock;
 static gboolean suspended;
 
 /* Hooks */
@@ -314,14 +314,14 @@ get_events_from_list (MonoMList *list)
 static void
 socket_io_cleanup (SocketIOData *data)
 {
-       EnterCriticalSection (&data->io_lock);
+       mono_mutex_lock (&data->io_lock);
        if (data->inited != 2) {
-               LeaveCriticalSection (&data->io_lock);
+               mono_mutex_unlock (&data->io_lock);
                return;
        }
        data->inited = 3;
        data->shutdown (data->event_data);
-       LeaveCriticalSection (&data->io_lock);
+       mono_mutex_unlock (&data->io_lock);
 }
 
 static int
@@ -443,15 +443,15 @@ mono_thread_pool_remove_socket (int sock)
        if (socket_io_data.inited == 0)
                return;
 
-       EnterCriticalSection (&socket_io_data.io_lock);
+       mono_mutex_lock (&socket_io_data.io_lock);
        if (socket_io_data.sock_to_state == NULL) {
-               LeaveCriticalSection (&socket_io_data.io_lock);
+               mono_mutex_unlock (&socket_io_data.io_lock);
                return;
        }
        list = mono_g_hash_table_lookup (socket_io_data.sock_to_state, GINT_TO_POINTER (sock));
        if (list)
                mono_g_hash_table_remove (socket_io_data.sock_to_state, GINT_TO_POINTER (sock));
-       LeaveCriticalSection (&socket_io_data.io_lock);
+       mono_mutex_unlock (&socket_io_data.io_lock);
        
        while (list) {
                state = (MonoSocketAsyncResult *) mono_mlist_get_data (list);
@@ -506,7 +506,7 @@ socket_io_init (SocketIOData *data)
                }
        }
 
-       EnterCriticalSection (&data->io_lock);
+       mono_mutex_lock (&data->io_lock);
        data->sock_to_state = mono_g_hash_table_new_type (g_direct_hash, g_direct_equal, MONO_HASH_VALUE_GC);
 #ifdef HAVE_EPOLL
        data->event_system = EPOLL_BACKEND;
@@ -520,7 +520,7 @@ socket_io_init (SocketIOData *data)
 
        init_event_system (data);
        mono_thread_create_internal (mono_get_root_domain (), data->wait, data, TRUE, SMALL_STACK);
-       LeaveCriticalSection (&data->io_lock);
+       mono_mutex_unlock (&data->io_lock);
        data->inited = 2;
        threadpool_start_thread (&async_io_tp);
 }
@@ -543,9 +543,9 @@ socket_io_add (MonoAsyncResult *ares, MonoSocketAsyncResult *state)
        MONO_OBJECT_SETREF (state, ares, ares);
 
        fd = GPOINTER_TO_INT (state->handle);
-       EnterCriticalSection (&data->io_lock);
+       mono_mutex_lock (&data->io_lock);
        if (data->sock_to_state == NULL) {
-               LeaveCriticalSection (&data->io_lock);
+               mono_mutex_unlock (&data->io_lock);
                return;
        }
        list = mono_g_hash_table_lookup (data->sock_to_state, GINT_TO_POINTER (fd));
@@ -731,11 +731,11 @@ print_pool_info (ThreadPool *tp)
        g_print ("Queued: %d\n", (tp->tail - tp->head));
        if (tp == &async_tp) {
                int i;
-               EnterCriticalSection (&wsqs_lock);
+               mono_mutex_lock (&wsqs_lock);
                for (i = 0; i < wsqs->len; i++) {
                        g_print ("\tWSQ %d: %d\n", i, mono_wsq_count (g_ptr_array_index (wsqs, i)));
                }
-               LeaveCriticalSection (&wsqs_lock);
+               mono_mutex_unlock (&wsqs_lock);
        } else {
                g_print ("\tSockets: %d\n", mono_g_hash_table_size (socket_io_data.sock_to_state));
        }
@@ -798,7 +798,7 @@ monitor_thread (gpointer unused)
                                continue;
                        need_one = (mono_cq_count (tp->queue) > 0);
                        if (!need_one && !tp->is_io) {
-                               EnterCriticalSection (&wsqs_lock);
+                               mono_mutex_lock (&wsqs_lock);
                                for (i = 0; wsqs != NULL && i < wsqs->len; i++) {
                                        MonoWSQ *wsq;
                                        wsq = g_ptr_array_index (wsqs, i);
@@ -807,7 +807,7 @@ monitor_thread (gpointer unused)
                                                break;
                                        }
                                }
-                               LeaveCriticalSection (&wsqs_lock);
+                               mono_mutex_unlock (&wsqs_lock);
                        }
                        if (need_one)
                                threadpool_start_thread (tp);
@@ -842,7 +842,7 @@ mono_thread_pool_init (void)
        }
 
        MONO_GC_REGISTER_ROOT_FIXED (socket_io_data.sock_to_state);
-       InitializeCriticalSection (&socket_io_data.io_lock);
+       mono_mutex_init_recursive (&socket_io_data.io_lock);
        if (g_getenv ("MONO_THREADS_PER_CPU") != NULL) {
                threads_per_cpu = atoi (g_getenv ("MONO_THREADS_PER_CPU"));
                if (threads_per_cpu < 1)
@@ -857,7 +857,7 @@ mono_thread_pool_init (void)
        async_call_klass = mono_class_from_name (mono_defaults.corlib, "System", "MonoAsyncCall");
        g_assert (async_call_klass);
 
-       InitializeCriticalSection (&wsqs_lock);
+       mono_mutex_init_recursive (&wsqs_lock);
        wsqs = g_ptr_array_sized_new (MAX (100 * cpu_count, thread_count));
 
 #ifndef DISABLE_PERFCOUNTERS
@@ -1006,12 +1006,12 @@ mono_thread_pool_cleanup (void)
        }
 
        if (wsqs) {
-               EnterCriticalSection (&wsqs_lock);
+               mono_mutex_lock (&wsqs_lock);
                mono_wsq_cleanup ();
                if (wsqs)
                        g_ptr_array_free (wsqs, TRUE);
                wsqs = NULL;
-               LeaveCriticalSection (&wsqs_lock);
+               mono_mutex_unlock (&wsqs_lock);
                MONO_SEM_DESTROY (&async_tp.new_job);
        }
 }
@@ -1161,11 +1161,11 @@ mono_thread_pool_remove_domain_jobs (MonoDomain *domain, int timeout)
        threadpool_clear_queue (&async_tp, domain);
        threadpool_clear_queue (&async_io_tp, domain);
 
-       EnterCriticalSection (&socket_io_data.io_lock);
+       mono_mutex_lock (&socket_io_data.io_lock);
        if (socket_io_data.sock_to_state)
                mono_g_hash_table_foreach_remove (socket_io_data.sock_to_state, remove_sockstate_for_domain, domain);
 
-       LeaveCriticalSection (&socket_io_data.io_lock);
+       mono_mutex_unlock (&socket_io_data.io_lock);
        
        /*
         * There might be some threads out that could be about to execute stuff from the given domain.
@@ -1218,21 +1218,21 @@ add_wsq (void)
        int i;
        MonoWSQ *wsq;
 
-       EnterCriticalSection (&wsqs_lock);
+       mono_mutex_lock (&wsqs_lock);
        wsq = mono_wsq_create ();
        if (wsqs == NULL) {
-               LeaveCriticalSection (&wsqs_lock);
+               mono_mutex_unlock (&wsqs_lock);
                return NULL;
        }
        for (i = 0; i < wsqs->len; i++) {
                if (g_ptr_array_index (wsqs, i) == NULL) {
                        wsqs->pdata [i] = wsq;
-                       LeaveCriticalSection (&wsqs_lock);
+                       mono_mutex_unlock (&wsqs_lock);
                        return wsq;
                }
        }
        g_ptr_array_add (wsqs, wsq);
-       LeaveCriticalSection (&wsqs_lock);
+       mono_mutex_unlock (&wsqs_lock);
        return wsq;
 }
 
@@ -1244,9 +1244,9 @@ remove_wsq (MonoWSQ *wsq)
        if (wsq == NULL)
                return;
 
-       EnterCriticalSection (&wsqs_lock);
+       mono_mutex_lock (&wsqs_lock);
        if (wsqs == NULL) {
-               LeaveCriticalSection (&wsqs_lock);
+               mono_mutex_unlock (&wsqs_lock);
                return;
        }
        g_ptr_array_remove_fast (wsqs, wsq);
@@ -1262,7 +1262,7 @@ remove_wsq (MonoWSQ *wsq)
                }
        }
        mono_wsq_destroy (wsq);
-       LeaveCriticalSection (&wsqs_lock);
+       mono_mutex_unlock (&wsqs_lock);
 }
 
 static void
@@ -1279,7 +1279,7 @@ try_steal (MonoWSQ *local_wsq, gpointer *data, gboolean retry)
                if (mono_runtime_is_shutting_down ())
                        return;
 
-               EnterCriticalSection (&wsqs_lock);
+               mono_mutex_lock (&wsqs_lock);
                for (i = 0; wsqs != NULL && i < wsqs->len; i++) {
                        MonoWSQ *wsq;
 
@@ -1288,11 +1288,11 @@ try_steal (MonoWSQ *local_wsq, gpointer *data, gboolean retry)
                                continue;
                        mono_wsq_try_steal (wsqs->pdata [i], data, ms);
                        if (*data != NULL) {
-                               LeaveCriticalSection (&wsqs_lock);
+                               mono_mutex_unlock (&wsqs_lock);
                                return;
                        }
                }
-               LeaveCriticalSection (&wsqs_lock);
+               mono_mutex_unlock (&wsqs_lock);
                ms += 10;
        } while (retry && ms < 11);
 }
old mode 100755 (executable)
new mode 100644 (file)
index 0867b3d..d29cb54
@@ -120,19 +120,19 @@ typedef struct {
 #define UICULTURES_START_IDX NUM_CACHED_CULTURES
 
 /* Controls access to the 'threads' hash table */
-#define mono_threads_lock() EnterCriticalSection (&threads_mutex)
-#define mono_threads_unlock() LeaveCriticalSection (&threads_mutex)
-static CRITICAL_SECTION threads_mutex;
+#define mono_threads_lock() mono_mutex_lock (&threads_mutex)
+#define mono_threads_unlock() mono_mutex_unlock (&threads_mutex)
+static mono_mutex_t threads_mutex;
 
 /* Controls access to context static data */
-#define mono_contexts_lock() EnterCriticalSection (&contexts_mutex)
-#define mono_contexts_unlock() LeaveCriticalSection (&contexts_mutex)
-static CRITICAL_SECTION contexts_mutex;
+#define mono_contexts_lock() mono_mutex_lock (&contexts_mutex)
+#define mono_contexts_unlock() mono_mutex_unlock (&contexts_mutex)
+static mono_mutex_t contexts_mutex;
 
 /* Controls access to the 'joinable_threads' hash table */
-#define joinable_threads_lock() EnterCriticalSection (&joinable_threads_mutex)
-#define joinable_threads_unlock() LeaveCriticalSection (&joinable_threads_mutex)
-static CRITICAL_SECTION joinable_threads_mutex;
+#define joinable_threads_lock() mono_mutex_lock (&joinable_threads_mutex)
+#define joinable_threads_unlock() mono_mutex_unlock (&joinable_threads_mutex)
+static mono_mutex_t joinable_threads_mutex;
 
 /* Holds current status of static data heap */
 static StaticDataInfo thread_static_info;
@@ -208,9 +208,9 @@ static MonoException* mono_thread_execute_interruption (MonoInternalThread *thre
 static void ref_stack_destroy (gpointer rs);
 
 /* Spin lock for InterlockedXXX 64 bit functions */
-#define mono_interlocked_lock() EnterCriticalSection (&interlocked_mutex)
-#define mono_interlocked_unlock() LeaveCriticalSection (&interlocked_mutex)
-static CRITICAL_SECTION interlocked_mutex;
+#define mono_interlocked_lock() mono_mutex_lock (&interlocked_mutex)
+#define mono_interlocked_unlock() mono_mutex_unlock (&interlocked_mutex)
+static mono_mutex_t interlocked_mutex;
 
 /* global count of thread interruptions requested */
 static gint32 thread_interruption_requested = 0;
@@ -332,19 +332,19 @@ static gboolean handle_remove(MonoInternalThread *thread)
 
 static void ensure_synch_cs_set (MonoInternalThread *thread)
 {
-       CRITICAL_SECTION *synch_cs;
+       mono_mutex_t *synch_cs;
 
        if (thread->synch_cs != NULL) {
                return;
        }
 
-       synch_cs = g_new0 (CRITICAL_SECTION, 1);
-       InitializeCriticalSection (synch_cs);
+       synch_cs = g_new0 (mono_mutex_t, 1);
+       mono_mutex_init_recursive (synch_cs);
 
        if (InterlockedCompareExchangePointer ((gpointer *)&thread->synch_cs,
                                               synch_cs, NULL) != NULL) {
                /* Another thread must have installed this CS */
-               DeleteCriticalSection (synch_cs);
+               mono_mutex_destroy (synch_cs);
                g_free (synch_cs);
        }
 }
@@ -356,13 +356,13 @@ lock_thread (MonoInternalThread *thread)
                ensure_synch_cs_set (thread);
 
        g_assert (thread->synch_cs);
-       EnterCriticalSection (thread->synch_cs);
+       mono_mutex_lock (thread->synch_cs);
 }
 
 static inline void
 unlock_thread (MonoInternalThread *thread)
 {
-       LeaveCriticalSection (thread->synch_cs);
+       mono_mutex_unlock (thread->synch_cs);
 }
 
 /*
@@ -529,8 +529,8 @@ create_internal_thread (void)
        vt = mono_class_vtable (mono_get_root_domain (), mono_defaults.internal_thread_class);
        thread = (MonoInternalThread*)mono_gc_alloc_mature (vt);
 
-       thread->synch_cs = g_new0 (CRITICAL_SECTION, 1);
-       InitializeCriticalSection (thread->synch_cs);
+       thread->synch_cs = g_new0 (mono_mutex_t, 1);
+       mono_mutex_init_recursive (thread->synch_cs);
 
        thread->apartment_state = ThreadApartmentState_Unknown;
        thread->managed_id = get_next_managed_thread_id ();
@@ -1079,9 +1079,9 @@ ves_icall_System_Threading_InternalThread_Thread_free_internal (MonoInternalThre
                CloseHandle (thread);
 
        if (this->synch_cs) {
-               CRITICAL_SECTION *synch_cs = this->synch_cs;
+               mono_mutex_t *synch_cs = this->synch_cs;
                this->synch_cs = NULL;
-               DeleteCriticalSection (synch_cs);
+               mono_mutex_destroy (synch_cs);
                g_free (synch_cs);
        }
 
@@ -2536,10 +2536,10 @@ mono_thread_init_tls (void)
 void mono_thread_init (MonoThreadStartCB start_cb,
                       MonoThreadAttachCB attach_cb)
 {
-       InitializeCriticalSection(&threads_mutex);
-       InitializeCriticalSection(&interlocked_mutex);
-       InitializeCriticalSection(&contexts_mutex);
-       InitializeCriticalSection(&joinable_threads_mutex);
+       mono_mutex_init_recursive(&threads_mutex);
+       mono_mutex_init_recursive(&interlocked_mutex);
+       mono_mutex_init_recursive(&contexts_mutex);
+       mono_mutex_init_recursive(&joinable_threads_mutex);
        
        background_change_event = CreateEvent (NULL, TRUE, FALSE, NULL);
        g_assert(background_change_event != NULL);
@@ -2580,11 +2580,11 @@ void mono_thread_cleanup (void)
         * critical sections can be locked when mono_thread_cleanup is
         * called.
         */
-       DeleteCriticalSection (&threads_mutex);
-       DeleteCriticalSection (&interlocked_mutex);
-       DeleteCriticalSection (&contexts_mutex);
-       DeleteCriticalSection (&delayed_free_table_mutex);
-       DeleteCriticalSection (&small_id_mutex);
+       mono_mutex_destroy (&threads_mutex);
+       mono_mutex_destroy (&interlocked_mutex);
+       mono_mutex_destroy (&contexts_mutex);
+       mono_mutex_destroy (&delayed_free_table_mutex);
+       mono_mutex_destroy (&small_id_mutex);
        CloseHandle (background_change_event);
 #endif
 
index 41242c6b5e9fda1afca864de7c71a3ecc6d0df82..bab57abf876b973ceb9ded37fb05289e927be4fe 100644 (file)
@@ -78,7 +78,7 @@ tp_epoll_modify (gpointer p, int fd, int operation, int events, gboolean is_new)
                        }
                }
        }
-       LeaveCriticalSection (&socket_io_data->io_lock);
+       mono_mutex_unlock (&socket_io_data->io_lock);
 }
 
 static void
@@ -129,10 +129,10 @@ tp_epoll_wait (gpointer p)
                        return;
                }
 
-               EnterCriticalSection (&socket_io_data->io_lock);
+               mono_mutex_lock (&socket_io_data->io_lock);
                if (socket_io_data->inited == 3) {
                        g_free (events);
-                       LeaveCriticalSection (&socket_io_data->io_lock);
+                       mono_mutex_unlock (&socket_io_data->io_lock);
                        return; /* cleanup called */
                }
 
@@ -175,7 +175,7 @@ tp_epoll_wait (gpointer p)
                                epoll_ctl (epollfd, EPOLL_CTL_DEL, fd, evt);
                        }
                }
-               LeaveCriticalSection (&socket_io_data->io_lock);
+               mono_mutex_unlock (&socket_io_data->io_lock);
                threadpool_append_jobs (&async_io_tp, (MonoObject **) async_results, nresults);
                mono_gc_bzero_aligned (async_results, sizeof (gpointer) * nresults);
        }
index f2ca4f4158dc3304fb6eedac61500894d30778b1..1cbd26f26e654e0fb38ab55da80a31ab51df94b0 100644 (file)
@@ -59,7 +59,7 @@ tp_kqueue_modify (gpointer p, int fd, int operation, int events, gboolean is_new
                EV_SET (&evt, fd, EVFILT_WRITE, EV_ADD | EV_ENABLE | EV_ONESHOT, 0, 0, 0);
                kevent_change (data->fd, &evt, "ADD write");
        }
-       LeaveCriticalSection (&socket_io_data->io_lock);
+       mono_mutex_unlock (&socket_io_data->io_lock);
 }
 
 static void
@@ -110,10 +110,10 @@ tp_kqueue_wait (gpointer p)
                        return;
                }
 
-               EnterCriticalSection (&socket_io_data->io_lock);
+               mono_mutex_lock (&socket_io_data->io_lock);
                if (socket_io_data->inited == 3) {
                        g_free (events);
-                       LeaveCriticalSection (&socket_io_data->io_lock);
+                       mono_mutex_unlock (&socket_io_data->io_lock);
                        return; /* cleanup called */
                }
 
@@ -155,7 +155,7 @@ tp_kqueue_wait (gpointer p)
                                mono_g_hash_table_remove (socket_io_data->sock_to_state, GINT_TO_POINTER (fd));
                        }
                }
-               LeaveCriticalSection (&socket_io_data->io_lock);
+               mono_mutex_unlock (&socket_io_data->io_lock);
                threadpool_append_jobs (&async_io_tp, (MonoObject **) async_results, nresults);
                mono_gc_bzero_aligned (async_results, sizeof (gpointer) * nresults);
        }
index e44e338598837532e6bd5d3e80f4c54dd67efbf3..aa1077bf07f9db1de24f085f9bae198341f27713 100644 (file)
@@ -84,7 +84,7 @@ tp_poll_modify (gpointer p, int fd, int operation, int events, gboolean is_new)
        socket_io_data = p;
        data = socket_io_data->event_data;
 
-       LeaveCriticalSection (&socket_io_data->io_lock);
+       mono_mutex_unlock (&socket_io_data->io_lock);
        
        MONO_SEM_WAIT (&data->new_sem);
        INIT_POLLFD (&data->newpfd, GPOINTER_TO_INT (fd), events);
@@ -270,11 +270,11 @@ tp_poll_wait (gpointer p)
                if (nsock == 0)
                        continue;
 
-               EnterCriticalSection (&socket_io_data->io_lock);
+               mono_mutex_lock (&socket_io_data->io_lock);
                if (socket_io_data->inited == 3) {
                        g_free (pfds);
                        mono_ptr_array_destroy (async_results);
-                       LeaveCriticalSection (&socket_io_data->io_lock);
+                       mono_mutex_unlock (&socket_io_data->io_lock);
                        return; /* cleanup called */
                }
 
@@ -314,7 +314,7 @@ tp_poll_wait (gpointer p)
                                        maxfd--;
                        }
                }
-               LeaveCriticalSection (&socket_io_data->io_lock);
+               mono_mutex_unlock (&socket_io_data->io_lock);
                threadpool_append_jobs (&async_io_tp, (MonoObject **) async_results.data, nresults);
                mono_ptr_array_clear (async_results);
        }
index 464d8a4521be6944f04476d5b992ad2f095ab50c..d1d3dbf19302aed9da7168ddd2ca0fbfd33d2da9 100644 (file)
@@ -7121,12 +7121,7 @@ mini_create_jit_domain_info (MonoDomain *domain)
        info->jit_trampoline_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
        info->delegate_trampoline_hash = g_hash_table_new (class_method_pair_hash, class_method_pair_equal);
        info->llvm_vcall_trampoline_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
-#ifdef HOST_WIN32
-       // FIXME:
        info->runtime_invoke_hash = mono_conc_hashtable_new_full (&domain->lock, mono_aligned_addr_hash, NULL, NULL, runtime_invoke_info_free);
-#else
-       info->runtime_invoke_hash = mono_conc_hashtable_new_full (&domain->lock.mutex, mono_aligned_addr_hash, NULL, NULL, runtime_invoke_info_free);
-#endif
        info->seq_points = g_hash_table_new_full (mono_aligned_addr_hash, NULL, NULL, seq_point_info_free);
        info->arch_seq_points = g_hash_table_new (mono_aligned_addr_hash, NULL);
        info->jump_target_hash = g_hash_table_new (NULL, NULL);
@@ -7809,7 +7804,7 @@ mini_cleanup (MonoDomain *domain)
 
        mono_mutex_destroy (&jit_mutex);
 
-       DeleteCriticalSection (&mono_delegate_section);
+       mono_mutex_destroy (&mono_delegate_section);
 
        mono_code_manager_cleanup ();
 
old mode 100755 (executable)
new mode 100644 (file)
index b412e77d7d535ed088203c81a839caa74c545133..a662261270d47b94cce659c7f1ad317a89df065b 100644 (file)
@@ -46,7 +46,7 @@ static volatile gint32 overflow_busy [HAZARD_TABLE_OVERFLOW];
 static MonoLockFreeArrayQueue delayed_free_queue = MONO_LOCK_FREE_ARRAY_QUEUE_INIT (sizeof (DelayedFreeItem));
 
 /* The table for small ID assignment */
-static CRITICAL_SECTION small_id_mutex;
+static mono_mutex_t small_id_mutex;
 static int small_id_next;
 static int highest_small_id = -1;
 static MonoBitSet *small_id_table;
@@ -63,7 +63,7 @@ mono_thread_small_id_alloc (void)
 {
        int i, id = -1;
 
-       EnterCriticalSection (&small_id_mutex);
+       mono_mutex_lock (&small_id_mutex);
 
        if (!small_id_table)
                small_id_table = mono_bitset_new (1, 0);
@@ -125,7 +125,7 @@ mono_thread_small_id_alloc (void)
                mono_memory_write_barrier ();
        }
 
-       LeaveCriticalSection (&small_id_mutex);
+       mono_mutex_unlock (&small_id_mutex);
 
        return id;
 }
@@ -134,13 +134,13 @@ void
 mono_thread_small_id_free (int id)
 {
        /* MonoBitSet operations are not atomic. */
-       EnterCriticalSection (&small_id_mutex);
+       mono_mutex_lock (&small_id_mutex);
 
        g_assert (id >= 0 && id < small_id_table->size);
        g_assert (mono_bitset_test_fast (small_id_table, id));
        mono_bitset_clear_fast (small_id_table, id);
 
-       LeaveCriticalSection (&small_id_mutex);
+       mono_mutex_unlock (&small_id_mutex);
 }
 
 static gboolean
@@ -345,7 +345,7 @@ mono_thread_smr_init (void)
 {
        int i;
 
-       InitializeCriticalSection(&small_id_mutex);
+       mono_mutex_init_recursive(&small_id_mutex);
        mono_counters_register ("Hazardous pointers", MONO_COUNTER_JIT | MONO_COUNTER_INT, &hazardous_pointer_count);
 
        for (i = 0; i < HAZARD_TABLE_OVERFLOW; ++i) {
index c8f746825355aff06999f7fb40de638b2f571403..5356876b3236b8733f7f8fac67f09b31e7a408e2 100644 (file)
@@ -231,7 +231,7 @@ nacl_inverse_modify_patch_target (unsigned char *target)
 
 #define VALLOC_FREELIST_SIZE 16
 
-static CRITICAL_SECTION valloc_mutex;
+static mono_mutex_t valloc_mutex;
 static GHashTable *valloc_freelists;
 
 static void*
@@ -241,14 +241,14 @@ codechunk_valloc (void *preferred, guint32 size)
        GSList *freelist;
 
        if (!valloc_freelists) {
-               InitializeCriticalSection (&valloc_mutex);
+               mono_mutex_init_recursive (&valloc_mutex);
                valloc_freelists = g_hash_table_new (NULL, NULL);
        }
 
        /*
         * Keep a small freelist of memory blocks to decrease pressure on the kernel memory subsystem to avoid #3321.
         */
-       EnterCriticalSection (&valloc_mutex);
+       mono_mutex_lock (&valloc_mutex);
        freelist = g_hash_table_lookup (valloc_freelists, GUINT_TO_POINTER (size));
        if (freelist) {
                ptr = freelist->data;
@@ -260,7 +260,7 @@ codechunk_valloc (void *preferred, guint32 size)
                if (!ptr && preferred)
                        ptr = mono_valloc (NULL, size, MONO_PROT_RWX | ARCH_MAP_FLAGS);
        }
-       LeaveCriticalSection (&valloc_mutex);
+       mono_mutex_unlock (&valloc_mutex);
        return ptr;
 }
 
@@ -269,7 +269,7 @@ codechunk_vfree (void *ptr, guint32 size)
 {
        GSList *freelist;
 
-       EnterCriticalSection (&valloc_mutex);
+       mono_mutex_lock (&valloc_mutex);
        freelist = g_hash_table_lookup (valloc_freelists, GUINT_TO_POINTER (size));
        if (!freelist || g_slist_length (freelist) < VALLOC_FREELIST_SIZE) {
                freelist = g_slist_prepend (freelist, ptr);
@@ -277,7 +277,7 @@ codechunk_vfree (void *ptr, guint32 size)
        } else {
                mono_vfree (ptr, size);
        }
-       LeaveCriticalSection (&valloc_mutex);
+       mono_mutex_unlock (&valloc_mutex);
 }              
 
 static void