From 2875cbd25a4e0f69d0ce054dd4fd46e4b25702ae Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Wed, 10 Aug 2011 18:34:47 +0200 Subject: [PATCH] Get rid of the macros in mono-tls.h to fix many warnings. --- mono/metadata/domain.c | 2 +- mono/metadata/loader.c | 4 ++-- mono/metadata/marshal.c | 4 ++-- mono/metadata/mono-wsq.c | 2 +- mono/metadata/threads.c | 2 +- mono/mini/debugger-agent.c | 2 +- mono/mini/mini-amd64.c | 6 +++--- mono/mini/mini-llvm.c | 2 +- mono/mini/mini.c | 2 +- mono/utils/mono-threads.c | 6 +++--- mono/utils/mono-tls.h | 23 +++++++++++++++++++---- 11 files changed, 35 insertions(+), 20 deletions(-) diff --git a/mono/metadata/domain.c b/mono/metadata/domain.c index 6dd6dadb78b..9210a881a5f 100644 --- a/mono/metadata/domain.c +++ b/mono/metadata/domain.c @@ -1241,7 +1241,7 @@ mono_init_internal (const char *filename, const char *exe_filename, const char * mono_gc_base_init (); MONO_FAST_TLS_INIT (tls_appdomain); - mono_native_tls_alloc (appdomain_thread_id, NULL); + mono_native_tls_alloc (&appdomain_thread_id, NULL); InitializeCriticalSection (&appdomains_mutex); diff --git a/mono/metadata/loader.c b/mono/metadata/loader.c index c2263d80dc7..3f0fd5b7b9f 100644 --- a/mono/metadata/loader.c +++ b/mono/metadata/loader.c @@ -85,8 +85,8 @@ mono_loader_init () InitializeCriticalSection (&loader_mutex); loader_lock_inited = TRUE; - mono_native_tls_alloc (loader_error_thread_id, NULL); - mono_native_tls_alloc (loader_lock_nest_id, NULL); + mono_native_tls_alloc (&loader_error_thread_id, NULL); + mono_native_tls_alloc (&loader_lock_nest_id, NULL); mono_counters_register ("Inflated signatures size", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &inflated_signatures_size); diff --git a/mono/metadata/marshal.c b/mono/metadata/marshal.c index 5ade3bb294a..b00cb0d2378 100644 --- a/mono/metadata/marshal.c +++ b/mono/metadata/marshal.c @@ -202,8 +202,8 @@ mono_marshal_init (void) module_initialized = TRUE; InitializeCriticalSection (&marshal_mutex); marshal_mutex_initialized = TRUE; - mono_native_tls_alloc (last_error_tls_id, NULL); - mono_native_tls_alloc (load_type_info_tls_id, NULL); + mono_native_tls_alloc (&last_error_tls_id, NULL); + mono_native_tls_alloc (&load_type_info_tls_id, NULL); register_icall (ves_icall_System_Threading_Thread_ResetAbort, "ves_icall_System_Threading_Thread_ResetAbort", "void", TRUE); register_icall (mono_marshal_string_to_utf16, "mono_marshal_string_to_utf16", "ptr obj", FALSE); diff --git a/mono/metadata/mono-wsq.c b/mono/metadata/mono-wsq.c index 24b777153a9..1a110ec3a15 100644 --- a/mono/metadata/mono-wsq.c +++ b/mono/metadata/mono-wsq.c @@ -35,7 +35,7 @@ mono_wsq_init () if (wsq_tlskey_inited) return; - mono_native_tls_alloc (wsq_tlskey, NULL); + mono_native_tls_alloc (&wsq_tlskey, NULL); wsq_tlskey_inited = TRUE; } diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c index c7c6a78f5cb..cd17b07dc9e 100644 --- a/mono/metadata/threads.c +++ b/mono/metadata/threads.c @@ -2432,7 +2432,7 @@ void mono_thread_init (MonoThreadStartCB start_cb, mono_init_static_data_info (&context_static_info); MONO_FAST_TLS_INIT (tls_current_object); - mono_native_tls_alloc (current_object_key, NULL); + mono_native_tls_alloc (¤t_object_key, NULL); THREAD_DEBUG (g_message ("%s: Allocated current_object_key %d", __func__, current_object_key)); mono_thread_start_cb = start_cb; diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 433b1061ef2..2901bde1b69 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -850,7 +850,7 @@ mono_debugger_agent_init (void) mono_profiler_install_jit_end (jit_end); mono_profiler_install_method_invoke (start_runtime_invoke, end_runtime_invoke); - mono_native_tls_alloc (debugger_tls_id, NULL); + mono_native_tls_alloc (&debugger_tls_id, NULL); thread_to_tls = mono_g_hash_table_new_type (NULL, NULL, MONO_HASH_KEY_GC); MONO_GC_REGISTER_ROOT_FIXED (thread_to_tls); diff --git a/mono/mini/mini-amd64.c b/mono/mini/mini-amd64.c index 5185922fa96..8855898b289 100644 --- a/mono/mini/mini-amd64.c +++ b/mono/mini/mini-amd64.c @@ -1288,10 +1288,10 @@ mono_arch_init (void) InitializeCriticalSection (&mini_arch_mutex); #if defined(__native_client_codegen__) - mono_native_tls_alloc (nacl_instruction_depth, NULL); + mono_native_tls_alloc (&nacl_instruction_depth, NULL); mono_native_tls_set_value (nacl_instruction_depth, (gpointer)0); - mono_native_tls_alloc (nacl_rex_tag, NULL); - mono_native_tls_alloc (nacl_legacy_prefix_tag, NULL); + mono_native_tls_alloc (&nacl_rex_tag, NULL); + mono_native_tls_alloc (&nacl_legacy_prefix_tag, NULL); #endif #ifdef MONO_ARCH_NOMAP32BIT diff --git a/mono/mini/mini-llvm.c b/mono/mini/mini-llvm.c index ac5adf9f15a..f72eb8a85b6 100644 --- a/mono/mini/mini-llvm.c +++ b/mono/mini/mini-llvm.c @@ -5100,7 +5100,7 @@ add_intrinsics (LLVMModuleRef module) void mono_llvm_init (void) { - mono_native_tls_alloc (current_cfg_tls_id, NULL); + mono_native_tls_alloc (¤t_cfg_tls_id, NULL); } static void diff --git a/mono/mini/mini.c b/mono/mini/mini.c index 74ed84b9b0d..fee8d27496a 100644 --- a/mono/mini/mini.c +++ b/mono/mini/mini.c @@ -6291,7 +6291,7 @@ mini_init (const char *filename, const char *runtime_version) if (!g_thread_supported ()) g_thread_init (NULL); - mono_native_tls_alloc (mono_jit_tls_id, NULL); + mono_native_tls_alloc (&mono_jit_tls_id, NULL); setup_jit_tls_data ((gpointer)-1, mono_thread_abort); if (default_opt & MONO_OPT_AOT) diff --git a/mono/utils/mono-threads.c b/mono/utils/mono-threads.c index 694d019c22a..e68ae12b9e6 100644 --- a/mono/utils/mono-threads.c +++ b/mono/utils/mono-threads.c @@ -243,13 +243,13 @@ mono_threads_init (MonoThreadInfoCallbacks *callbacks, size_t info_size) threads_callbacks = *callbacks; thread_info_size = info_size; #ifdef HOST_WIN32 - res = mono_native_tls_alloc (thread_info_key, NULL); + res = mono_native_tls_alloc (&thread_info_key, NULL); #else - res = mono_native_tls_alloc (thread_info_key, unregister_thread); + res = mono_native_tls_alloc (&thread_info_key, unregister_thread); #endif g_assert (res); - res = mono_native_tls_alloc (small_id_key, NULL); + res = mono_native_tls_alloc (&small_id_key, NULL); g_assert (res); InitializeCriticalSection (&global_suspend_lock); diff --git a/mono/utils/mono-tls.h b/mono/utils/mono-tls.h index 52ce6f049e7..11ece6d584b 100644 --- a/mono/utils/mono-tls.h +++ b/mono/utils/mono-tls.h @@ -16,7 +16,7 @@ #include #define MonoNativeTlsKey DWORD -#define mono_native_tls_alloc(key,destructor) ((key = TlsAlloc ()) != TLS_OUT_OF_INDEXES && destructor == NULL) +#define mono_native_tls_alloc(key,destructor) ((*(key) = TlsAlloc ()) != TLS_OUT_OF_INDEXES && destructor == NULL) #define mono_native_tls_free TlsFree #define mono_native_tls_set_value TlsSetValue #define mono_native_tls_get_value TlsGetValue @@ -26,11 +26,26 @@ #include #define MonoNativeTlsKey pthread_key_t -#define mono_native_tls_alloc(key,destructor) (pthread_key_create (&key, destructor) == 0) -#define mono_native_tls_free pthread_key_delete -#define mono_native_tls_set_value(k,v) (!pthread_setspecific ((k), (v))) #define mono_native_tls_get_value pthread_getspecific +static inline int +mono_native_tls_alloc (MonoNativeTlsKey *key, void *destructor) +{ + return pthread_key_create (key, destructor) == 0; +} + +static inline void +mono_native_tls_free (MonoNativeTlsKey key) +{ + pthread_key_delete (key); +} + +static inline int +mono_native_tls_set_value (MonoNativeTlsKey key, gpointer value) +{ + return !pthread_setspecific (key, value); +} + #endif /* HOST_WIN32 */ -- 2.25.1