Skip to content

feat(libc): implement wcsftime - #3637

Closed
MarcZX10 wants to merge 1 commit into
boykopovar:mainfrom
MarcZX10:carry/wcsftime-3625
Closed

MarcZX10 wants to merge 1 commit into
boykopovar:mainfrom
MarcZX10:carry/wcsftime-3625

Conversation

@MarcZX10

Copy link
Copy Markdown
Contributor

What

Implements wcsftime (XbVXpf5WF28), which is absent from libSceLibcInternal on current main. PS5MC's import audit lists this as its next unresolved import (registry index 481); the startup failure is predicted from the registry and has not been observed in a game run:

FAIL: unresolved ELF import XbVXpf5WF28 from libSceLibcInternal.prx

The implementation follows FreeBSD 11.4's wcsftime over the guest library's wcsrtombs, strftime and mbsrtowcs, with the current single-byte C locale and 16-bit guest wchar_t. It preserves errno for empty or oversized results and null output, reports EILSEQ for an unconvertible format, and throws for null format or tm, consistent with the repository's exact-behaviour-or-throw rule.

This carries David's tested commit 06ed477e from #3625, with its commit authorship and co-author credit preserved. Thanks to @screamm for the import audit, FreeBSD comparison and Windows validation.

Tested

  • Linux, GCC 12.2, Release: built guest_wide_formatting_tests and guest_time_conversion_tests; guest_wide_formatting and guest_time_conversion each passed three consecutive runs.
  • python3 tools/check_conventions.py --base upstream/main and git diff upstream/main --check passed.
  • Windows was not run locally; the implementation author reports a full Windows build and the focused tests in libc: wcsftime is absent (PS5MC); fix branch ready #3625.

Checklist

  • Based on current main; no other open PR implements wcsftime
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

PS5MC (PPSA99420) imports wcsftime (XbVXpf5WF28, aerolib) as the last
absent libSceLibcInternal import in its registry order (index 481), so
its predicted stop is:

    FAIL: unresolved ELF import XbVXpf5WF28 from libSceLibcInternal.prx

The stop is predicted from the import order, not observed in a run.

wcsftime follows FreeBSD 11.4 lib/libc/locale/wcsftime.c (8c639945):
the wide format is converted with wcsrtombs, strftime fills a buffer of
maxsize * MB_CUR_MAX bytes limited to maxsize, and mbsrtowcs converts
the result back. A format unit that the single-byte C locale of
lib/libc/locale/none.c cannot encode returns 0 with EILSEQ, a maxsize
whose product with MB_CUR_MAX overflows returns 0 with EINVAL, and an
empty or overflowing result or a null buffer returns 0 with errno
unchanged; the ERANGE or EINVAL set by the Windows CRT's strftime is
discarded. A null format or tm throws, as FreeBSD dereferences it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 06ed477)
@github-actions

Copy link
Copy Markdown

Progress report (a11c8f7 → f4ad1ca)

📈 System libraries: 85.82% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libc wcsftime_nid_postfix

@blawesom

Copy link
Copy Markdown
Contributor

Independent pre-review on Linux (full CI runs only happen on manual trigger, so recording one): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON.

  • Builds; tools/check_conventions.py --base origin/main passes.
  • Full suite: 832/832 passed (all tests including the Vulkan suites on AMD RX 9070 XT / RADV).

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#3653 docs/dev/TechnicalDebt.md L630

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Closing: the PS5MC stop at XbVXpf5WF28 hasn't been observed in a run yet. Reopen when it is the title's stop on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants