Skip to content

feat(libc): implement swscanf - #4467

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
arcwiser:feat/libc-swscanf
Oct 13, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
arcwiser:feat/libc-swscanf

Conversation

@arcwiser

Copy link
Copy Markdown
Contributor

What

Implement the missing 16-bit guest swscanf export by sharing the existing swscanf_s scanner without consuming the secure buffer-size arguments after string, character and scanset conversions. Keep the existing refusal behavior for unsupported conversions and widen the documented scanner limitations to cover both entry points.

Add regression coverage for integer, floating-point, string, character, scanset, %n, suppression, width, partial-match, EOF, null-input and unsupported-format behavior.

This carries screamm's offered commit from issue #4464 unchanged and preserves its authorship.

Closes #4464.

Tested

  • Windows 11 build 26200, WinLibs MinGW-w64 GCC 15.2.0 r7, Release, BUILD_TESTING=ON
  • Built guest_wide_conversion_tests and its 52-step libc dependency target successfully
  • ctest --test-dir build -R '^guest_wide_conversion$' --output-on-failure (3/3 passed)
  • python tools/check_conventions.py --base origin/main
  • git diff --check origin/main
  • python tools/check_test_registration.py build (705 executables, none unregistered)
  • Project overlap checker: no overlap with open pull requests
  • Original author additionally reported 606/606 non-GPU full tests on Windows; not rerun in this carry checkout

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; unsupported scanner behavior remains rejected
  • No notes, investigation .md files or images added to the repository
  • No third-party code added
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none (PPSA99360 imports this function, but the stop is predicted rather than runtime-observed)
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Progress report (bf8dc61 → 8aa0d42)

➖ System libraries: 88.18% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libc swscanf_nid_postfix

@LeandroLP23

Copy link
Copy Markdown
Contributor

The swscanf stop is now observed at runtime, not just predicted. PS5CEMU-HAR (PPSA99360, catalog 3.5.0) on Windows 11 (26300), WinLibs GCC 15.2.0, Release, relinked with --windows --trap-sdk-syscall-stubs. Each step adds one change onto main f8dee0595:

Build Stop
main unresolved ELF import avvJ3J0H0EY from libkernel.prx (sceKernelJitCreateSharedMemory, #3787)
+ #3787 (its two File/src conflicts with main resolved by keeping both sides) unresolved ELF import 5KWrg7-ZqvE from libkernel.prx (pthread_setaffinity_np)
+ screamm's feat/libkernel-setaffinity-siglist (827a8c87) unresolved ELF import HNnWdT43ues from libSceLibcInternal.prx (swscanf)
+ screamm's feat/libc-swscanf (569cb122, the same patch as this PR's 462830939 per git range-diff) unresolved ELF import ELSr5qm4K1M from libSceLibcInternal.prx (__umodti3, #4462)

So with #3787 and pthread_setaffinity_np in, this PR moves the title from swscanf to __umodti3. The Unblocks line could name PPSA99360 (with Depends on: #3787), if you agree. I'm opening a PR that carries screamm's pthread_setaffinity_np commit, the one part of #4463 not carried yet.

AI-assisted: yes (Claude Code)

@screamm

screamm commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Windows validation with title evidence (Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON, full build including libs; base main d379bfd0 with #5025 applied for the title runs (without it current main cannot load libkernel_sys.prx on Windows, #4877)): 46283093 merged onto d379bfd0 (one trivial conflict: the bullet now belongs in docs/dev/debt/libc.md). Same lines as my 569cb122. guest_wide_conversion 3/3; suite 686/688 (guest_sce_net passes serially, patched_libraries is main's #4877 failure); conventions and git diff --check pass.

PS5CEMU-HAR (PPSA99360): with #4514 in, the title's stop is FAIL: unresolved ELF import HNnWdT43ues from libSceLibcInternal.prx (this export); with #4514 + #4469 + this PR it runs the whole minute at PS5CEMU-HAR | FPS: 59.93 (3483), launcher [ui] frames=3001 avg=16.68 ms.

@p3n1cillin

Copy link
Copy Markdown
Contributor

Title run with this PR: Windows 11, MinGW GCC 15.2.0 (WinLibs), Release, on main 3faa9cb40 merged with this PR and the other open PRs the catalog titles need; PS5CEMU-HAR (PPSA99360) from its catalog release, converted with --trap-sdk-syscall-stubs (it has a forbidden inline syscall otherwise), eboot.bin kept in app0.

AI-assisted (Claude Code).

@blawesom

Copy link
Copy Markdown
Contributor

Rebase handoff — rebased onto current main, authorship unchanged. This one needed the full per-library routing: the PR's TechnicalDebt.md conflict carried 107 debt entries from before the ledger restructure (#4411) — each is routed to its docs/dev/debt/<name>.md by first core/ link, with relative links adjusted for the deeper directory.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV):

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/4467
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is 1818ddb38.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Conflicts with main in docs/dev/TechnicalDebt.md; the swscanf entry now goes in docs/dev/debt/libc.md, please rebase. Also list #4514 under Depends on and PPSA99360 under Unblocks, since screamm's run shows the title stops at HNnWdT43ues once #4514 is in.

swscanf (HNnWdT43ues) runs the swscanf_s scanner without the buffer
size arguments after %s, %c and %[, as FreeBSD's swscanf.c passes its
arguments to vswscanf. Both entry points share one engine with a flag
for the sizes; swscanf_s behaves as before.

Title: PS5CEMU-HAR PPSA99360 imports swscanf from libSceLibcInternal.prx
(import audit with --trap-sdk-syscall-stubs, registry index 292, right
after pthread_setaffinity_np at 276). Predicted stop line once
pthread_setaffinity_np resolves, without this change:
FAIL: unresolved ELF import HNnWdT43ues (swscanf) from libSceLibcInternal.prx

NID from tools/nid_names.py, confirmed in shadPS4 aerolib.inl:51950
(e0a466753a1a). Prototype in ps5-payload-dev include/freebsd/wchar.h:133,
export in sce_stubs/libSceLibcInternal.c:8582 (f5d40f02770e).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Rebased onto main (bf8dc61) and force-pushed: the swscanf debt entry now sits in docs/dev/debt/libc.md with main's other entries, and docs/dev/TechnicalDebt.md is as on main. The commit and its author are unchanged.
Please update the description: #4514 (merged) under Depends on, PPSA99360 under Unblocks.

@github-actions

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
#4958 docs/dev/debt/libc.md L65-66

@oneandonlydean
oneandonlydean merged commit 83924ac into boykopovar:main Oct 13, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs libc needs rebase Conflicts with main, rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libc: swscanf is absent (PS5CEMU-HAR); fix branch ready

6 participants