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