2005-09-23 18:33:47 +02:00
|
|
|
dnl Check whether the target supports TLS.
|
|
|
|
AC_DEFUN([GCC_CHECK_TLS], [
|
2006-09-19 03:48:06 +02:00
|
|
|
GCC_ENABLE(tls, yes, [], [Use thread-local storage])
|
2005-09-23 18:33:47 +02:00
|
|
|
AC_CACHE_CHECK([whether the target supports thread-local storage],
|
|
|
|
have_tls, [
|
|
|
|
AC_RUN_IFELSE([__thread int a; int b; int main() { return a = b; }],
|
|
|
|
[dnl If the test case passed with dynamic linking, try again with
|
2006-12-04 12:10:38 +01:00
|
|
|
dnl static linking, but only if static linking is supported (not
|
|
|
|
dnl on Solaris 10). This fails with some older Red Hat releases.
|
2005-09-23 18:33:47 +02:00
|
|
|
save_LDFLAGS="$LDFLAGS"
|
|
|
|
LDFLAGS="-static $LDFLAGS"
|
2006-12-04 12:10:38 +01:00
|
|
|
AC_LINK_IFELSE([int main() { return 0; }],
|
|
|
|
AC_RUN_IFELSE([__thread int a; int b; int main() { return a = b; }],
|
|
|
|
[have_tls=yes], [have_tls=no],[]),
|
|
|
|
[have_tls=yes])
|
2005-09-23 18:33:47 +02:00
|
|
|
LDFLAGS="$save_LDFLAGS"],
|
|
|
|
[have_tls=no],
|
2006-11-13 21:35:20 +01:00
|
|
|
[AC_LINK_IFELSE([__thread int a; int b; int main() { return a = b; }],
|
|
|
|
[have_tls=yes], [have_tls=no])]
|
2005-09-23 18:33:47 +02:00
|
|
|
)])
|
|
|
|
if test "$enable_tls $have_tls" = "yes yes"; then
|
|
|
|
AC_DEFINE(HAVE_TLS, 1,
|
|
|
|
[Define to 1 if the target supports thread-local storage.])
|
|
|
|
fi])
|