Skip to content

runtime: remove dependency on LLVM_ENABLE_THREADS #31632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stdlib/public/runtime/Exclusivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,10 @@ static SwiftTLSContext &getTLSContext() {
return *ctx;
}

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

static LLVM_THREAD_LOCAL SwiftTLSContext TLSContext;
static thread_local SwiftTLSContext TLSContext;

static SwiftTLSContext &getTLSContext() {
return TLSContext;
Expand Down
13 changes: 3 additions & 10 deletions stdlib/public/runtime/ThreadLocalStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@
# define SWIFT_TLS_HAS_RESERVED_PTHREAD_SPECIFIC 1
#endif

// If we're using Clang, and Clang claims not to support thread_local,
// it must be because we're on a platform that doesn't support it.
#if __clang__ && !__has_feature(cxx_thread_local)
// No thread_local.
#else
// Otherwise, we do have thread_local.
# define SWIFT_TLS_HAS_THREADLOCAL 1
static_assert(LLVM_ENABLE_THREADS, "LLVM_THREAD_LOCAL will use a global?");
#endif

#if SWIFT_TLS_HAS_RESERVED_PTHREAD_SPECIFIC
// Use reserved TSD keys.
# if __has_include(<pthread/tsd_private.h>)
Expand Down Expand Up @@ -92,6 +82,9 @@ typedef unsigned long __swift_thread_key_t;
# include <io.h>
# define WIN32_LEAN_AND_MEAN
# include <Windows.h>

#include <type_traits>

static_assert(std::is_same<__swift_thread_key_t, DWORD>::value,
"__swift_thread_key_t is not a DWORD");

Expand Down