Blame m4/ax_tls.m4

Packit 6bd9ab
# ===========================================================================
Packit 6bd9ab
#          http://www.gnu.org/software/autoconf-archive/ax_tls.html
Packit 6bd9ab
# ===========================================================================
Packit 6bd9ab
#
Packit 6bd9ab
# SYNOPSIS
Packit 6bd9ab
#
Packit 6bd9ab
#   AX_TLS([action-if-found], [action-if-not-found])
Packit 6bd9ab
#
Packit 6bd9ab
# DESCRIPTION
Packit 6bd9ab
#
Packit 6bd9ab
#   Provides a test for the compiler support of thread local storage (TLS)
Packit 6bd9ab
#   extensions. Defines TLS if it is found. Currently knows about GCC/ICC
Packit 6bd9ab
#   and MSVC. I think SunPro uses the same as GCC, and Borland apparently
Packit 6bd9ab
#   supports either.
Packit 6bd9ab
#
Packit 6bd9ab
# LICENSE
Packit 6bd9ab
#
Packit 6bd9ab
#   Copyright (c) 2008 Alan Woodland <ajw05@aber.ac.uk>
Packit 6bd9ab
#   Copyright (c) 2010 Diego Elio Petteno` <flameeyes@gmail.com>
Packit 6bd9ab
#
Packit 6bd9ab
#   This program is free software: you can redistribute it and/or modify it
Packit 6bd9ab
#   under the terms of the GNU General Public License as published by the
Packit 6bd9ab
#   Free Software Foundation, either version 3 of the License, or (at your
Packit 6bd9ab
#   option) any later version.
Packit 6bd9ab
#
Packit 6bd9ab
#   This program is distributed in the hope that it will be useful, but
Packit 6bd9ab
#   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6bd9ab
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Packit 6bd9ab
#   Public License for more details.
Packit 6bd9ab
#
Packit 6bd9ab
#   You should have received a copy of the GNU General Public License along
Packit 6bd9ab
#   with this program. If not, see <http://www.gnu.org/licenses/>.
Packit 6bd9ab
#
Packit 6bd9ab
#   As a special exception, the respective Autoconf Macro's copyright owner
Packit 6bd9ab
#   gives unlimited permission to copy, distribute and modify the configure
Packit 6bd9ab
#   scripts that are the output of Autoconf when processing the Macro. You
Packit 6bd9ab
#   need not follow the terms of the GNU General Public License when using
Packit 6bd9ab
#   or distributing such scripts, even though portions of the text of the
Packit 6bd9ab
#   Macro appear in them. The GNU General Public License (GPL) does govern
Packit 6bd9ab
#   all other use of the material that constitutes the Autoconf Macro.
Packit 6bd9ab
#
Packit 6bd9ab
#   This special exception to the GPL applies to versions of the Autoconf
Packit 6bd9ab
#   Macro released by the Autoconf Archive. When you make and distribute a
Packit 6bd9ab
#   modified version of the Autoconf Macro, you may extend this special
Packit 6bd9ab
#   exception to the GPL to apply to your modified version as well.
Packit 6bd9ab
Packit 6bd9ab
#serial 11
Packit 6bd9ab
Packit 6bd9ab
AC_DEFUN([AX_TLS], [
Packit 6bd9ab
  AC_MSG_CHECKING([for thread local storage (TLS) class])
Packit 6bd9ab
  AC_CACHE_VAL([ac_cv_tls],
Packit 6bd9ab
   [for ax_tls_keyword in __thread '__declspec(thread)' none; do
Packit 6bd9ab
       AS_CASE([$ax_tls_keyword],
Packit 6bd9ab
          [none], [ac_cv_tls=none ; break],
Packit 6bd9ab
          [AC_TRY_COMPILE(
Packit 6bd9ab
              [#include <stdlib.h>
Packit 6bd9ab
               static void
Packit 6bd9ab
               foo(void) {
Packit 6bd9ab
               static ] $ax_tls_keyword [ int bar;
Packit 6bd9ab
               exit(1);
Packit 6bd9ab
               }],
Packit 6bd9ab
               [],
Packit 6bd9ab
               [ac_cv_tls=$ax_tls_keyword ; break],
Packit 6bd9ab
               ac_cv_tls=none
Packit 6bd9ab
           )])
Packit 6bd9ab
    done
Packit 6bd9ab
  ])
Packit 6bd9ab
  AC_MSG_RESULT([$ac_cv_tls])
Packit 6bd9ab
Packit 6bd9ab
  AS_IF([test "$ac_cv_tls" != "none"],
Packit 6bd9ab
    [AC_DEFINE_UNQUOTED([TLS],[$ac_cv_tls],[If the compiler supports a TLS storage class define it to that here])
Packit 6bd9ab
     m4_ifnblank([$1],[$1])],
Packit 6bd9ab
    m4_ifnblank([$2],[$2]))
Packit 6bd9ab
])