Skip to content

Commit

Permalink
Merge pull request #2946 from STEllAR-GROUP/fixing_2137
Browse files Browse the repository at this point in the history
Adding explicit feature test for thread_local
  • Loading branch information
hkaiser committed Oct 25, 2017
2 parents e847103 + 615fe65 commit ac3517b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -361,7 +361,7 @@ endif()
################################################################################
set(HPX_WITH_NATIVE_TLS_DEFAULT ON)
if(APPLE)
set(HPX_WITH_NATIVE_TLS_DEFAULT OFF)
set(HPX_WITH_NATIVE_TLS_DEFAULT ${HPX_WITH_CXX11_THREAD_LOCAL})
endif()
hpx_option(HPX_WITH_NATIVE_TLS BOOL
"Use native TLS support if available (default: ${HPX_WITH_NATIVE_TLS_DEFAULT})"
Expand Down
8 changes: 8 additions & 0 deletions cmake/HPX_AddConfigTest.cmake
Expand Up @@ -541,6 +541,14 @@ macro(hpx_check_for_cxx11_std_unordered_set)
FILE ${ARGN})
endmacro()

###############################################################################
macro(hpx_check_for_cxx11_thread_local)
add_hpx_config_test(HPX_WITH_CXX11_THREAD_LOCAL
SOURCE cmake/tests/cxx11_thread_local.cpp
FILE ${ARGN}
CMAKECXXFEATURE cxx_thread_local)
endmacro()

###############################################################################
macro(hpx_check_for_cxx11_noreturn_attribute)
add_hpx_config_test(HPX_WITH_CXX11_NORETURN_ATTRIBUTE
Expand Down
5 changes: 4 additions & 1 deletion cmake/HPX_PerformCxxFeatureTests.cmake
Expand Up @@ -146,6 +146,9 @@ macro(hpx_perform_cxx_feature_tests)
hpx_check_for_cxx11_std_unordered_set(
REQUIRED "HPX needs support for C++11 std::unordered_set")

hpx_check_for_cxx11_thread_local(
DEFINITIONS HPX_HAVE_CXX11_THREAD_LOCAL)

hpx_check_for_cxx11_noreturn_attribute(
DEFINITIONS HPX_HAVE_CXX11_NORETURN_ATTRIBUTE)

Expand Down Expand Up @@ -175,7 +178,7 @@ macro(hpx_perform_cxx_feature_tests)

hpx_check_for_cxx14_deprecated_attribute(
DEFINITIONS HPX_HAVE_CXX14_DEPRECATED_ATTRIBUTE)

hpx_check_for_cxx14_return_type_deduction()

# check for experimental facilities
Expand Down
13 changes: 13 additions & 0 deletions cmake/tests/cxx11_thread_local.cpp
@@ -0,0 +1,13 @@
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2017 Hartmut Kaiser
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
////////////////////////////////////////////////////////////////////////////////

thread_local int dummy = 0;

int main()
{
return 0;
}
2 changes: 2 additions & 0 deletions hpx/util/thread_specific_ptr.hpp
Expand Up @@ -29,6 +29,8 @@
# if __has_feature(cxx_thread_local)
# define HPX_NATIVE_TLS thread_local
# endif
#elif defined(HPX_HAVE_CXX11_THREAD_LOCAL)
# define HPX_NATIVE_TLS thread_local
#endif

#if !defined(HPX_NATIVE_TLS)
Expand Down
2 changes: 2 additions & 0 deletions tests/performance/local/native_tls_overhead.cpp
Expand Up @@ -23,6 +23,8 @@
# if __has_feature(cxx_thread_local)
# define HPX_NATIVE_TLS thread_local
# endif
#elif defined(HPX_HAVE_CXX11_THREAD_LOCAL)
# define HPX_NATIVE_TLS thread_local
#endif

#if !defined(HPX_NATIVE_TLS)
Expand Down

0 comments on commit ac3517b

Please sign in to comment.