Skip to content

Commit

Permalink
Adding explicit feature test for thread_local
Browse files Browse the repository at this point in the history
- this fixes #2137
  • Loading branch information
hkaiser committed Oct 12, 2017
1 parent d711115 commit d6c9502
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
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 d6c9502

Please sign in to comment.