Skip to content

Commit 386001a

Browse files
[1.10.x] Fix pthread use on FreeBSD (#253) (#262)
Much like OpenBSD, the FreeBSD pthread APIs are not imported with the appropriate nullability annotations, so the base pthread mutex type should be an optional value. Eventually we should provide API notes to fix this issue, but that is not in place today. See swiftlang/swift#81407 (cherry picked from commit 9d7ff77) Co-authored-by: Evan Wilde <[email protected]>
1 parent 944b740 commit 386001a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/X509/Lock.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import wasi_pthread
3535
#if os(Windows)
3636
@usableFromInline
3737
typealias LockPrimitive = SRWLOCK
38-
#elseif os(OpenBSD)
38+
#elseif os(OpenBSD) || os(FreeBSD)
3939
@usableFromInline
4040
typealias LockPrimitive = pthread_mutex_t?
4141
#else
@@ -54,14 +54,14 @@ extension LockOperations {
5454
#if os(Windows)
5555
InitializeSRWLock(mutex)
5656
#elseif (compiler(<6.1) && !os(WASI)) || (compiler(>=6.1) && _runtime(_multithreaded))
57-
#if os(OpenBSD)
57+
#if os(OpenBSD) || os(FreeBSD)
5858
var attr = pthread_mutexattr_t(bitPattern: 0)
5959
#else
6060
var attr = pthread_mutexattr_t()
6161
#endif
6262
pthread_mutexattr_init(&attr)
6363
debugOnly {
64-
#if os(OpenBSD)
64+
#if os(OpenBSD) || os(FreeBSD)
6565
pthread_mutexattr_settype(&attr, .init(PTHREAD_MUTEX_ERRORCHECK.rawValue))
6666
#else
6767
pthread_mutexattr_settype(&attr, .init(PTHREAD_MUTEX_ERRORCHECK))

0 commit comments

Comments
 (0)