Skip to content

Commit 407e571

Browse files
committed
Fix macos 14 build
1 parent c0bbfa5 commit 407e571

2 files changed

Lines changed: 22 additions & 19 deletions

File tree

Sources/Subprocess/Atomic.swift

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#if canImport(Synchronization)
1313
import Synchronization
14-
#else
14+
#endif // canImport(Synchronization)
1515

1616
#if canImport(os)
1717
internal import os
@@ -28,7 +28,6 @@ internal import C.os.lock
2828
import WinSDK
2929
#endif // canImport(os)
3030

31-
#endif // canImport(Synchronization)
3231

3332
internal struct AtomicBox: Sendable, ~Copyable {
3433
internal typealias BitwiseXorFunc = (OutputConsumptionState) -> OutputConsumptionState
@@ -37,21 +36,26 @@ internal struct AtomicBox: Sendable, ~Copyable {
3736

3837
internal init() {
3938
#if canImport(Synchronization)
40-
guard #available(macOS 15, *) else {
41-
fatalError("Unexpected configuration")
42-
}
43-
let box = Atomic(UInt8(0))
44-
self.storage = {
45-
return { input in
46-
return box._bitwiseXor(input)
47-
}
48-
}
39+
let hasSynchronization = true
4940
#else
50-
let state = LockedState(OutputConsumptionState(rawValue: 0))
51-
self.storage = {
52-
return state._bitwiseXor
53-
}
41+
let hasSynchronization = false
5442
#endif
43+
44+
if hasSynchronization, #available(macOS 15, *) {
45+
let box = Atomic(UInt8(0))
46+
self.storage = {
47+
return { input in
48+
return box._bitwiseXor(input)
49+
}
50+
}
51+
} else {
52+
let state = LockedState(OutputConsumptionState(rawValue: 0))
53+
self.storage = {
54+
return { input in
55+
return state._bitwiseXor(input)
56+
}
57+
}
58+
}
5559
}
5660

5761
internal func bitwiseXor(
@@ -78,7 +82,8 @@ extension Atomic where Value == UInt8 {
7882
self = Atomic(initialValue.rawValue)
7983
}
8084
}
81-
#else
85+
#endif
86+
8287
// Fallback to LockedState if `Synchronization` is not available
8388
extension LockedState where State == OutputConsumptionState {
8489
init(_ initialValue: OutputConsumptionState) {
@@ -237,5 +242,3 @@ extension LockedState where State == Void {
237242
}
238243

239244
extension LockedState: @unchecked Sendable where State: Sendable {}
240-
241-
#endif

Sources/_SubprocessCShims/process_shims.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ static int _subprocess_spawn_prefork(
236236
*pid = childPid;
237237
// Read from the pipe until pipe is closed
238238
// either due to exec succeeds or error is written
239-
while (true) {
239+
for (;;) {
240240
int childError = 0;
241241
ssize_t read_rc = read(pipefd[0], &childError, sizeof(childError));
242242
if (read_rc == 0) {

0 commit comments

Comments
 (0)