fix(libc): normalize valid mktime minus-one results #4277
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4277"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by BharatYadav007 on 2026-10-12T03:53:52Z.
What
A successful
mktimecan return-1for the second before the Unix epoch. The libc wrapper treated every-1result as a failure and left the guest calendar unnormalized.Initialize the host weekday to an invalid value and treat
-1as failure only if the host conversion leaves that value unchanged. This preserves the guest input on genuine failures and normalizes valid-1results through bothlibc_mktimeandmktime. The distinction follows the documentedtm_wdaycheck in Linux man-pages.Add a runtime test for both exports covering normalization around the epoch, multiple time zones, stale
EOVERFLOW, unrepresentable calendars, and the Windows CRT's existing pre-epoch failure behavior. Windows pre-epoch support remains as documented in TechnicalDebt.Replaces #3547, which was automatically closed under the open PR limit while #3542 was open. #3542 has now merged. The branch code is unchanged. Before the original submission, 132 open PR heads were checked for overlap; none implemented this change.
Tested
Validation performed on October 11 on branch commit
bbd52a249, based on upstreama11c8f7f7:Time.cppwith the regression fixture and ran it. The unmodified implementation failed at the valid-1timestamp; the fix passed. This was a focused native runtime check, not a full Linux build.guest_mktimepassed in 0.10 s andguest_time_conversionpassed in 0.13 s.libstarget passed.tools/check_conventions.py --base upstream/mainpassed.tools/check_test_registration.py buildpassed; all 638 test executables are registered.Checklist
.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-12T03:57:00Z.
Review: COMMENTED
🟢 Approval recommended
The focused implementation follows documented libc behavior and is covered by comprehensive cross-platform regression tests.
0 open findings
What changed in this PR
Fixes valid
mktimeresults of-1being mistaken for failures while preserving input on genuine failures.Changes:
tm_wdayto distinguish valid-1timestamps from errors.core/libs/tests/GuestMktime.cppcore/libs/prx/libc/src/Time.cppmktimeresults of-1.core/libs/prx/libc/CMakeLists.txt🧠 Review effort: Balanced
💡 Add a
code-reviewagent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.