fix(libc): implement PAF mspace memalign #7878

Merged
PayloadAnim merged 1 commit from upstream-pr/7878 into main 2026-10-19 16:54:05 +00:00
PayloadAnim commented 2026-10-19 12:05:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PayloadAnim on 2026-10-19T12:05:06Z.


What

Implement sceLibcPafMspaceMemalign by delegating to sceLibcMspaceMemalign. The PAF owner argument is ignored, matching existing PAF allocator wrappers; the inferred signature and unverified console behavior are recorded in the libc debt note.

Tested

Windows: cmake --build build --target libc passed (user-reported). check_conventions.py passed. Tests not run. The overlap comparison found no matching function changes; I manually reviewed the conflicting docs/dev/debt/libc.md hunks and found them unrelated.

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
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4920640852 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7878). Originally posted by [PayloadAnim](https://github.com/PayloadAnim) on 2026-10-19T12:05:06Z. --- ### What Implement `sceLibcPafMspaceMemalign` by delegating to `sceLibcMspaceMemalign`. The PAF owner argument is ignored, matching existing PAF allocator wrappers; the inferred signature and unverified console behavior are recorded in the libc debt note. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows: `cmake --build build --target libc` passed (user-reported). `check_conventions.py` passed. Tests not run. The overlap comparison found no matching function changes; I manually reviewed the conflicting `docs/dev/debt/libc.md` hunks and found them unrelated. ### 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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
github-actions[bot] commented 2026-10-19 12:05:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T12:05:46Z.


Progress report (ebf1a90 → 3045488)

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

✅ 1 implemented
Library Name
libc sceLibcPafMspaceMemalign_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6266791259 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7878#issuecomment-6266791259). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T12:05:46Z. --- <!-- progress-report --> ### Progress report (ebf1a90 → 3045488) 📈 **System libraries**: 81.62% (+0.01%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libc | `sceLibcPafMspaceMemalign_nid_postfix` | </details>
github-actions[bot] commented 2026-10-19 12:16:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T12:16:52Z.


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 5021 docs/dev/debt/libc.md
PR 6226 docs/dev/debt/libc.md
PR 6469 docs/dev/debt/libc.md
PR 7081 docs/dev/debt/libc.md
PR 7332 docs/dev/debt/libc.md
PR 7417 docs/dev/debt/libc.md
PR 7473 docs/dev/debt/libc.md
PR 7715 docs/dev/debt/libc.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6266996259 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7878#issuecomment-6266996259). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T12:16:52Z. --- <!-- 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 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `docs/dev/debt/libc.md` | | [PR 6226](https://www.github.com/boykopovar/AnyPS5/pull/6226) | `docs/dev/debt/libc.md` | | [PR 6469](https://www.github.com/boykopovar/AnyPS5/pull/6469) | `docs/dev/debt/libc.md` | | [PR 7081](https://www.github.com/boykopovar/AnyPS5/pull/7081) | `docs/dev/debt/libc.md` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `docs/dev/debt/libc.md` | | [PR 7417](https://www.github.com/boykopovar/AnyPS5/pull/7417) | `docs/dev/debt/libc.md` | | [PR 7473](https://www.github.com/boykopovar/AnyPS5/pull/7473) | `docs/dev/debt/libc.md` | | [PR 7715](https://www.github.com/boykopovar/AnyPS5/pull/7715) | `docs/dev/debt/libc.md` |
fogydes commented 2026-10-19 12:24:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fogydes on 2026-10-19T12:24:24Z.

Review: COMMENTED


Verified on Windows 11 with MinGW-w64 GCC 15.2.0 (Release):

  • Implementation: sceLibcPafMspaceMemalign_nid_postfix correctly delegates to sceLibcMspaceMemalign_nid_postfix(handle, alignment, size) ignoring the trailing owner argument, matching the established PAF wrapper pattern in core/libs/prx/libc/src/Mspace.cpp.
  • Debt Tracking: Technical debt in docs/dev/debt/libc.md updated cleanly.
  • Conventions: No code comments added; tools/check_conventions.py passes cleanly.

Suggestion: Consider adding unit test coverage in core/libs/tests/Mspace.cpp alongside the other sceLibcPafMspace* test cases:

--- a/core/libs/tests/Mspace.cpp
+++ b/core/libs/tests/Mspace.cpp
@@ -28,6 +28,7 @@ int APS5_VABI sceLibcPafMspaceDestroy_nid_postfix(void*);
 void* APS5_VABI sceLibcPafMspaceMalloc_nid_postfix(void*, std::size_t, const void*);
+void* APS5_VABI sceLibcPafMspaceMemalign_nid_postfix(void*, std::size_t, std::size_t, const void*);
 void APS5_VABI sceLibcPafMspaceFree_nid_postfix(void*, void*, const void*);
 void* APS5_VABI sceLibcPafMspaceCalloc_nid_postfix(void*, std::size_t, std::size_t, const void*);
 void* APS5_VABI sceLibcPafMspaceRealloc_nid_postfix(void*, void*, std::size_t, const void*);
@@ -58,6 +59,9 @@ int main() {
     auto* block = static_cast<unsigned char*>(sceLibcPafMspaceMalloc_nid_postfix(arena, 40, &owner));
+    auto* aligned = static_cast<unsigned char*>(sceLibcPafMspaceMemalign_nid_postfix(arena, 64, 128, &owner));
+    Require(aligned != nullptr && (reinterpret_cast<std::uintptr_t>(aligned) % 64 == 0));
+    sceLibcPafMspaceFree_nid_postfix(arena, aligned, &owner);
     auto* zeroed = static_cast<unsigned char*>(sceLibcPafMspaceCalloc_nid_postfix(arena, 4, 8, arena));

Tested locally: ctest --test-dir build-libs -R "^mspace$" -V builds and passes in 0.08s.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5571480046 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7878#pullrequestreview-5571480046). Originally posted by [fogydes](https://github.com/fogydes) on 2026-10-19T12:24:24Z. **Review:** COMMENTED --- Verified on Windows 11 with MinGW-w64 GCC 15.2.0 (Release): - **Implementation**: `sceLibcPafMspaceMemalign_nid_postfix` correctly delegates to `sceLibcMspaceMemalign_nid_postfix(handle, alignment, size)` ignoring the trailing owner argument, matching the established PAF wrapper pattern in `core/libs/prx/libc/src/Mspace.cpp`. - **Debt Tracking**: Technical debt in `docs/dev/debt/libc.md` updated cleanly. - **Conventions**: No code comments added; `tools/check_conventions.py` passes cleanly. **Suggestion**: Consider adding unit test coverage in `core/libs/tests/Mspace.cpp` alongside the other `sceLibcPafMspace*` test cases: ```diff --- a/core/libs/tests/Mspace.cpp +++ b/core/libs/tests/Mspace.cpp @@ -28,6 +28,7 @@ int APS5_VABI sceLibcPafMspaceDestroy_nid_postfix(void*); void* APS5_VABI sceLibcPafMspaceMalloc_nid_postfix(void*, std::size_t, const void*); +void* APS5_VABI sceLibcPafMspaceMemalign_nid_postfix(void*, std::size_t, std::size_t, const void*); void APS5_VABI sceLibcPafMspaceFree_nid_postfix(void*, void*, const void*); void* APS5_VABI sceLibcPafMspaceCalloc_nid_postfix(void*, std::size_t, std::size_t, const void*); void* APS5_VABI sceLibcPafMspaceRealloc_nid_postfix(void*, void*, std::size_t, const void*); @@ -58,6 +59,9 @@ int main() { auto* block = static_cast<unsigned char*>(sceLibcPafMspaceMalloc_nid_postfix(arena, 40, &owner)); + auto* aligned = static_cast<unsigned char*>(sceLibcPafMspaceMemalign_nid_postfix(arena, 64, 128, &owner)); + Require(aligned != nullptr && (reinterpret_cast<std::uintptr_t>(aligned) % 64 == 0)); + sceLibcPafMspaceFree_nid_postfix(arena, aligned, &owner); auto* zeroed = static_cast<unsigned char*>(sceLibcPafMspaceCalloc_nid_postfix(arena, 4, 8, arena)); ``` Tested locally: `ctest --test-dir build-libs -R "^mspace$" -V` builds and passes in 0.08s.
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!7878
No description provided.