3 * Low-level TLS support
6 * Rodrigo Kumpera (kumpera@gmail.com)
8 * Copyright 2011 Novell, Inc (http://www.novell.com)
9 * Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
10 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
13 #ifndef __MONO_TLS_H__
14 #define __MONO_TLS_H__
19 /* TLS entries used by the runtime */
21 /* mono_thread_internal_current () */
24 /* mono_domain_get () */
26 TLS_KEY_SGEN_THREAD_INFO = 3,
39 #define MonoNativeTlsKey DWORD
40 #define mono_native_tls_alloc(key,destructor) ((*(key) = TlsAlloc ()) != TLS_OUT_OF_INDEXES && destructor == NULL)
41 #define mono_native_tls_free TlsFree
42 #define mono_native_tls_set_value TlsSetValue
43 #define mono_native_tls_get_value TlsGetValue
49 #define MonoNativeTlsKey pthread_key_t
50 #define mono_native_tls_get_value pthread_getspecific
53 mono_native_tls_alloc (MonoNativeTlsKey *key, void *destructor)
55 return pthread_key_create (key, (void (*)(void*)) destructor) == 0;
59 mono_native_tls_free (MonoNativeTlsKey key)
61 pthread_key_delete (key);
65 mono_native_tls_set_value (MonoNativeTlsKey key, gpointer value)
67 return !pthread_setspecific (key, value);
70 #endif /* HOST_WIN32 */
72 void mono_tls_init_gc_keys (void);
73 void mono_tls_init_runtime_keys (void);
74 void mono_tls_free_keys (void);
75 gint32 mono_tls_get_tls_offset (MonoTlsKey key);
76 gpointer mono_tls_get_tls_getter (MonoTlsKey key, gboolean name);
77 gpointer mono_tls_get_tls_setter (MonoTlsKey key, gboolean name);
79 gpointer mono_tls_get_thread (void);
80 gpointer mono_tls_get_jit_tls (void);
81 gpointer mono_tls_get_domain (void);
82 gpointer mono_tls_get_sgen_thread_info (void);
83 gpointer mono_tls_get_lmf_addr (void);
85 void mono_tls_set_thread (gpointer value);
86 void mono_tls_set_jit_tls (gpointer value);
87 void mono_tls_set_domain (gpointer value);
88 void mono_tls_set_sgen_thread_info (gpointer value);
89 void mono_tls_set_lmf_addr (gpointer value);
91 #endif /* __MONO_TLS_H__ */