Skip to content

Support for 64-bit timespec seconds on 32-bit platforms #3277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 30, 2025

Conversation

lhoward
Copy link
Contributor

@lhoward lhoward commented Jun 29, 2025

Modern 32-bit platforms (such as embedded Linux builds) support 64-bit timestamps in time_t and timespec. Accommodate this.

Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for filing this! I've left a quick note in the diff.

#else
let tvSec = curTime.tv_sec + Int((allNSecs / nsecPerSec))
#endif
let tvSec = curTime.tv_sec + _Seconds((allNSecs / nsecPerSec))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inclined to assume that we could actually just make this time_t on all platforms.

let nsecPerSec: Int64 = 1_000_000_000
let ns = amount.nanoseconds
let sec = ns / nsecPerSec
self = timespec(tv_sec: Int(sec), tv_nsec: Int(ns - sec * nsecPerSec))
self = timespec(tv_sec: _Seconds(sec), tv_nsec: Int(ns - sec * nsecPerSec))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, I'm inclined to assume we could just make this a time_t on all platforms.

Modern 32-bit platforms (such as embedded Linux builds) support 64-bit
timestamps in time_t and timespec.
@lhoward lhoward force-pushed the 64bit-time_t-on-32bit-platforms branch from c50e12d to a143444 Compare June 29, 2025 22:49
@Lukasa Lukasa added the 🔨 semver/patch No public API change. label Jun 30, 2025
@Lukasa
Copy link
Contributor

Lukasa commented Jun 30, 2025

Thanks for this! ✨

@Lukasa Lukasa enabled auto-merge (squash) June 30, 2025 16:45
@Lukasa Lukasa merged commit 8d265e3 into apple:main Jun 30, 2025
40 of 41 checks passed
@lhoward
Copy link
Contributor Author

lhoward commented Jun 30, 2025

Great! Out of interest, what's the release cadence of swift-nio? Curious when we can enable 64-bit timestamps in the Yocto layer.

jeremy-prater/meta-swift#12

cc @xtremekforever

@Lukasa
Copy link
Contributor

Lukasa commented Jun 30, 2025

I expect we'll be able to release this week.

@Lukasa
Copy link
Contributor

Lukasa commented Jul 1, 2025

Shipped as 2.84.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants