Commit Graph

30 Commits

Author SHA1 Message Date
Doug Gregor
1efb994375 Enable strict memory safety in the Synchronization module 2025-02-26 14:28:28 -08:00
Doug Gregor
8378562e12 Adopt @unsafe throughout the standard library
Annotate all of the `Unsafe*` types and `unsafe` functions in the standard
library (including concurrency, synchronization, etc.) as `@unsafe`. Add a
few tests to ensure that we detect uses of these types in clients that
have disabled unsafe code.
2024-08-19 14:33:09 -07:00
Evan Wilde
cae88d3344 Fix add_swift_target_library for the static SDK
add_swift_target_library was missing pieces for passing sources and
flags to the static SDK build. As a result, the static SDK was missing
pieces (specifically Mutex).

Also adding the Musl import to the Linux Mutex implementation.
2024-08-13 15:59:31 -07:00
Alejandro Alonso
24a46c422b Merge pull request #74946 from Azoy/mutex-sending-inout
[stdlib] Adopt inout sending for Mutex
2024-07-17 10:56:57 -07:00
Alexander Cyon
c21b1e68fd [stdlib] Fix typos 2024-07-06 13:09:57 +02:00
Alejandro Alonso
9cbf410220 Adopt inout sending for Mutex 2024-07-03 10:54:20 -07:00
Alejandro Alonso
e3a53abe13 Don't use aarch64 hint for arm targets 2024-06-10 09:23:21 -07:00
Alejandro Alonso
b1ceb9b947 Update MutexUnavailable.swift (#74182)
Fixes the availability syntax for minimal platforms.
Resolves: rdar://129345303
2024-06-06 12:46:28 -07:00
Alejandro Alonso
4f8181dde6 Merge pull request #74143 from Azoy/mutex-minimal-thing
[stdlib] Condition Mutex.swift on platform
2024-06-06 07:54:36 -07:00
Yuta Saito
da6f015e3c Merge pull request #74171 from kateinoigakukun/yt/fix-mutex-wasm-test
[Synchronization] Fix wasm atomic intrinsic declarations
2024-06-06 16:58:32 +09:00
Alex Lorenz
bffb878476 Merge pull request #74160 from hyp/eng/fix-android-synchro
[android] Fix Synchronization Android build
2024-06-05 23:38:47 -07:00
Yuta Saito
2dbbbcf646 [Synchronization] Skip atomic operations in single-threaded mode on WebAssembly
Use of atomics instructions requires the support of threads proposal and
it's not widely supported yet. So we should enable actual atomic
operations only when targeting wasm32-uknown-wasip1-threads.
2024-06-06 04:18:13 +00:00
Yuta Saito
0536c9ac65 [Synchronization] Fix wasm atomic intrinsic declarations
Otherwise, isel will not be able to select the desired atomic
instructions.
2024-06-06 04:18:13 +00:00
Alex Lorenz
74d2a66a27 [androd] Fix Synchronization Android build
Add Android import for Mutex implementation
2024-06-05 16:58:05 -07:00
Alejandro Alonso
fcfbf068a5 Add a special file for mutex on unavailable platforms 2024-06-05 13:51:55 -07:00
Yuta Saito
3b1791a638 [Synchronization] Fix Wasm mutex build
This change fixes the following build error happening on Wasm:
```
error: referencing instance method '_wait(expected:)' on 'Atomic' requires the types '_MutexHandle.State' and 'UInt32' be equivalent
```
2024-06-05 17:15:43 +00:00
Alejandro Alonso
cb3fc4b451 Adopt sending and movesAsLike 2024-06-04 09:49:21 -07:00
Alejandro Alonso
66ec7abd54 Underscore some things, add explicit internal
Fix some compile issues
2024-06-04 09:06:37 -07:00
Alejandro Alonso
fbfb218d11 Update LinuxImpl.swift 2024-06-04 09:06:37 -07:00
Alejandro Alonso
3a115fc290 Properly handle the syscalls on Linux and do some spins
fix some stuff
2024-06-04 09:06:37 -07:00
Alejandro Alonso
9b389a3df5 Fix tests and toolchain build 2024-06-04 09:06:37 -07:00
Alejandro Alonso
e99268864c Use Builtin.addressOfRawLayout 2024-06-04 09:06:37 -07:00
Alejandro Alonso
97072e5b79 Adopt transferring for Mutex init 2024-06-04 09:06:37 -07:00
Alejandro Alonso
89748d4229 Actually implement the API now 2024-06-04 09:06:36 -07:00
Alejandro Alonso
92e6a989b2 Cache TID in TLS on Linux 2024-06-04 09:06:36 -07:00
Alejandro Alonso
5b7e3d8ca2 Add a WasmMutex 2024-06-04 09:06:36 -07:00
Alejandro Alonso
1146b41d14 Add the underscored unsafe locking primitives 2024-06-04 09:06:36 -07:00
Alejandro Alonso
882568ca4d Directly call gettid syscall instead of library function 2024-06-04 09:06:36 -07:00
Alejandro Alonso
1f206ec58e Attempt to release the lock and wake when we can't 2024-06-04 09:06:36 -07:00
Alejandro Alonso
2a60c88457 Implement Mutex in Synchronization 2024-06-04 09:06:34 -07:00