|
1 | 1 | # =========================================================================== |
2 | | -# http://www.nongnu.org/autoconf-archive/ax_tls.html |
| 2 | +# https://www.gnu.org/software/autoconf-archive/ax_tls.html |
3 | 3 | # =========================================================================== |
4 | 4 | # |
5 | 5 | # SYNOPSIS |
6 | 6 | # |
7 | | -# AX_TLS |
| 7 | +# AX_TLS([action-if-found], [action-if-not-found]) |
8 | 8 | # |
9 | 9 | # DESCRIPTION |
10 | 10 | # |
11 | 11 | # Provides a test for the compiler support of thread local storage (TLS) |
12 | | -# extensions. Defines TLS if it is found. Currently only knows about GCC |
13 | | -# and MSVC. I think SunPro uses the same as GCC, and Borland apparently |
14 | | -# supports either. |
| 12 | +# extensions. Defines TLS if it is found. Currently knows about C++11, |
| 13 | +# GCC/ICC, and MSVC. I think SunPro uses the same as GCC, and Borland |
| 14 | +# apparently supports either. |
15 | 15 | # |
16 | 16 | # LICENSE |
17 | 17 | # |
18 | 18 | # Copyright (c) 2008 Alan Woodland <ajw05@aber.ac.uk> |
| 19 | +# Copyright (c) 2010 Diego Elio Petteno` <flameeyes@gmail.com> |
19 | 20 | # |
20 | 21 | # This program is free software: you can redistribute it and/or modify it |
21 | 22 | # under the terms of the GNU General Public License as published by the |
|
28 | 29 | # Public License for more details. |
29 | 30 | # |
30 | 31 | # You should have received a copy of the GNU General Public License along |
31 | | -# with this program. If not, see <http://www.gnu.org/licenses/>. |
| 32 | +# with this program. If not, see <https://www.gnu.org/licenses/>. |
32 | 33 | # |
33 | 34 | # As a special exception, the respective Autoconf Macro's copyright owner |
34 | 35 | # gives unlimited permission to copy, distribute and modify the configure |
|
43 | 44 | # modified version of the Autoconf Macro, you may extend this special |
44 | 45 | # exception to the GPL to apply to your modified version as well. |
45 | 46 |
|
| 47 | +#serial 15 |
| 48 | + |
46 | 49 | AC_DEFUN([AX_TLS], [ |
47 | | - AC_MSG_CHECKING(for thread local storage (TLS) class) |
48 | | - AC_CACHE_VAL(ac_cv_tls, [ |
49 | | - ax_tls_keywords="__thread __declspec(thread) none" |
50 | | - for ax_tls_keyword in $ax_tls_keywords; do |
51 | | - case $ax_tls_keyword in |
52 | | - none) ac_cv_tls=none ; break ;; |
53 | | - *) |
54 | | - AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
55 | | - [@%:@include <stdlib.h> |
56 | | - static void |
57 | | - foo(void) { |
58 | | - static ] $ax_tls_keyword [ int bar; |
59 | | - exit(1); |
60 | | - }], |
61 | | - [])], |
62 | | - [ac_cv_tls=$ax_tls_keyword ; break], |
63 | | - ac_cv_tls=none |
64 | | - ) |
65 | | - esac |
66 | | - done |
67 | | -]) |
| 50 | + AC_MSG_CHECKING([for thread local storage (TLS) class]) |
| 51 | + AC_CACHE_VAL([ac_cv_tls], |
| 52 | + [for ax_tls_keyword in thread_local _Thread_local __thread '__declspec(thread)' none; do |
| 53 | + AS_CASE([$ax_tls_keyword], |
| 54 | + [none], [ac_cv_tls=none ; break], |
| 55 | + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
| 56 | + [#include <stdlib.h>], |
| 57 | + [static $ax_tls_keyword int bar;] |
| 58 | + )], |
| 59 | + [ac_cv_tls=$ax_tls_keyword ; break], |
| 60 | + [ac_cv_tls=none] |
| 61 | + )] |
| 62 | + ) |
| 63 | + done ] |
| 64 | + ) |
| 65 | + AC_MSG_RESULT([$ac_cv_tls]) |
68 | 66 |
|
69 | | - if test "$ac_cv_tls" != "none"; then |
70 | | - dnl AC_DEFINE([TLS], [], [If the compiler supports a TLS storage class define it to that here]) |
71 | | - AC_DEFINE_UNQUOTED([TLS], $ac_cv_tls, [If the compiler supports a TLS storage class define it to that here]) |
72 | | - fi |
73 | | - AC_MSG_RESULT($ac_cv_tls) |
| 67 | + AS_IF([test "$ac_cv_tls" != "none"], |
| 68 | + [AC_DEFINE_UNQUOTED([TLS],[$ac_cv_tls],[If the compiler supports a TLS storage class, define it to that here]) |
| 69 | + m4_ifnblank([$1],[$1],[[:]])], |
| 70 | + [m4_ifnblank([$2],[$2],[[:]])]) |
74 | 71 | ]) |
0 commit comments