feat(libc): implement ctime and rewind #1871
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1871"
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 TheAggie on 2026-10-08T22:27:48Z.
What
ctimeandrewindwere not exported. ccleste (PPSA59322) imports both.ctimeformats through the existinglocaltimeandasctime, as C defines it, and returns null whenlocaltimedoes.rewindseeks the stream to its start throughfseekoand clears its error and end-of-file flags.Test (
guest_standard_streams):ctimeof a fixed moment equalsasctime(localtime(...))and is 25 characters ending in a newline. After reading a stream to end of file,rewindclears end-of-file and the stream reads from its first byte again.Tested
Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release.
mainwith this PR and four other small libc/libkernel PRs of mine merged together (atol, getprogname, dup2, ctime/rewind, pthread_set_name_np). It was run from the generatedCTestTestfile.cmakecommands because antivirus blocksctest.exeon this machine.tools/check_conventions.py --base origin/mainpasses on this branch alone.Not tested on Linux or macOS.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T22:31:42Z.
Progress report (
ce64d8e→51067d7)📈 System libraries: 84.77% (+0.01%, +2 implemented functions)
✅ 2 implemented
ctime_nid_postfixrewind_nid_postfixImported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T02:58:09Z.
Review: COMMENTED
Verified on Linux — the differential holds, and both symbols are genuinely new.
cmake --build build --target guest_standard_stream_tests→ clean; the test passes, exit 0. (For anyone reproducing: the target isguest_standard_stream_tests, singular.)Time.cppandFileAndHeap.cppback atmain, the test kept → the target fails to link:so both are truly absent from
main. Worth grepping with a word boundary, incidentally —ctime_nid_postfixis a substring ofasctime_nid_postfixand a plaingrep -conmainreturns a hit that is not there.Claim cross-check:
ctimeislocaltime→asctimewith the null propagated (Time.cpp:104-107), andrewindisfseeko(stream, 0, SEEK_SET)+ClearError()(FileAndHeap.cpp:208-211).ClearErrorcallsstd::clearerr, which clears the error and end-of-file indicators together, then re-syncs the guest flags fromfeof/ferror(FileStream.hpp:96-100). So "clears its error and end-of-file flags" is right, and it is cleared at the C level rather than only in the guest word.One detail worth keeping: the test pins
ctimetoasctime(localtime(...))instead of a literal string, so it holds in any timezone — it ran here in EDT.Not verified: Windows, the author's platform.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:30:24Z.
Closing: ccleste stops at
shm_openon main, beforectimeandrewind. Reopen when either is a title's next stop on main, with the log line.Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T02:24:51Z.
Both functions are now titles' next stops on current
main, so here are the log lines the close note asked for, plus a check of this branch.Checked
51067d7emerged ontomainc963432d, Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC from WinLibs), Release. The conflict is inTime.cpp:mainmovedlocaltime,asctimeandstrftimetoGuestTm, so in the merge I keptmain'sstrftimeand changedctimetoconst GuestTm* local = localtime_nid_postfix(timer);. The rest of the branch merged as is.guest_standard_streamspasses 5/5 on both (--repeat until-fail:5); no compiler warnings and no CRT assertion dialog on Windows.main0uAUs3hYuG4(ctime)V02oFv+-JzA(__isinf, #2174), Linux and Windows3QIPIh-GDjw(rewind)+my9jdHCMIQ(atol, #2186), Linux and Windows0uAUs3hYuG4(ctime)QuJYZ2KVGGQ(shm_open, #1860), Linux; on Windows it doesn't relink yet (emptyPT_TLS, #1911)Example for RommPS on Windows:
mainFAIL: unresolved ELF import 0uAUs3hYuG4 (ctime) from libSceLibcInternal.prx; with this branchFAIL: unresolved ELF import V02oFv+-JzA (__isinf) from libSceLibcInternal.prx. EVO Player and Nuvio PS5 also reachrewindonceatollexists (#2186).Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-10T04:49:06Z.
@oneandonlydean the reopen condition is met for both functions, from @babyhuey's runs above on current
main(Linux and Windows):0uAUs3hYuG4(ctime) (FAIL: unresolved ELF import 0uAUs3hYuG4 (ctime) from libSceLibcInternal.prx); with this branch it moves on toV02oFv+-JzA(__isinf).3QIPIh-GDjw(rewind); with this branch it moves on to+my9jdHCMIQ(atol).I rebased the branch onto current
main(afb8cd22) and force-pushed it.mainhad movedlocaltime/asctime/strftimetoGuestTm, soctimenow takesmain'sGuestTmfromlocaltime_nid_postfix(the same resolution babyhuey used);rewindmerged as is. On Windows (MinGW-w64 GCC 15.2, WinLibs, Release) it builds,guest_standard_streamsandguest_time_conversionpass, andtools/check_conventions.pypasses. I don't have RommPS or Capy Mobile locally, so the title runs are babyhuey's, not mine.Could you reopen it? GitHub doesn't let me reopen a PR a maintainer closed. Thanks @babyhuey for the runs.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T22:36:19Z.
@TheAggie with #1529 in, the libc stops are back on
mainf38a036e(catalog builds withsce_module/libc.prxunwrapped), and this branch covers seven titles:ctime(0uAUs3hYuG4): ccleste (PPSA59322), RommPS (PPSA76677)rewind(3QIPIh-GDjw): Capy Mobile (PPSA92280), PSXS5 (PPSA97510), vkQuake (PPSA99010), EVO Player (PPSA99039), Nuvio PS5 (PPSA99997)Linux:
app.elf: symbol lookup error: app.elf: undefined symbol: 3QIPIh-GDjw. With the intake check at 10 merged PRs it can go up as a new PR; happy to run the seven titles on Linux and Windows against it once it's up.Pull request closed