|
Packit |
0848f5 |
# ===========================================================================
|
|
Packit |
0848f5 |
# http://www.nongnu.org/autoconf-archive/ax_tls.html
|
|
Packit |
0848f5 |
# ===========================================================================
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# SYNOPSIS
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# AX_TLS
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# DESCRIPTION
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# Provides a test for the compiler support of thread local storage (TLS)
|
|
Packit |
0848f5 |
# extensions. Defines TLS if it is found. Currently only knows about GCC
|
|
Packit |
0848f5 |
# and MSVC. I think SunPro uses the same as GCC, and Borland apparently
|
|
Packit |
0848f5 |
# supports either.
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# LICENSE
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# Copyright (c) 2008 Alan Woodland <ajw05@aber.ac.uk>
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# This program is free software: you can redistribute it and/or modify it
|
|
Packit |
0848f5 |
# under the terms of the GNU General Public License as published by the
|
|
Packit |
0848f5 |
# Free Software Foundation, either version 3 of the License, or (at your
|
|
Packit |
0848f5 |
# option) any later version.
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# This program is distributed in the hope that it will be useful, but
|
|
Packit |
0848f5 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
0848f5 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
Packit |
0848f5 |
# Public License for more details.
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# You should have received a copy of the GNU General Public License along
|
|
Packit |
0848f5 |
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# As a special exception, the respective Autoconf Macro's copyright owner
|
|
Packit |
0848f5 |
# gives unlimited permission to copy, distribute and modify the configure
|
|
Packit |
0848f5 |
# scripts that are the output of Autoconf when processing the Macro. You
|
|
Packit |
0848f5 |
# need not follow the terms of the GNU General Public License when using
|
|
Packit |
0848f5 |
# or distributing such scripts, even though portions of the text of the
|
|
Packit |
0848f5 |
# Macro appear in them. The GNU General Public License (GPL) does govern
|
|
Packit |
0848f5 |
# all other use of the material that constitutes the Autoconf Macro.
|
|
Packit |
0848f5 |
#
|
|
Packit |
0848f5 |
# This special exception to the GPL applies to versions of the Autoconf
|
|
Packit |
0848f5 |
# Macro released by the Autoconf Archive. When you make and distribute a
|
|
Packit |
0848f5 |
# modified version of the Autoconf Macro, you may extend this special
|
|
Packit |
0848f5 |
# exception to the GPL to apply to your modified version as well.
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
AC_DEFUN([AX_TLS], [
|
|
Packit |
0848f5 |
AC_MSG_CHECKING(for thread local storage specifier)
|
|
Packit |
0848f5 |
AC_CACHE_VAL(ac_cv_tls, [
|
|
Packit |
0848f5 |
ax_tls_keywords="__thread __declspec(thread) none"
|
|
Packit |
0848f5 |
for ax_tls_keyword in $ax_tls_keywords; do
|
|
Packit |
0848f5 |
case $ax_tls_keyword in
|
|
Packit |
0848f5 |
none) ac_cv_tls=none ; break ;;
|
|
Packit |
0848f5 |
*)
|
|
Packit |
0848f5 |
# MPICH modification: This was an AC_TRY_COMPILE before, but
|
|
Packit |
0848f5 |
# Darwin with non-standard compilers will accept __thread at
|
|
Packit |
0848f5 |
# compile time but fail to link due to an undefined
|
|
Packit |
0848f5 |
# "__emutls_get_address" symbol unless -lgcc_eh is added to the
|
|
Packit |
0848f5 |
# link line.
|
|
Packit |
0848f5 |
AC_LINK_IFELSE(
|
|
Packit |
0848f5 |
[AC_LANG_PROGRAM([$ax_tls_keyword int bar = 5;],[++bar;])],
|
|
Packit |
0848f5 |
[ac_cv_tls=$ax_tls_keyword],
|
|
Packit |
0848f5 |
[ac_cv_tls=none])
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
# MPICH modification: Also test with the extern keyword.
|
|
Packit |
0848f5 |
# The intel compiler on Darwin (at least as of 15.0.1)
|
|
Packit |
0848f5 |
# seems to break with the above error when the extern
|
|
Packit |
0848f5 |
# keyword is specified in shared library builds.
|
|
Packit |
0848f5 |
PAC_PUSH_FLAG([LIBS])
|
|
Packit |
0848f5 |
PAC_APPEND_FLAG([-shared],[LIBS])
|
|
Packit |
0848f5 |
if test "$ac_cv_tls" != "none" ; then
|
|
Packit |
0848f5 |
AC_LINK_IFELSE(
|
|
Packit |
0848f5 |
[AC_LANG_PROGRAM([extern $ax_tls_keyword int bar;],[++bar;])],
|
|
Packit |
0848f5 |
[ac_cv_tls=$ax_tls_keyword],
|
|
Packit |
0848f5 |
[ac_cv_tls=none])
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
PAC_POP_FLAG([LIBS])
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if test "$ac_cv_tls" != "none" ; then break ; fi
|
|
Packit |
0848f5 |
esac
|
|
Packit |
0848f5 |
done
|
|
Packit |
0848f5 |
])
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if test "$ac_cv_tls" != "none"; then
|
|
Packit |
0848f5 |
# MPICH modification: this was "TLS" before instead of
|
|
Packit |
0848f5 |
# "MPICH_TLS_SPECIFIER", but TLS had a reasonably high chance of conflicting
|
|
Packit |
0848f5 |
# with a system library.
|
|
Packit |
0848f5 |
AC_DEFINE_UNQUOTED([MPICH_TLS_SPECIFIER], $ac_cv_tls, [If the compiler supports a TLS storage class define it to that here])
|
|
Packit |
0848f5 |
fi
|
|
Packit |
0848f5 |
AC_MSG_RESULT($ac_cv_tls)
|
|
Packit |
0848f5 |
])
|