Skip to content

Commit 4da993f

Browse files
committed
Observation: do not import all of Darwin to implement locking facilities
At the same time, drop that dependency in the new build system, so that we don't add an additional linkage for Darwin platforms compared to what we are doing in the current build system. Addresses rdar://158313871
1 parent 02e5d34 commit 4da993f

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

Runtimes/Supplemental/Observation/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ target_link_libraries(swiftObservation PRIVATE
102102
swiftCore
103103
swift_Concurrency
104104
$<$<PLATFORM_ID:Android>:swiftAndroid>
105-
$<$<PLATFORM_ID:Darwin>:swiftDarwin>
106105
$<$<PLATFORM_ID:Linux>:swiftGlibc>
107106
$<$<PLATFORM_ID:Windows>:swiftWinSDK>)
108107

stdlib/public/Observation/Sources/Observation/Locking.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
// symbols that are not provided by this library - so instead it has to re-implement
1616
// all of this on its own...
1717

18-
#if canImport(Darwin)
19-
import Darwin
18+
#if canImport(Darwin.os.lock)
19+
import Darwin.os.lock
2020
#elseif canImport(Glibc)
2121
import Glibc
2222
#elseif canImport(Musl)
@@ -31,7 +31,7 @@ import Bionic
3131
#endif
3232

3333
internal struct Lock {
34-
#if canImport(Darwin)
34+
#if canImport(Darwin.os.lock)
3535
typealias Primitive = os_unfair_lock
3636
#elseif canImport(Glibc) || canImport(Musl) || canImport(Bionic)
3737
#if os(FreeBSD) || os(OpenBSD)
@@ -59,7 +59,7 @@ internal struct Lock {
5959
}
6060

6161
fileprivate static func initialize(_ platformLock: PlatformLock) {
62-
#if canImport(Darwin)
62+
#if canImport(Darwin.os.lock)
6363
platformLock.initialize(to: os_unfair_lock())
6464
#elseif canImport(Glibc) || canImport(Musl) || canImport(Bionic)
6565
let result = pthread_mutex_init(platformLock, nil)
@@ -82,7 +82,7 @@ internal struct Lock {
8282
}
8383

8484
fileprivate static func lock(_ platformLock: PlatformLock) {
85-
#if canImport(Darwin)
85+
#if canImport(Darwin.os.lock)
8686
os_unfair_lock_lock(platformLock)
8787
#elseif canImport(Glibc) || canImport(Musl) || canImport(Bionic)
8888
pthread_mutex_lock(platformLock)
@@ -95,7 +95,7 @@ internal struct Lock {
9595
}
9696

9797
fileprivate static func unlock(_ platformLock: PlatformLock) {
98-
#if canImport(Darwin)
98+
#if canImport(Darwin.os.lock)
9999
os_unfair_lock_unlock(platformLock)
100100
#elseif canImport(Glibc) || canImport(Musl) || canImport(Bionic)
101101
let result = pthread_mutex_unlock(platformLock)

0 commit comments

Comments
 (0)