feat(libc): export wcstombs_s #8396

Merged
Chuk49 merged 2 commits from upstream-pr/8396 into main 2026-10-20 23:21:13 +00:00
Chuk49 commented 2026-10-20 12:12:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Chuk49 on 2026-10-20T12:12:59Z.


What

libc.prx did not export wcstombs_s (sZLrjx-yEx4); only libSceAmpr.prx did. Ghost of Yotei imports it from libc.prx and stops during symbol resolution (#8383).

The implementation moves from libSceAmpr to libc's Multibyte.cpp, next to wcsrtombs_s. libSceAmpr keeps exporting the NID through APS5_EXPORT("sZLrjx-yEx4", sceAmprWcstombsS), which forwards to libc. A plain wcstombs_s_nid_postfix definition in libSceAmpr would lose its NID: the patcher leaves any name that libc also exports unrenamed (--preserve-export-list). This is the same pattern libSceAmpr already uses for mbstowcs and wcscpy_s.

The other import in #8383, mbstowcs_s (tdcAqgCS+uI), is implemented by #7841, so this PR leaves it alone.

Tested

Linux (Arch), GCC 16.2.1, full build with BUILD_TESTING=ON:

  • guest_wcsrtombs_s now also checks wcstombs_s in libc: conversion, len limit, count-only, ERANGE, EINVAL and EILSEQ.
  • guest_ampr_threads runs its existing wcstombs_s cases through the libSceAmpr export sceAmprWcstombsS.
  • ctest -R "ampr|wcs|mbs|crt|patched_libraries|nid|multibyte": 21/21 pass.
  • nm -D on the patched build/core/libs/libs/libc.prx and libSceAmpr.prx: both define sZLrjx-yEx4.

No title run.

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 (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none (covers wcstombs_s from #8383; mbstowcs_s is #7841)
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4935539793 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8396). Originally posted by [Chuk49](https://github.com/Chuk49) on 2026-10-20T12:12:59Z. --- ### What `libc.prx` did not export `wcstombs_s` (`sZLrjx-yEx4`); only `libSceAmpr.prx` did. Ghost of Yotei imports it from `libc.prx` and stops during symbol resolution (#8383). The implementation moves from libSceAmpr to libc's `Multibyte.cpp`, next to `wcsrtombs_s`. libSceAmpr keeps exporting the NID through `APS5_EXPORT("sZLrjx-yEx4", sceAmprWcstombsS)`, which forwards to libc. A plain `wcstombs_s_nid_postfix` definition in libSceAmpr would lose its NID: the patcher leaves any name that libc also exports unrenamed (`--preserve-export-list`). This is the same pattern libSceAmpr already uses for `mbstowcs` and `wcscpy_s`. The other import in #8383, `mbstowcs_s` (`tdcAqgCS+uI`), is implemented by #7841, so this PR leaves it alone. ### Tested Linux (Arch), GCC 16.2.1, full build with `BUILD_TESTING=ON`: - `guest_wcsrtombs_s` now also checks `wcstombs_s` in libc: conversion, `len` limit, count-only, ERANGE, EINVAL and EILSEQ. - `guest_ampr_threads` runs its existing `wcstombs_s` cases through the libSceAmpr export `sceAmprWcstombsS`. - `ctest -R "ampr|wcs|mbs|crt|patched_libraries|nid|multibyte"`: 21/21 pass. - `nm -D` on the patched `build/core/libs/libs/libc.prx` and `libSceAmpr.prx`: both define `sZLrjx-yEx4`. No title run. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none (covers `wcstombs_s` from #8383; `mbstowcs_s` is #7841) - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-20 12:32:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T12:32:39Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6044 core/libs/tests/GuestAmprThreads.cpp
core/libs/tests/GuestWcsrtombsS.cpp
PR 7081 core/libs/prx/libSceAmpr/Export.cpp
PR 7648 core/libs/prx/libSceAmpr/Export.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6290917471 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8396#issuecomment-6290917471). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T12:32:39Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestAmprThreads.cpp`<br>`core/libs/tests/GuestWcsrtombsS.cpp` | | [PR 7081](https://www.github.com/boykopovar/AnyPS5/pull/7081) | `core/libs/prx/libSceAmpr/Export.cpp` | | [PR 7648](https://www.github.com/boykopovar/AnyPS5/pull/7648) | `core/libs/prx/libSceAmpr/Export.cpp` |
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!8396
No description provided.