Skip to content

Commit 00ff1c3

Browse files
authored
Merge pull request swiftlang#31632 from compnerd/nyhow-ou-ave-n-problems
runtime: remove dependency on `LLVM_ENABLE_THREADS`
2 parents fdde56c + 70bd271 commit 00ff1c3

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

stdlib/public/runtime/Exclusivity.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,10 @@ static SwiftTLSContext &getTLSContext() {
270270
return *ctx;
271271
}
272272

273-
#elif SWIFT_TLS_HAS_THREADLOCAL
273+
#elif __has_feature(cxx_thread_local)
274274
// Second choice is direct language support for thread-locals.
275275

276-
static LLVM_THREAD_LOCAL SwiftTLSContext TLSContext;
276+
static thread_local SwiftTLSContext TLSContext;
277277

278278
static SwiftTLSContext &getTLSContext() {
279279
return TLSContext;

stdlib/public/runtime/ThreadLocalStorage.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,6 @@
2626
# define SWIFT_TLS_HAS_RESERVED_PTHREAD_SPECIFIC 1
2727
#endif
2828

29-
// If we're using Clang, and Clang claims not to support thread_local,
30-
// it must be because we're on a platform that doesn't support it.
31-
#if __clang__ && !__has_feature(cxx_thread_local)
32-
// No thread_local.
33-
#else
34-
// Otherwise, we do have thread_local.
35-
# define SWIFT_TLS_HAS_THREADLOCAL 1
36-
static_assert(LLVM_ENABLE_THREADS, "LLVM_THREAD_LOCAL will use a global?");
37-
#endif
38-
3929
#if SWIFT_TLS_HAS_RESERVED_PTHREAD_SPECIFIC
4030
// Use reserved TSD keys.
4131
# if __has_include(<pthread/tsd_private.h>)
@@ -92,6 +82,9 @@ typedef unsigned long __swift_thread_key_t;
9282
# include <io.h>
9383
# define WIN32_LEAN_AND_MEAN
9484
# include <Windows.h>
85+
86+
#include <type_traits>
87+
9588
static_assert(std::is_same<__swift_thread_key_t, DWORD>::value,
9689
"__swift_thread_key_t is not a DWORD");
9790

0 commit comments

Comments
 (0)