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__
19 #define MonoNativeTlsKey DWORD
20 #define mono_native_tls_alloc(key,destructor) ((*(key) = TlsAlloc ()) != TLS_OUT_OF_INDEXES && destructor == NULL)
21 #define mono_native_tls_free TlsFree
22 #define mono_native_tls_set_value TlsSetValue
23 #define mono_native_tls_get_value TlsGetValue
29 #define MonoNativeTlsKey pthread_key_t
30 #define mono_native_tls_get_value pthread_getspecific
33 mono_native_tls_alloc (MonoNativeTlsKey *key, void *destructor)
35 return pthread_key_create (key, destructor) == 0;
39 mono_native_tls_free (MonoNativeTlsKey key)
41 pthread_key_delete (key);
45 mono_native_tls_set_value (MonoNativeTlsKey key, gpointer value)
47 return !pthread_setspecific (key, value);
50 #endif /* HOST_WIN32 */
53 #endif /* __MONO_TLS_H__ */