Skip to content

Commit 6de8bd7

Browse files
committed
Adjust from backdeploy to bit casting as always emit into client
1 parent facba09 commit 6de8bd7

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

stdlib/public/Concurrency/ContinuousClock.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ extension ContinuousClock: Clock {
143143
@_unavailableInEmbedded
144144
extension ContinuousClock {
145145
@available(SwiftStdlib 5.7, *)
146-
@backDeployed(before: SwiftStdlib 9999)
147-
public var systemEpoch: Instant { Instant(_value: .seconds(0)) }
146+
@_alwaysEmitIntoClient
147+
public var systemEpoch: Instant { unsafeBitCast(Duration.seconds(0), to: Instant.self) }
148148
}
149149

150150
@available(SwiftStdlib 5.7, *)

stdlib/public/Concurrency/SuspendingClock.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ extension SuspendingClock: Clock {
131131
@_unavailableInEmbedded
132132
extension SuspendingClock {
133133
@available(SwiftStdlib 5.7, *)
134-
@backDeployed(before: SwiftStdlib 9999)
135-
public var systemEpoch: Instant { Instant(_value: .seconds(0)) }
134+
@_alwaysEmitIntoClient
135+
public var systemEpoch: Instant { unsafeBitCast(Duration.seconds(0), to: Instant.self) }
136136
}
137137

138138
@available(SwiftStdlib 5.7, *)

test/Concurrency/Runtime/clock.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ import StdlibUnittest
158158
}
159159
}
160160

161+
tests.test("Ensure abi layout size of Instant") {
162+
// If this test fails it means the ABI of ContinuousClock.Instant has been broken!
163+
// it MUST be the same laoyut of that of Duration
164+
expectEqual(MemoryLayout<ContinuousClock.Instant>.size, MemoryLayout<Duration>.size)
165+
expectEqual(MemoryLayout<SuspendingClock.Instant>.size, MemoryLayout<Duration>.size)
166+
}
167+
161168
await runAllTestsAsync()
162169
}
163170
}

0 commit comments

Comments
 (0)