Skip to content

Commit a143444

Browse files
committed
Support for 64-bit timespec seconds on 32-bit platforms
Modern 32-bit platforms (such as embedded Linux builds) support 64-bit timestamps in time_t and timespec.
1 parent f5339fb commit a143444

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

Sources/NIOConcurrencyHelpers/lock.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,7 @@ public final class ConditionLock<T: Equatable> {
253253
gettimeofday(&curTime, nil)
254254

255255
let allNSecs: Int64 = timeoutNS + Int64(curTime.tv_usec) * 1000
256-
#if canImport(wasi_pthread)
257-
let tvSec = curTime.tv_sec + (allNSecs / nsecPerSec)
258-
#else
259-
let tvSec = curTime.tv_sec + Int((allNSecs / nsecPerSec))
260-
#endif
256+
let tvSec = curTime.tv_sec + time_t((allNSecs / nsecPerSec))
261257

262258
var timeoutAbs = timespec(
263259
tv_sec: tvSec,

Sources/NIOPosix/SelectorGeneric.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ extension timespec {
4646
let nsecPerSec: Int64 = 1_000_000_000
4747
let ns = amount.nanoseconds
4848
let sec = ns / nsecPerSec
49-
self = timespec(tv_sec: Int(sec), tv_nsec: Int(ns - sec * nsecPerSec))
49+
self = timespec(tv_sec: time_t(sec), tv_nsec: Int(ns - sec * nsecPerSec))
5050
}
5151
}
5252
#endif

0 commit comments

Comments
 (0)