Expand TLS support beyond __thread to __declspec(thread)

This code was pretty much coppied from a similar commit that I made to
xorg-server in April.

cf: xorg/xserver: bb4d145bd25e2aee988b100ecf1105ea3b6a40b8

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
This commit is contained in:
Jeremy Huddleston 2012-03-08 09:41:34 -08:00 committed by Søren Sandmann Pedersen
parent 61d999b910
commit a069da6c66
2 changed files with 16 additions and 14 deletions

View File

@ -788,26 +788,28 @@ fi
dnl ===================================== dnl =====================================
dnl Thread local storage dnl Thread local storage
support_for__thread=no AC_MSG_CHECKING(for thread local storage (TLS) support)
AC_CACHE_VAL(ac_cv_tls, [
AC_MSG_CHECKING(for __thread) ac_cv_tls=none
AC_LINK_IFELSE([AC_LANG_SOURCE([[ keywords="__thread __declspec(thread)"
for kw in $keywords ; do
AC_TRY_COMPILE([
#if defined(__MINGW32__) && !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) #if defined(__MINGW32__) && !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
#error This MinGW version has broken __thread support #error This MinGW version has broken __thread support
#endif #endif
#ifdef __OpenBSD__ #ifdef __OpenBSD__
#error OpenBSD has broken __thread support #error OpenBSD has broken __thread support
#endif #endif
static __thread int x ;
int main () { x = 123; return x; }
]])], support_for__thread=yes)
if test $support_for__thread = yes; then int $kw test;], [], ac_cv_tls=$kw)
AC_DEFINE([TOOLCHAIN_SUPPORTS__THREAD],[],[Whether the tool chain supports __thread]) done
])
AC_MSG_RESULT($ac_cv_tls)
if test "$ac_cv_tls" != "none"; then
AC_DEFINE_UNQUOTED([TLS], $pixman_tls, [The compiler supported TLS storage class])
fi fi
AC_MSG_RESULT($support_for__thread)
dnl dnl
dnl posix tls dnl posix tls
dnl dnl
@ -858,7 +860,7 @@ AC_DEFUN([PIXMAN_CHECK_PTHREAD],[dnl
fi fi
]) ])
if test $support_for__thread = no; then if test $ac_cv_tls = none ; then
support_for_pthread_setspecific=no support_for_pthread_setspecific=no
AC_MSG_CHECKING(for pthread_setspecific) AC_MSG_CHECKING(for pthread_setspecific)

View File

@ -97,10 +97,10 @@
# define PIXMAN_GET_THREAD_LOCAL(name) \ # define PIXMAN_GET_THREAD_LOCAL(name) \
(&name) (&name)
#elif defined(TOOLCHAIN_SUPPORTS__THREAD) #elif defined(TLS)
# define PIXMAN_DEFINE_THREAD_LOCAL(type, name) \ # define PIXMAN_DEFINE_THREAD_LOCAL(type, name) \
static __thread type name static TLS type name
# define PIXMAN_GET_THREAD_LOCAL(name) \ # define PIXMAN_GET_THREAD_LOCAL(name) \
(&name) (&name)