Skip to content

Commit 1a546a9

Browse files
committed
[FreeBSD]: Optional observation pthread primitives
The pthread APIs on FreeBSD do not include nullability APIs so the pthread mutex APIs are imported as pointers to optional values. Other platforms include nullability APIs and import the pthread APIs as pointers to the mutex. Splitting the locking primitive type based on the OS. Fixes: rdar://150880976
1 parent b311c63 commit 1a546a9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ internal struct Lock {
3434
#if canImport(Darwin)
3535
typealias Primitive = os_unfair_lock
3636
#elseif canImport(Glibc) || canImport(Musl) || canImport(Bionic)
37+
#if os(FreeBSD) || os(OpenBSD)
38+
// BSD libc does not annotate the nullability of pthread APIs.
39+
// We should replace this with the appropriate API note in the platform
40+
// overlay.
41+
// https://github.com/swiftlang/swift/issues/81407
42+
typealias Primitive = pthread_mutex_t?
43+
#else
3744
typealias Primitive = pthread_mutex_t
45+
#endif
3846
#elseif canImport(WinSDK)
3947
typealias Primitive = SRWLOCK
4048
#elseif arch(wasm32)

0 commit comments

Comments
 (0)