2 * mono-tls.h: Low-level TLS support
5 * Rodrigo Kumpera (kumpera@gmail.com)
7 * Copyright 2011 Novell, Inc (http://www.novell.com)
8 * Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
9 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
12 #ifndef __MONO_TLS_H__
13 #define __MONO_TLS_H__
17 /* TLS entries used by the runtime */
19 /* mono_thread_internal_current () */
22 /* mono_domain_get () */
25 TLS_KEY_SGEN_THREAD_INFO = 4,
26 TLS_KEY_SGEN_TLAB_NEXT_ADDR = 5,
27 TLS_KEY_SGEN_TLAB_TEMP_END = 6,
28 TLS_KEY_BOEHM_GC_THREAD = 7,
30 TLS_KEY_SGEN_IN_CRITICAL_REGION_ADDR = 9,
38 #define MonoNativeTlsKey DWORD
39 #define mono_native_tls_alloc(key,destructor) ((*(key) = TlsAlloc ()) != TLS_OUT_OF_INDEXES && destructor == NULL)
40 #define mono_native_tls_free TlsFree
41 #define mono_native_tls_set_value TlsSetValue
42 #define mono_native_tls_get_value TlsGetValue
48 #define MonoNativeTlsKey pthread_key_t
49 #define mono_native_tls_get_value pthread_getspecific
52 mono_native_tls_alloc (MonoNativeTlsKey *key, void *destructor)
54 return pthread_key_create (key, (void (*)(void*)) destructor) == 0;
58 mono_native_tls_free (MonoNativeTlsKey key)
60 pthread_key_delete (key);
64 mono_native_tls_set_value (MonoNativeTlsKey key, gpointer value)
66 return !pthread_setspecific (key, value);
69 #endif /* HOST_WIN32 */
71 int mono_tls_key_get_offset (MonoTlsKey key);
72 void mono_tls_key_set_offset (MonoTlsKey key, int offset);
74 #endif /* __MONO_TLS_H__ */