Although the C11 spec says `tss_dtor_t` is `void(*)(void *)`, there
may be modifiers on the former typedef, so we should use it instead
of directly writing the type.
rdar://144220714
can be reentrantly executed.
I don't think doing this is *actually a good idea*, but corrupting the
runtime is an even worse idea, and the overhead here is very low.
Because we're mentioning the type in a macro and it gets used elsewhere,
we need to be explicit that the type is inside threading_impl.
rdar://121122202
We need to pick up the `_swift_tsan_xxx` symbols from libswiftCore in
most cases, but sometimes we're statically linked and in that case we
want to use a local copy.
rdar://1106655213
On Darwin, `RTLD_NEXT` doesn't do what we need it to here, with the
result that if `libswiftCore`'s TSan initializer gets found first,
then `libswift_Concurrency` won't have its initializer called at all,
in spite of us using `RTLD_NEXT` to find the next definition.
Fix this by centralising the initializer in `libswiftCore` instead.
rdar://110665213
* Use the longer name ThreadSanitizer rather than TSan for the new files.
* Don't implement `tsan::consume` at all for now.
* Do the `tsan::release` for `ulock_unlock()` at the head of the function,
not at the tail.
* Add a comment to test/Sanitizers/tsan/once.swift to explain the test a
little more clearly.
rdar://110665213
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
The `RTL_SRWLOCK_INIT` declaration got reformatted and doesn't exactly
match what's in `windows.h`, so we're getting warnings during builds.
Fix to match what it says in the system header.
rdar://105400572
If we include this file, it generates inline assembly, which would be fine
except that when apps are being built with bitcode, that isn't allowed.
rdar://103274667
Rather than bodging the test to make it more robust, fix the functions
in the Threading layer to behave the same as they do on other platforms,
i.e. to guarantee that they always wait *at least* the amount of time
you asked for.
rdar://100236038
We were inadvertently rounding down, which was fine almost 100% of the
time, but on Windows where the timer resolution is only 1ms, it made
the test _very slightly_ flaky because we were asking to wait for
9ms rather than 10ms, then checking we'd waited at least 10ms.
We should explicitly round up, for that reason.
rdar://100236038
This repairs the Windows x86 SDK build after #59287. Use `intptr_t`
rather than the explicitly sized integer as this is always guaranteed to
be the size of the pointer width (irrespective of LP64/LP32 or
LLP64/LLP32). Since this impacts only the once predicate, this
shouldn't impact any assumptions around structure sizes.
There's no guarantee that e.g. pthread_key_t is an integral type. It could
be some kind of struct, or some other thing that isn't valid as a template
argument.
rdar://90776105
Removing thread_get_main() means we don't need a static initializer on
Darwin, which means we can delete Darwin.cpp as well. We can also delete
Nothreads.cpp while we're about it, because there's nothing in that file.
rdar://90776105
Declaring _RTL_SRWLOCK ourselves causes clashes with <windows.h>.
Rather than doing that, declare an equivalent struct, and some overloads.
rdar://90776105
We can't safely include <windows.h> because it defines a large number
of macros, some of which clash with things in the Swift source tree,
and others of which clash with things in the LLVM source tree. Sadly
we *also* can't just include the Windows headers we need, because they
pull in some of the problematic macros.
In this instance, the best thing seems to be to grab the definitions
for the types and functions we are going to use and put them in their
own header file. If we define them correctly, then #including
<windows.h> before or after this header won't have any adverse effects.
rdar://90776105
Some things (LLDB's language plugin, for instance), include Swift headers
from outside of our build system, and may not know to define one of the
threading package defines.
rdar://90776105
Moved all the threading code to one place. Added explicit support for
Darwin, Linux, Pthreads, C11 threads and Win32 threads, including new
implementations of Once for Linux, Pthreads, C11 and Win32.
rdar://90776105