feat(libc): export the std::__sce_v2 _Pmsw, _FPmsw and _LPmsw helpers #15519

Merged
Danigamer05 merged 1 commit from upstream-pr/15519 into main 2026-11-07 13:17:58 +00:00
Danigamer05 commented 2026-11-03 17:14:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Danigamer05 on 2026-11-03T17:14:21Z.


What

Export the versioned std::__sce_v2 _Pmsw, _FPmsw and _LPmsw from libc.

Export NID Original RVA
_ZNSt8__sce_v25_PmswEPd WbdD4UIGs8Q 0xCB5F0
_ZNSt8__sce_v26_FPmswEPf Ra68ujotvg0 0xCF2D0
_ZNSt8__sce_v26_LPmswEPe 3nFb+klnjVc 0x10C120

The behavior comes from the libc.prx bundled with PPSA03671 v01.001.005 (J03848509, SHA-256 483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6).

Each returns the address of the word holding the sign and exponent, without reading or writing it: 6 bytes into a double, 2 bytes into a float, and 6 bytes into a long double. That module treats long double as a 64-bit double here, as the versioned _LDtest and _LDint already in main do, so _LPmsw takes a double* like them.

Tested

Windows x86-64, WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON, main 1e658521a0a. Exact tested commit: 5dd6d283f3c.

  • Built libc, libkernel, their NID-patched production libraries and the related tests. The new guest_sce_v2_pmsw, public_headers, guest_math_exact and guest_dinkumware_float_bits pass, along with the other guest_sce_v2_* CTests.
  • The new test checks each returned address, the word it points at for 1.0, 1.0f and -2.0, and that writing through it changes the sign and exponent (1.0 to -infinity, 1.0f to -2.0f).
  • The original functions were loaded from the bundled module with its relocations applied, and ran side by side with the patched production library on 387 calls: 128 addresses per export, aligned and unaligned, with random bytes, plus a null pointer. The returned addresses, the 16 bytes around the argument, MXCSR and the x87 control and status words agree in every call.
  • Negative control: each export's offset was changed by one word in turn. The new CTest failed on each, and the side-by-side run reported the altered export. The source was then restored byte for byte (SHA-256 checked) and rebuilt, and the test and side-by-side run passed again.
  • Code conventions and git diff --check pass.
  • tools/pr_overlap.py read 1,731 open PRs before the rebase onto 1e658521a0a and reports no overlap; the rebase was clean and changed none of these lines. It keeps exit 2 for 32 branches that already conflict with main. None of them adds a line naming these exports. Merging each of the 32 with this branch and with main using git merge-tree gives the same conflict blocks. The branch also merges cleanly with #15336, #15471, #15484, #15490 and #15501.

Not tested: Linux, macOS, another SDK, a game, GPU or console. No game compatibility claim. No original module, extracted bytes, harness or log is committed or uploaded.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5141480421 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15519). Originally posted by [Danigamer05](https://github.com/Danigamer05) on 2026-11-03T17:14:21Z. --- ### What Export the versioned `std::__sce_v2` `_Pmsw`, `_FPmsw` and `_LPmsw` from libc. | Export | NID | Original RVA | | --- | --- | --- | | `_ZNSt8__sce_v25_PmswEPd` | `WbdD4UIGs8Q` | `0xCB5F0` | | `_ZNSt8__sce_v26_FPmswEPf` | `Ra68ujotvg0` | `0xCF2D0` | | `_ZNSt8__sce_v26_LPmswEPe` | `3nFb+klnjVc` | `0x10C120` | The behavior comes from the `libc.prx` bundled with PPSA03671 v01.001.005 (J03848509, SHA-256 `483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6`). Each returns the address of the word holding the sign and exponent, without reading or writing it: 6 bytes into a `double`, 2 bytes into a `float`, and 6 bytes into a `long double`. That module treats `long double` as a 64-bit `double` here, as the versioned `_LDtest` and `_LDint` already in main do, so `_LPmsw` takes a `double*` like them. ### 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 x86-64, WinLibs GCC 15.2.0, Release, `BUILD_TESTING=ON`, main `1e658521a0a`. Exact tested commit: `5dd6d283f3c`. - Built libc, libkernel, their NID-patched production libraries and the related tests. The new `guest_sce_v2_pmsw`, `public_headers`, `guest_math_exact` and `guest_dinkumware_float_bits` pass, along with the other `guest_sce_v2_*` CTests. - The new test checks each returned address, the word it points at for 1.0, 1.0f and -2.0, and that writing through it changes the sign and exponent (1.0 to -infinity, 1.0f to -2.0f). - The original functions were loaded from the bundled module with its relocations applied, and ran side by side with the patched production library on 387 calls: 128 addresses per export, aligned and unaligned, with random bytes, plus a null pointer. The returned addresses, the 16 bytes around the argument, MXCSR and the x87 control and status words agree in every call. - Negative control: each export's offset was changed by one word in turn. The new CTest failed on each, and the side-by-side run reported the altered export. The source was then restored byte for byte (SHA-256 checked) and rebuilt, and the test and side-by-side run passed again. - Code conventions and `git diff --check` pass. - `tools/pr_overlap.py` read 1,731 open PRs before the rebase onto `1e658521a0a` and reports no overlap; the rebase was clean and changed none of these lines. It keeps exit 2 for 32 branches that already conflict with main. None of them adds a line naming these exports. Merging each of the 32 with this branch and with main using `git merge-tree` gives the same conflict blocks. The branch also merges cleanly with #15336, #15471, #15484, #15490 and #15501. Not tested: Linux, macOS, another SDK, a game, GPU or console. No game compatibility claim. No original module, extracted bytes, harness or log is committed or uploaded. ### 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 - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!15519
No description provided.