Commit Graph

28 Commits

Author SHA1 Message Date
Mike Ash
0403dd8a0a [Runtime] Fix recursive_mutex_handle when getting os_unfair_recursive_lock from the SDK.
The declaration was inside the #if, which makes it unavailable when the condition is not true. Move the declaration outside the #if.

rdar://158956741
2025-08-22 15:37:46 -04:00
Mike Ash
650027e087 [Runtime] Don't redeclare os_unfair_recursive_lock et al if the SDK has them.
rdar://152340726
2025-06-03 16:38:22 -04:00
Mike Ash
6397e30856 [Concurrency] Eliminate StatusRecordLockRecord.
Move to a recursive lock inline in the Task. This avoids the need to allocate a lock record and simplifies the code somewhat.

Change Task's OpaquePrivateStorage to compute its size at build time based on the sizes of its components, rather than having it be a fixed size. It appears that the fixed size was intended to be part of the ABI, but that didn't happen and we're free to change this size. We need to expand it slightly when using pthread_mutex as the recursive lock, as pthread_mutex is pretty big. Other recursive locks allow it to shrink slightly.

We don't have a recursive mutex in our Threading support code, so add a RecursiveMutex type.

rdar://113898653
2025-03-26 14:52:37 -04:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Evan Wilde
154e98706c Use a macro to initialize mutex
Copying a mutex isn't really a supported thing. Use a macro to
initialize the mutex directly rather than a function that returns the
mutex.
2024-01-10 12:44:30 -08:00
Kuba (Brecka) Mracek
c86aa48bb4 Explicitly #include <errno.h>, avoid depending on implicit inclusion by other headers (#66060) 2023-05-22 20:38:40 -07:00
Philippe Hausler
40c277b245 Observation and associated macros 2023-03-02 15:30:59 -08:00
Alastair Houghton
b068194195 Don't use tsd_private.h in compatibility libraries for ARM64_32.
Apparently this issue also affects ARM64_32.

rdar://105768086
2023-02-22 08:36:25 +00:00
Alastair Houghton
21ac6149e3 Don't use tsd_private.h in compatibility libraries for ARMv7k.
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
2023-01-19 16:48:42 +00:00
Alastair Houghton
33e74cd1d8 [Threading] Rename chrono.h to match the namespace name.
rdar://100236038
2022-09-29 15:44:29 +01:00
Alastair Houghton
fcf3bfa4a6 [Threading] Always round up when converting std::chrono::durations.
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
2022-09-29 10:31:26 +01:00
Alastair Houghton
4495d63c12 [Threading] Add ConditionVariable support.
Swift Concurrency would like to be able to use condition variables.
Add support to the threading packages.

rdar://100236038
2022-09-27 16:21:13 +01:00
Alastair Houghton
863ab00c24 [Threading] Close and re-open namespace around include.
We need an extra namespace close/open around the include in `Darwin.h`.

rdar://90776105
2022-06-10 10:32:13 +01:00
Alastair Houghton
c401cc34fd [Threading] Use llvm::Optional<> rather than making a zero lower bound special.
While most systems aren't going to have their stack bottom at zero,
using llvm::Optional<> here is cleaner.

rdar://90776105
2022-06-07 07:39:53 +01:00
Alastair Houghton
b5c8b79556 [Threading] Move stack bounds fetching into the threading library.
Fetching the current stack bounds is done using threading functions, so
should be in the threading library.

rdar://90776105
2022-06-07 07:39:53 +01:00
Alastair Houghton
eb4c81d60e [Threading] Don't use TLS keys as template arguments.
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
2022-06-07 07:39:53 +01:00
Alastair Houghton
0e9318cec5 [Threading] Put everything through git clang-format.
Just formatting changes.

rdar://90776105
2022-06-07 07:39:53 +01:00
Alastair Houghton
f3a412dd53 [Threading] Remove thread_get_main().
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
2022-06-07 07:39:53 +01:00
Alastair Houghton
6d1b6dbd1c [Threading] Fix the Linux build.
A few fixes specifically for the Linux build.

rdar://90776105
2022-06-07 07:39:52 +01:00
Alastair Houghton
f5bdb858e0 [Threading] Create new threading library and use it.
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
2022-06-07 07:39:51 +01:00
Alex Hoppen
4aa2bbbf06 Revert "Merge pull request #42447 from al45tair/eng/PR-90776105"
This reverts commit 8bcb71140f, reversing
changes made to c4dd271d36.
2022-06-02 18:03:23 +02:00
Alastair Houghton
43cc1f97ba [Threading] Use llvm::Optional<> rather than making a zero lower bound special.
While most systems aren't going to have their stack bottom at zero,
using llvm::Optional<> here is cleaner.

rdar://90776105
2022-05-24 17:46:33 +01:00
Alastair Houghton
fc4f941185 [Threading] Move stack bounds fetching into the threading library.
Fetching the current stack bounds is done using threading functions, so
should be in the threading library.

rdar://90776105
2022-05-24 14:57:42 +01:00
Alastair Houghton
69f0b03a73 [Threading] Don't use TLS keys as template arguments.
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
2022-05-24 14:57:42 +01:00
Alastair Houghton
b5bd267ff1 [Threading] Put everything through git clang-format.
Just formatting changes.

rdar://90776105
2022-05-24 14:57:41 +01:00
Alastair Houghton
6e875dacc9 [Threading] Remove thread_get_main().
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
2022-05-24 14:57:41 +01:00
Alastair Houghton
fc90280e34 [Threading] Fix the Linux build.
A few fixes specifically for the Linux build.

rdar://90776105
2022-05-24 14:57:39 +01:00
Alastair Houghton
63a09007a1 [Threading] Create new threading library and use it.
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
2022-05-24 14:57:39 +01:00