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);
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);
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);
if (wsq_tlskey_inited)
return;
- mono_native_tls_alloc (wsq_tlskey, NULL);
+ mono_native_tls_alloc (&wsq_tlskey, NULL);
wsq_tlskey_inited = TRUE;
}
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;
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);
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
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
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)
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);
#include <windows.h>
#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
#include <pthread.h>
#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 */