xref: /netbsd-src/external/gpl3/binutils/dist/bfd/ax_tls.m4 (revision cb63e24e8d6aae7ddac1859a9015f48b1d8bd90e)
1*cb63e24eSchristos# ===========================================================================
2*cb63e24eSchristos#          https://www.gnu.org/software/autoconf-archive/ax_tls.html
3*cb63e24eSchristos# ===========================================================================
4*cb63e24eSchristos#
5*cb63e24eSchristos# SYNOPSIS
6*cb63e24eSchristos#
7*cb63e24eSchristos#   AX_TLS([action-if-found], [action-if-not-found])
8*cb63e24eSchristos#
9*cb63e24eSchristos# DESCRIPTION
10*cb63e24eSchristos#
11*cb63e24eSchristos#   Provides a test for the compiler support of thread local storage (TLS)
12*cb63e24eSchristos#   extensions. Defines TLS if it is found. Currently knows about C++11,
13*cb63e24eSchristos#   GCC/ICC, and MSVC. I think SunPro uses the same as GCC, and Borland
14*cb63e24eSchristos#   apparently supports either.
15*cb63e24eSchristos#
16*cb63e24eSchristos# LICENSE
17*cb63e24eSchristos#
18*cb63e24eSchristos#   Copyright (c) 2008 Alan Woodland <ajw05@aber.ac.uk>
19*cb63e24eSchristos#   Copyright (c) 2010 Diego Elio Petteno` <flameeyes@gmail.com>
20*cb63e24eSchristos#
21*cb63e24eSchristos#   This program is free software: you can redistribute it and/or modify it
22*cb63e24eSchristos#   under the terms of the GNU General Public License as published by the
23*cb63e24eSchristos#   Free Software Foundation, either version 3 of the License, or (at your
24*cb63e24eSchristos#   option) any later version.
25*cb63e24eSchristos#
26*cb63e24eSchristos#   This program is distributed in the hope that it will be useful, but
27*cb63e24eSchristos#   WITHOUT ANY WARRANTY; without even the implied warranty of
28*cb63e24eSchristos#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
29*cb63e24eSchristos#   Public License for more details.
30*cb63e24eSchristos#
31*cb63e24eSchristos#   You should have received a copy of the GNU General Public License along
32*cb63e24eSchristos#   with this program. If not, see <https://www.gnu.org/licenses/>.
33*cb63e24eSchristos#
34*cb63e24eSchristos#   As a special exception, the respective Autoconf Macro's copyright owner
35*cb63e24eSchristos#   gives unlimited permission to copy, distribute and modify the configure
36*cb63e24eSchristos#   scripts that are the output of Autoconf when processing the Macro. You
37*cb63e24eSchristos#   need not follow the terms of the GNU General Public License when using
38*cb63e24eSchristos#   or distributing such scripts, even though portions of the text of the
39*cb63e24eSchristos#   Macro appear in them. The GNU General Public License (GPL) does govern
40*cb63e24eSchristos#   all other use of the material that constitutes the Autoconf Macro.
41*cb63e24eSchristos#
42*cb63e24eSchristos#   This special exception to the GPL applies to versions of the Autoconf
43*cb63e24eSchristos#   Macro released by the Autoconf Archive. When you make and distribute a
44*cb63e24eSchristos#   modified version of the Autoconf Macro, you may extend this special
45*cb63e24eSchristos#   exception to the GPL to apply to your modified version as well.
46*cb63e24eSchristos
47*cb63e24eSchristos#serial 15
48*cb63e24eSchristos
49*cb63e24eSchristosAC_DEFUN([AX_TLS], [
50*cb63e24eSchristos  AC_MSG_CHECKING([for thread local storage (TLS) class])
51*cb63e24eSchristos  AC_CACHE_VAL([ac_cv_tls],
52*cb63e24eSchristos   [for ax_tls_keyword in thread_local _Thread_local __thread '__declspec(thread)' none; do
53*cb63e24eSchristos       AS_CASE([$ax_tls_keyword],
54*cb63e24eSchristos          [none], [ac_cv_tls=none ; break],
55*cb63e24eSchristos          [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
56*cb63e24eSchristos              [#include <stdlib.h>],
57*cb63e24eSchristos              [static  $ax_tls_keyword  int bar;]
58*cb63e24eSchristos            )],
59*cb63e24eSchristos            [ac_cv_tls=$ax_tls_keyword ; break],
60*cb63e24eSchristos            [ac_cv_tls=none]
61*cb63e24eSchristos          )]
62*cb63e24eSchristos        )
63*cb63e24eSchristos    done ]
64*cb63e24eSchristos  )
65*cb63e24eSchristos  AC_MSG_RESULT([$ac_cv_tls])
66*cb63e24eSchristos
67*cb63e24eSchristos  AS_IF([test "$ac_cv_tls" != "none"],
68*cb63e24eSchristos    [AC_DEFINE_UNQUOTED([TLS],[$ac_cv_tls],[If the compiler supports a TLS storage class, define it to that here])
69*cb63e24eSchristos     m4_ifnblank([$1],[$1],[[:]])],
70*cb63e24eSchristos    [m4_ifnblank([$2],[$2],[[:]])])
71*cb63e24eSchristos])
72