docs(libc): record feholdexcept, fegetexcept, setlocale and strcasecmp as measured on a PS5 #11121

Merged
orezraey merged 2 commits from upstream-pr/11121 into main 2026-10-27 03:51:25 +00:00
orezraey commented 2026-10-25 18:42:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by orezraey on 2026-10-25T18:42:29Z.


What

Four libc entries measured on a retail PS5 (firmware 13.60) against the system libSceLibcInternal, with homebrew probes from a payload process. AnyPS5 already behaves as measured, so only docs/dev/debt/libc.md changes. The sources and console logs are in this gist (pfehold, pfeexcept, psetloc, pcasecmp).

  • feholdexcept: the entry said console equivalence was unverified. On the console it saves the environment with its flags (the 28-byte x87 fnstenv block and MXCSR at offset 28 of the 32-byte fenv_t), masks the x87 exceptions keeping rounding and precision (0x0377 becomes 0x037f, 0x0a7f stays), clears the x87 status, sets MXCSR to (csr & ~0x3f) | 0x1f80 (0x9bc1 and 0x8040 become 0x9fc0, 0xdfe0 becomes 0xdfc0) and returns 0, which is what Math.cpp does. A null argument faults there and throws here, which the entry keeps.
  • fegetexcept: the entry asked whether the PS5 reads only the x87 masks when the units disagree. It does: MXCSR unmasked alone gives 0, the x87 unmasking DIVBYZERO alone gives 4, the x87 unmasking everything with SSE masked gives 0x3f, and DENORMAL (0x2) is reported. The gap is closed, so the entry is removed. feenableexcept and fedisableexcept change both units and return ~((cw | mxcsr >> 7) & 0x3f) (all masked 0xffffffc0, all unmasked 0xffffffff), which FloatingPoint.cpp also returns; their Rosetta 2 entry is untouched.
  • setlocale: the entry said the rule was not measured on a console. For categories -1 to 7, 100 and 1 << 30, a null, "" or "C" name gives "C"; "POSIX", "C.UTF-8", "en_US.UTF-8", "ja_JP", "en_US.ISO8859-1" and "ISO8859-1" give null without setting errno. This is the rule StdioExtras.cpp follows, so the entry is removed. The localeconv entry said whether setlocale changes the table was not known; it now says it cannot.
  • strcasecmp and strncasecmp: the entry said console locale behaviour was unmeasured. The system library has only the C locale and returns -1, 0 or 1 with lower-case folding ("[" against "a" and "_" against "A" give -1), no folding of high bytes ("\xe9" against "\xc9" gives 1, "\x7f" against "\x80" gives -1), and strncasecmp with n 0 gives 0. This matches Strings.cpp, so the entry is removed.

Tested

Documentation only. Head 258ce3e2e9 on main a7a2eece49. tools/check_conventions.py passes; each changed entry is under 1000 characters.

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: #7081 (it edits the localeconv entry this PR also edits; merge order only)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5007578695 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11121). Originally posted by [orezraey](https://github.com/orezraey) on 2026-10-25T18:42:29Z. --- ### What Four libc entries measured on a retail PS5 (firmware 13.60) against the system `libSceLibcInternal`, with homebrew probes from a payload process. AnyPS5 already behaves as measured, so only `docs/dev/debt/libc.md` changes. The sources and console logs are in [this gist](https://gist.github.com/orezraey/d03c5812676329f553364d149198bf13) (`pfehold`, `pfeexcept`, `psetloc`, `pcasecmp`). - **`feholdexcept`**: the entry said console equivalence was unverified. On the console it saves the environment with its flags (the 28-byte x87 `fnstenv` block and MXCSR at offset 28 of the 32-byte `fenv_t`), masks the x87 exceptions keeping rounding and precision (0x0377 becomes 0x037f, 0x0a7f stays), clears the x87 status, sets MXCSR to `(csr & ~0x3f) | 0x1f80` (0x9bc1 and 0x8040 become 0x9fc0, 0xdfe0 becomes 0xdfc0) and returns 0, which is what `Math.cpp` does. A null argument faults there and throws here, which the entry keeps. - **`fegetexcept`**: the entry asked whether the PS5 reads only the x87 masks when the units disagree. It does: MXCSR unmasked alone gives 0, the x87 unmasking DIVBYZERO alone gives 4, the x87 unmasking everything with SSE masked gives 0x3f, and DENORMAL (0x2) is reported. The gap is closed, so the entry is removed. `feenableexcept` and `fedisableexcept` change both units and return `~((cw | mxcsr >> 7) & 0x3f)` (all masked 0xffffffc0, all unmasked 0xffffffff), which `FloatingPoint.cpp` also returns; their Rosetta 2 entry is untouched. - **`setlocale`**: the entry said the rule was not measured on a console. For categories -1 to 7, 100 and `1 << 30`, a null, `""` or `"C"` name gives "C"; `"POSIX"`, `"C.UTF-8"`, `"en_US.UTF-8"`, `"ja_JP"`, `"en_US.ISO8859-1"` and `"ISO8859-1"` give null without setting `errno`. This is the rule `StdioExtras.cpp` follows, so the entry is removed. The `localeconv` entry said whether `setlocale` changes the table was not known; it now says it cannot. - **`strcasecmp` and `strncasecmp`**: the entry said console locale behaviour was unmeasured. The system library has only the C locale and returns -1, 0 or 1 with lower-case folding (`"["` against `"a"` and `"_"` against `"A"` give -1), no folding of high bytes (`"\xe9"` against `"\xc9"` gives 1, `"\x7f"` against `"\x80"` gives -1), and `strncasecmp` with n 0 gives 0. This matches `Strings.cpp`, so the entry is removed. ### 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. --> Documentation only. Head `258ce3e2e9` on `main` `a7a2eece49`. `tools/check_conventions.py` passes; each changed entry is under 1000 characters. ### 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: #7081 (it edits the `localeconv` entry this PR also edits; merge order only) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-25 18:50:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T18:50:43Z.

Review: APPROVED


Reviewed the documentation-only change against the linked firmware 13.60 probe logs and Strings.cpp. The libSceLibcInternal rows show normalized -1/0/1 results for strcasecmp, C-locale ASCII folding, unchanged high bytes, and strncasecmp returning 0 at n=0; these agree with the implementation. The separate libc.prx SDK comparison in the logs has different raw-difference results, but the PR clearly scopes its claim to libSceLibcInternal. The feholdexcept, fegetexcept, and setlocale claims are also supported by their linked captures. The changed debt entries accurately distinguish measured console behavior from host behavior. The conventions, eligibility, intake, and labels checks pass; this is documentation-only and product test jobs are skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5644720117 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11121#pullrequestreview-5644720117). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T18:50:43Z. **Review:** APPROVED --- Reviewed the documentation-only change against the linked firmware 13.60 probe logs and `Strings.cpp`. The `libSceLibcInternal` rows show normalized -1/0/1 results for `strcasecmp`, C-locale ASCII folding, unchanged high bytes, and `strncasecmp` returning 0 at n=0; these agree with the implementation. The separate `libc.prx` SDK comparison in the logs has different raw-difference results, but the PR clearly scopes its claim to `libSceLibcInternal`. The `feholdexcept`, `fegetexcept`, and `setlocale` claims are also supported by their linked captures. The changed debt entries accurately distinguish measured console behavior from host behavior. The conventions, eligibility, intake, and labels checks pass; this is documentation-only and product test jobs are skipped.
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!11121
No description provided.