X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Futils%2Fmono-tls.h;h=a3751ea6e38b7ee2bbc60aaa1390f35d1eb2b88d;hb=379436fcf5258ac83c27c0dc469eb6cfc80e0b7b;hp=11ece6d584b5ad8ee8223b49b2bdb94cfc0e8cf9;hpb=f80ea372c0eea5c02314691d0fa14996fb778a3a;p=mono.git diff --git a/mono/utils/mono-tls.h b/mono/utils/mono-tls.h index 11ece6d584b..a3751ea6e38 100644 --- a/mono/utils/mono-tls.h +++ b/mono/utils/mono-tls.h @@ -4,12 +4,40 @@ * Author: * Rodrigo Kumpera (kumpera@gmail.com) * - * (C) 2011 Novell, Inc + * Copyright 2011 Novell, Inc (http://www.novell.com) + * Copyright 2011 Xamarin, Inc (http://www.xamarin.com) + * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ #ifndef __MONO_TLS_H__ #define __MONO_TLS_H__ +#include +#include + +/* TLS entries used by the runtime */ +typedef enum { + /* mono_thread_internal_current () */ + TLS_KEY_THREAD = 0, + TLS_KEY_JIT_TLS = 1, + /* mono_domain_get () */ + TLS_KEY_DOMAIN = 2, + TLS_KEY_LMF = 3, + TLS_KEY_SGEN_THREAD_INFO = 4, + TLS_KEY_LMF_ADDR = 5, + TLS_KEY_NUM = 6 +} MonoTlsKey; + +#ifdef HAVE_KW_THREAD +#define USE_KW_THREAD +#endif + +#if defined(USE_KW_THREAD) +#define HAVE_GET_TLS_ADDR +#elif defined(TARGET_MACH) && (defined(TARGET_X86) || defined(TARGET_AMD64)) +/* mono_mach_get_tls_address_from_thread is untested for arm/arm64 */ +#define HAVE_GET_TLS_ADDR +#endif #ifdef HOST_WIN32 @@ -31,7 +59,7 @@ static inline int mono_native_tls_alloc (MonoNativeTlsKey *key, void *destructor) { - return pthread_key_create (key, destructor) == 0; + return pthread_key_create (key, (void (*)(void*)) destructor) == 0; } static inline void @@ -48,5 +76,26 @@ mono_native_tls_set_value (MonoNativeTlsKey key, gpointer value) #endif /* HOST_WIN32 */ +void mono_tls_init_gc_keys (void); +void mono_tls_init_runtime_keys (void); +void mono_tls_free_keys (void); +gint32 mono_tls_get_tls_offset (MonoTlsKey key); +gpointer mono_tls_get_tls_getter (MonoTlsKey key, gboolean name); +gpointer mono_tls_get_tls_setter (MonoTlsKey key, gboolean name); +gpointer mono_tls_get_tls_addr (MonoTlsKey key); + +gpointer mono_tls_get_thread (void); +gpointer mono_tls_get_jit_tls (void); +gpointer mono_tls_get_domain (void); +gpointer mono_tls_get_lmf (void); +gpointer mono_tls_get_sgen_thread_info (void); +gpointer mono_tls_get_lmf_addr (void); + +void mono_tls_set_thread (gpointer value); +void mono_tls_set_jit_tls (gpointer value); +void mono_tls_set_domain (gpointer value); +void mono_tls_set_lmf (gpointer value); +void mono_tls_set_sgen_thread_info (gpointer value); +void mono_tls_set_lmf_addr (gpointer value); #endif /* __MONO_TLS_H__ */