@@ -85,29 +85,32 @@ BOOST_SYMBOL_VISIBLE inline ::backtrace_state* construct_state(const program_loc
8585 // and multiple threads concurrently work with state. I failed to localize the root cause:
8686 // https://gcc.gnu.org/bugzilla//show_bug.cgi?id=87653
8787
88-
89- #if !defined(BOOST_HAS_THREADS) || defined(BOOST_STACKTRACE_BACKTRACE_FORCE_STATIC)
90- static
88+ #define BOOST_STACKTRACE_DETAIL_IS_MT 1
89+
90+ #if !defined(BOOST_HAS_THREADS)
91+ # define BOOST_STACKTRACE_DETAIL_STORAGE static
92+ # undef BOOST_STACKTRACE_DETAIL_IS_MT
93+ # define BOOST_STACKTRACE_DETAIL_IS_MT 0
94+ #elif defined(BOOST_STACKTRACE_BACKTRACE_FORCE_STATIC)
95+ # define BOOST_STACKTRACE_DETAIL_STORAGE static
96+ #elif !defined(BOOST_NO_CXX11_THREAD_LOCAL)
97+ # define BOOST_STACKTRACE_DETAIL_STORAGE thread_local
98+ #elif defined(__GNUC__) && !defined(__clang__)
99+ # define BOOST_STACKTRACE_DETAIL_STORAGE static __thread
91100#else
92-
93- // Result of `construct_state()` invocation is not stored by the callers, so `thread_local`
94- // gives a single `state` per thread and that state is not shared between threads in any way.
95-
96- # ifndef BOOST_NO_CXX11_THREAD_LOCAL
97- thread_local
98- # elif defined(__GNUC__) && !defined(__clang__)
99- static __thread
100- # else
101- /* just a local variable */
102- # endif
103-
101+ # define BOOST_STACKTRACE_DETAIL_STORAGE /* just a local variable */
104102#endif
105- ::backtrace_state* state = ::backtrace_create_state (
103+
104+ BOOST_STACKTRACE_DETAIL_STORAGE ::backtrace_state* state = ::backtrace_create_state (
106105 prog_location.name (),
107- 0 ,
106+ BOOST_STACKTRACE_DETAIL_IS_MT ,
108107 boost::stacktrace::detail::libbacktrace_error_callback,
109108 0
110109 );
110+
111+ #undef BOOST_STACKTRACE_DETAIL_IS_MT
112+ #undef BOOST_STACKTRACE_DETAIL_STORAGE
113+
111114 return state;
112115}
113116
0 commit comments