File tree Expand file tree Collapse file tree 3 files changed +17
-11
lines changed
Expand file tree Collapse file tree 3 files changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -120,10 +120,10 @@ void SetCurrentThreadIdentity(
120120 ABSL_THREAD_IDENTITY_MODE == ABSL_THREAD_IDENTITY_MODE_USE_CPP11
121121
122122// Please see the comment on `CurrentThreadIdentityIfPresent` in
123- // thread_identity.h. Because DLLs cannot expose thread_local variables in
124- // headers, we opt for the correct-but-slower option of placing the definition
125- // of this function only in a translation unit inside DLL .
126- #if defined(ABSL_BUILD_DLL) || defined(ABSL_CONSUME_DLL)
123+ // thread_identity.h. When we cannot expose thread_local variables in
124+ // headers, we opt for the correct-but-slower option of not inlining this
125+ // function.
126+ #ifndef ABSL_INTERNAL_INLINE_CURRENT_THREAD_IDENTITY_IF_PRESENT
127127ThreadIdentity* CurrentThreadIdentityIfPresent () { return thread_identity_ptr; }
128128#endif
129129#endif
Original file line number Diff line number Diff line change @@ -236,13 +236,18 @@ ABSL_CONST_INIT extern thread_local ThreadIdentity* thread_identity_ptr;
236236#error Thread-local storage not detected on this platform
237237#endif
238238
239- // thread_local variables cannot be in headers exposed by DLLs. However, it is
240- // important for performance reasons in general that
241- // `CurrentThreadIdentityIfPresent` be inlined. This is not possible across a
242- // DLL boundary so, with DLLs, we opt to have the function not be inlined. Note
239+ // thread_local variables cannot be in headers exposed by DLLs or in certain
240+ // build configurations on Apple platforms. However, it is important for
241+ // performance reasons in general that `CurrentThreadIdentityIfPresent` be
242+ // inlined. In the other cases we opt to have the function not be inlined. Note
243243// that `CurrentThreadIdentityIfPresent` is declared above so we can exclude
244- // this entire inline definition when compiling as a DLL.
245- #if !defined(ABSL_BUILD_DLL) && !defined(ABSL_CONSUME_DLL)
244+ // this entire inline definition.
245+ #if !defined(__APPLE__) && !defined(ABSL_BUILD_DLL) && \
246+ !defined (ABSL_CONSUME_DLL)
247+ #define ABSL_INTERNAL_INLINE_CURRENT_THREAD_IDENTITY_IF_PRESENT 1
248+ #endif
249+
250+ #ifdef ABSL_INTERNAL_INLINE_CURRENT_THREAD_IDENTITY_IF_PRESENT
246251inline ThreadIdentity* CurrentThreadIdentityIfPresent () {
247252 return thread_identity_ptr;
248253}
Original file line number Diff line number Diff line change @@ -136,7 +136,8 @@ static bool SetupAlternateStackOnce() {
136136#else
137137 const size_t page_mask = sysconf (_SC_PAGESIZE) - 1 ;
138138#endif
139- size_t stack_size = (std::max (SIGSTKSZ, 65536 ) + page_mask) & ~page_mask;
139+ size_t stack_size =
140+ (std::max<size_t >(SIGSTKSZ, 65536 ) + page_mask) & ~page_mask;
140141#if defined(ABSL_HAVE_ADDRESS_SANITIZER) || \
141142 defined (ABSL_HAVE_MEMORY_SANITIZER) || defined (ABSL_HAVE_THREAD_SANITIZER)
142143 // Account for sanitizer instrumentation requiring additional stack space.
You can’t perform that action at this time.
0 commit comments