[xbuild] Pick the correct base path for target frameworks.
[mono.git] / mono / utils / mono-tls.h
1 /*
2  * mono-tls.h: Low-level TLS support
3  *
4  * Author:
5  *      Rodrigo Kumpera (kumpera@gmail.com)
6  *
7  * Copyright 2011 Novell, Inc (http://www.novell.com)
8  * Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
9  */
10
11 #ifndef __MONO_TLS_H__
12 #define __MONO_TLS_H__
13
14
15 #ifdef HOST_WIN32
16
17 #include <windows.h>
18
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
24
25 #else
26
27 #include <pthread.h>
28
29 #define MonoNativeTlsKey pthread_key_t
30 #define mono_native_tls_get_value pthread_getspecific
31
32 static inline int
33 mono_native_tls_alloc (MonoNativeTlsKey *key, void *destructor)
34 {
35         return pthread_key_create (key, destructor) == 0;
36 }
37
38 static inline void
39 mono_native_tls_free (MonoNativeTlsKey key)
40 {
41         pthread_key_delete (key);
42 }
43
44 static inline int
45 mono_native_tls_set_value (MonoNativeTlsKey key, gpointer value)
46 {
47         return !pthread_setspecific (key, value);
48 }
49
50 #endif /* HOST_WIN32 */
51
52
53 #endif /* __MONO_TLS_H__ */