Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Sources/Testing/ExitTests/SpawnProcess.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ func spawnExecutable(
// these file descriptors.
_ = swt_posix_spawn_file_actions_addclosefrom_np(fileActions, highestFD + 1)
#elseif os(FreeBSD)
// Like Linux, this platfrom doesn't have POSIX_SPAWN_CLOEXEC_DEFAULT;
// However; unlike Linux, all non-EOL FreeBSD (>= 13.1) supports
// `posix_spawn_file_actions_addclosefrom_np` and therefore we don't need
// need `swt_posix_spawn_file_actions_addclosefrom_np` to guard the availability
// of this api.
// Like Linux, this platform doesn't have POSIX_SPAWN_CLOEXEC_DEFAULT.
// Unlike Linux, all non-EOL FreeBSD versions (≥13.1) support
// `posix_spawn_file_actions_addclosefrom_np`. Therefore, we don't need
// `swt_posix_spawn_file_actions_addclosefrom_np` to guard the
// availability of this function.
_ = posix_spawn_file_actions_addclosefrom_np(fileActions, highestFD + 1)
#else
#warning("Platform-specific implementation missing: cannot close unused file descriptors")
Expand Down
8 changes: 4 additions & 4 deletions Sources/Testing/ExitTests/WaitFor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ private let _childProcessContinuations = Locked<[pid_t: CheckedContinuation<Exit
/// A condition variable used to suspend the waiter thread created by
/// `_createWaitThread()` when there are no child processes to await.
private nonisolated(unsafe) let _waitThreadNoChildrenCondition = {
#if os(FreeBSD)
#if os(FreeBSD)
let result = UnsafeMutablePointer<pthread_cond_t?>.allocate(capacity: 1)
#else
#else
let result = UnsafeMutablePointer<pthread_cond_t>.allocate(capacity: 1)
#endif
#endif
_ = pthread_cond_init(result, nil)
return result
}()
Expand Down Expand Up @@ -126,7 +126,7 @@ private let _createWaitThread: Void = {
// newly-scheduled waiter process. (If this condition is spuriously
// woken, we'll just loop again, which is fine.) Note that we read errno
// outside the lock in case acquiring the lock perturbs it.
_childProcessContinuations.withUnsafeUnderlyingLock { lock, childProcessContinuations in
_childProcessContinuations.withUnsafePlatformLock { lock, childProcessContinuations in
if childProcessContinuations.isEmpty {
_ = pthread_cond_wait(_waitThreadNoChildrenCondition, lock)
}
Expand Down
4 changes: 1 addition & 3 deletions Sources/Testing/Support/Locked.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ struct Locked<T>: RawRepresentable, Sendable where T: Sendable {
}
}

#if SWT_TARGET_OS_APPLE || os(Linux) || os(FreeBSD) || os(Android) || (os(WASI) && compiler(>=6.1) && _runtime(_multithreaded))
/// Acquire the lock and invoke a function while it is held, yielding both the
/// protected value and a reference to the lock itself.
///
Expand All @@ -144,14 +143,13 @@ struct Locked<T>: RawRepresentable, Sendable where T: Sendable {
/// - Warning: Callers that unlock the lock _must_ lock it again before the
/// closure returns. If the lock is not acquired when `body` returns, the
/// effect is undefined.
nonmutating func withUnsafeUnderlyingLock<R>(_ body: (UnsafeMutablePointer<PlatformLock>, T) throws -> R) rethrows -> R {
nonmutating func withUnsafePlatformLock<R>(_ body: (UnsafeMutablePointer<PlatformLock>, T) throws -> R) rethrows -> R {
try withLock { value in
try _storage.withUnsafeMutablePointerToElements { lock in
try body(lock, value)
}
}
}
#endif
}

extension Locked where T: AdditiveArithmetic {
Expand Down