.gitignore: ignore binaries and generated files
[libtar.git] / autoconf / ax_tls.m4
blob228110b98c144ae58121cfa824d54cd79de48015
1 # ===========================================================================
2 #                 http://autoconf-archive.cryp.to/ax_tls.html
3 # ===========================================================================
5 # SYNOPSIS
7 #   AX_TLS
9 # DESCRIPTION
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.
16 # LICENSE
18 #   Copyright (c) 2008 Alan Woodland <ajw05@aber.ac.uk>
20 #   This program is free software: you can redistribute it and/or modify it
21 #   under the terms of the GNU General Public License as published by the
22 #   Free Software Foundation, either version 3 of the License, or (at your
23 #   option) any later version.
25 #   This program is distributed in the hope that it will be useful, but
26 #   WITHOUT ANY WARRANTY; without even the implied warranty of
27 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
28 #   Public License for more details.
30 #   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/>.
33 #   As a special exception, the respective Autoconf Macro's copyright owner
34 #   gives unlimited permission to copy, distribute and modify the configure
35 #   scripts that are the output of Autoconf when processing the Macro. You
36 #   need not follow the terms of the GNU General Public License when using
37 #   or distributing such scripts, even though portions of the text of the
38 #   Macro appear in them. The GNU General Public License (GPL) does govern
39 #   all other use of the material that constitutes the Autoconf Macro.
41 #   This special exception to the GPL applies to versions of the Autoconf
42 #   Macro released by the Autoconf Archive. When you make and distribute a
43 #   modified version of the Autoconf Macro, you may extend this special
44 #   exception to the GPL to apply to your modified version as well.
46 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_TRY_COMPILE(
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
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)