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