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)
11 #ifndef __MONO_TLS_H__
12 #define __MONO_TLS_H__
16 /* TLS entries used by the runtime */
18 /* mono_thread_internal_current () */
21 /* mono_domain_get () */
24 TLS_KEY_SGEN_THREAD_INFO
= 4,
25 TLS_KEY_SGEN_TLAB_NEXT_ADDR
= 5,
26 TLS_KEY_SGEN_TLAB_TEMP_END
= 6,
27 TLS_KEY_BOEHM_GC_THREAD
= 7,
36 #define MonoNativeTlsKey DWORD
37 #define mono_native_tls_alloc(key,destructor) ((*(key) = TlsAlloc ()) != TLS_OUT_OF_INDEXES && destructor == NULL)
38 #define mono_native_tls_free TlsFree
39 #define mono_native_tls_set_value TlsSetValue
40 #define mono_native_tls_get_value TlsGetValue
46 #define MonoNativeTlsKey pthread_key_t
47 #define mono_native_tls_get_value pthread_getspecific
50 mono_native_tls_alloc (MonoNativeTlsKey
*key
, void *destructor
)
52 return pthread_key_create (key
, destructor
) == 0;
56 mono_native_tls_free (MonoNativeTlsKey key
)
58 pthread_key_delete (key
);
62 mono_native_tls_set_value (MonoNativeTlsKey key
, gpointer value
)
64 return !pthread_setspecific (key
, value
);
67 #endif /* HOST_WIN32 */
69 int mono_tls_key_get_offset (MonoTlsKey key
);
70 void mono_tls_key_set_offset (MonoTlsKey key
, int offset
);
72 #endif /* __MONO_TLS_H__ */