mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Threading][TSan] Fix TSan errors from lazy init on Linux.
Move the TSan functionality from Concurrency into Threading. Use it in the Linux `ulock` implementation so that TSan knows about `ulock` and will tolerate the newer `swift_once` implementation that uses it. rdar://110665213
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "swift/Threading/Impl.h"
|
||||
#include "swift/Threading/Errors.h"
|
||||
#include "swift/Threading/TSan.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -61,7 +62,7 @@ void swift::threading_impl::once_slow(once_t &predicate, void (*fn)(void *),
|
||||
#endif
|
||||
if (predicate.flag.load(std::memory_order_acquire) == 0) {
|
||||
fn(context);
|
||||
predicate.flag.store(-1, std::memory_order_release);
|
||||
predicate.flag.store(tsan::enabled() ? 1 : -1, std::memory_order_release);
|
||||
}
|
||||
#if defined(__LP64__) || defined(_LP64)
|
||||
linux::ulock_unlock(&predicate.lock);
|
||||
|
||||
Reference in New Issue
Block a user