Backport utils/mono-tls.h.

This commit is contained in:
Rodrigo Kumpera committed 2011-12-06 01:57:51 -02:00
1 parent 1f505f2ebb
commit b4c110c021
2 files changed
+54

No files matched your search

+1
View File
@@ -77,6 +77,7 @@ monoutils_sources = \
valgrind.h \
mach-support.c \
mach-support.h \
mach-tls.h \
memcheck.h
arch_sources =
+53
View File
@@ -0,0 +1,53 @@
/*
* mono-tls.h: Low-level TLS support
*
* Author:
* Rodrigo Kumpera ([email protected])
*
* Copyright 2011 Novell, Inc (http://www.novell.com)
* Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
*/
#ifndef __MONO_TLS_H__
#define __MONO_TLS_H__
#ifdef HOST_WIN32
#include <windows.h>
#define MonoNativeTlsKey DWORD
#define mono_native_tls_alloc(key,destructor) ((*(key) = TlsAlloc ()) != TLS_OUT_OF_INDEXES && destructor == NULL)
#define mono_native_tls_free TlsFree
#define mono_native_tls_set_value TlsSetValue
#define mono_native_tls_get_value TlsGetValue
#else
#include <pthread.h>
#define MonoNativeTlsKey pthread_key_t
#define mono_native_tls_get_value pthread_getspecific
static inline int
mono_native_tls_alloc (MonoNativeTlsKey *key, void *destructor)
{
return pthread_key_create (key, destructor) == 0;
}
static inline void
mono_native_tls_free (MonoNativeTlsKey key)
{
pthread_key_delete (key);
}
static inline int
mono_native_tls_set_value (MonoNativeTlsKey key, gpointer value)
{
return !pthread_setspecific (key, value);
}
#endif /* HOST_WIN32 */
#endif /* __MONO_TLS_H__ */