Skip to content
Snippets Groups Projects
Commit 77f9b729 authored by Martin Marinov's avatar Martin Marinov
Browse files

Replace thread_local with a new macro BASE_THREAD_LOCAL. Set this macro to...

Replace thread_local with a new macro BASE_THREAD_LOCAL. Set this macro to selectively disable thread_local on platforms that don't support it correctly, e.g., Xcode < 8, and gcc < 4.8.3. Progress now uses BASE_THREAD_LOCAL instead of thread_local.
parent e60b6459
No related branches found
No related tags found
No related merge requests found
......@@ -57,7 +57,7 @@ void Context::exit_node()
actv_node_ = prnt == nullptr ? &phny_root_ : prnt;
}
thread_local Context cntx;
BASE_THREAD_LOCAL Context cntx;
/// Node implementation
Node::~Node()
......
......@@ -4,14 +4,10 @@
#define BASE_PROGRESS_NODE_HH_INCLUDED
#ifdef PROGRESS_ON
namespace Progress {
#if defined(__apple_build_version__)
// work around the lack of thread_local support in XCode 7
#if !__has_feature(cxx_thread_local)
#define thread_local // disable thread_local
#endif//!__has_feature(cxx_thread_local)
#endif//defined(__apple_build_version__)
#include <Base/Utils/Thread.hh>
namespace Progress {
//! Progress tick counter type
typedef unsigned long long TickNumber;
......@@ -134,7 +130,7 @@ private:
};
//! the current thread Progress context
extern thread_local Context cntx;
extern BASE_THREAD_LOCAL Context cntx;
/*!
Enable (or disable) the Context::abort() processing, use to enable abort()
......
......@@ -5,6 +5,7 @@ set(my_headers
${CMAKE_CURRENT_SOURCE_DIR}/IOutputStream.hh
${CMAKE_CURRENT_SOURCE_DIR}/OStringStream.hh
${CMAKE_CURRENT_SOURCE_DIR}/StopWatch.hh
${CMAKE_CURRENT_SOURCE_DIR}/Thread.hh
${CMAKE_CURRENT_SOURCE_DIR}/ThrowError.hh
PARENT_SCOPE
)
......
// (C) Copyright 2017 by Autodesk, Inc.
#ifndef BASE_THREAD_HH_INCLUDED
#define BASE_THREAD_HH_INCLUDED
// System specific thread support
#if defined(__apple_build_version__)
// work around the lack of thread_local support in XCode 7
#if !__has_feature(cxx_thread_local)
#define BASE_THREAD_LOCAL_BROKEN
#endif//!__has_feature(cxx_thread_local)
#endif//defined(__apple_build_version__)
// TODO: move these macros to a more suitable location
#define GCC_VERSION(MAJOR, MINOR, PATCH) \
(MAJOR * 10000 + MINOR * 100 + PATCH)
#define GCC_VERSION_CURRENT\
GCC_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
#if defined(__GNUC__) && GCC_VERSION_CURRENT < GCC_VERSION(4, 8, 3)
// there is a thread_local linker bug prior to gcc-4.8.3
// see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55800
#define BASE_THREAD_LOCAL_BROKEN
#endif//__GNUC__
#ifdef BASE_THREAD_LOCAL_BROKEN // if broken do not use thread_local
#define BASE_THREAD_LOCAL
#else// BASE_THREAD_LOCAL_BROKEN
#define BASE_THREAD_LOCAL thread_local
#endif// BASE_THREAD_LOCAL_BROKEN
#endif//BASE_THREAD_HH_INCLUDED
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment