Merge pull request #4152 from BrzVlad/misc-gc-altstack
[mono.git] / mono / utils / mono-tls.h
index 485aea76f3a0f3e13bad9b2fb19e579c8e96dc27..a3751ea6e38b7ee2bbc60aaa1390f35d1eb2b88d 100644 (file)
@@ -6,11 +6,13 @@
  *
  * 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 <config.h>
 #include <glib.h>
 
 /* TLS entries used by the runtime */
@@ -22,13 +24,21 @@ typedef enum {
        TLS_KEY_DOMAIN = 2,
        TLS_KEY_LMF = 3,
        TLS_KEY_SGEN_THREAD_INFO = 4,
-       TLS_KEY_SGEN_TLAB_NEXT_ADDR = 5,
-       TLS_KEY_SGEN_TLAB_TEMP_END = 6,
-       TLS_KEY_BOEHM_GC_THREAD = 7,
-       TLS_KEY_LMF_ADDR = 8,
-       TLS_KEY_NUM = 9
+       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
 
 #include <windows.h>
@@ -49,7 +59,7 @@ typedef enum {
 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
@@ -66,7 +76,26 @@ mono_native_tls_set_value (MonoNativeTlsKey key, gpointer value)
 
 #endif /* HOST_WIN32 */
 
-int mono_tls_key_get_offset (MonoTlsKey key);
-void mono_tls_key_set_offset (MonoTlsKey key, int offset);
+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__ */