feat(libc): implement floating-point prefix helpers #9772

Merged
UnhealthyKraken merged 5 commits from upstream-pr/9772 into main 2026-10-28 04:49:14 +00:00
UnhealthyKraken commented 2026-10-22 14:08:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by UnhealthyKraken on 2026-10-22T14:08:34Z.


What

Implement _Stopfx and _WStopfx in the common libc provider. They classify a floating-point prefix and update the input cursor without converting the number or consuming its digits. Decimal/hexadecimal paths leave the optional end pointer unchanged; NaN/infinity update it, including rollback on an incomplete keyword. NaN discards a leading minus flag; infinity retains it.

Names/NIDs are in the PS5 3.20 inventory. Behavior follows pinned Dinkumware V6 xstopfx.c and xwstopfx.c. Sony signatures/configuration, locale equivalence and module/library versions remain unmeasured; the wide helper uses the existing 16-bit guest string ABI. Unknown null-input behavior remains unsupported.

The review revision removes CheckUnsupported and its calls, retaining valid-prefix, cursor/end-pointer, case/payload, guarded-read and concurrent coverage. Public declarations now live once in libc's API header; the implementation uses that header for its classifiers as required by current main.

Tested

Review revision 14b096d3d68406aeccc7b56f510f0d8616447cb1, based on main 47f9cee2cd77 by history-preserving merge.

Hosted Linux actual project configure/focused build passed with matching source-built libraries: all four narrow/wide raw/patched tests pass once plus two repetitions each. Conventions, whitespace, public-header audit and standalone libc/kernel header compilation pass. Linux job. Windows final-head actual project configure/affected-target build passed on hosted WinLibs GCC 15.2 Release with matching runtime libraries: 4/4 focused tests, followed by two repetitions each. Windows job. Git-only mergeability against later fetched main 504ea3b53b23 is clean; that later combined tree was not built.

Original Windows regression-first evidence used identical executables: four missing-export failures/three existing passes on baseline, then 7/7 on candidate, plus a NaN-sign negative control and restored pass. The reference/guest locale and firmware-equivalence limitations remain in debt.

No local builds/runtime tests, games, proprietary modules or physical-console execution were performed for this revision. The full repository suite was not 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
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4968758731 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9772). Originally posted by [UnhealthyKraken](https://github.com/UnhealthyKraken) on 2026-10-22T14:08:34Z. --- ### What Implement `_Stopfx` and `_WStopfx` in the common libc provider. They classify a floating-point prefix and update the input cursor without converting the number or consuming its digits. Decimal/hexadecimal paths leave the optional end pointer unchanged; NaN/infinity update it, including rollback on an incomplete keyword. NaN discards a leading minus flag; infinity retains it. Names/NIDs are in the [PS5 3.20 inventory](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceLibcInternal.c). Behavior follows pinned Dinkumware V6 [xstopfx.c](https://github.com/ganboing/crt.vc12/blob/f1d47126bf13d1c9dccaa6c53b72217fd0474968/src/xstopfx.c) and [xwstopfx.c](https://github.com/ganboing/crt.vc12/blob/f1d47126bf13d1c9dccaa6c53b72217fd0474968/src/xwstopfx.c). Sony signatures/configuration, locale equivalence and module/library versions remain unmeasured; the wide helper uses the existing 16-bit guest string ABI. Unknown null-input behavior remains unsupported. The review revision removes CheckUnsupported and its calls, retaining valid-prefix, cursor/end-pointer, case/payload, guarded-read and concurrent coverage. Public declarations now live once in libc's API header; the implementation uses that header for its classifiers as required by current main. ### Tested Review revision `14b096d3d68406aeccc7b56f510f0d8616447cb1`, based on main `47f9cee2cd77` by history-preserving merge. Hosted Linux actual project configure/focused build passed with matching source-built libraries: all four narrow/wide raw/patched tests pass once plus two repetitions each. Conventions, whitespace, public-header audit and standalone libc/kernel header compilation pass. [Linux job](https://github.com/UnhealthyKraken/AnyPS5/actions/runs/40251248364/job/121343419586). Windows final-head actual project configure/affected-target build passed on hosted WinLibs GCC 15.2 Release with matching runtime libraries: 4/4 focused tests, followed by two repetitions each. [Windows job](https://github.com/UnhealthyKraken/AnyPS5/actions/runs/40251248364/job/121349451462). Git-only mergeability against later fetched main `504ea3b53b23` is clean; that later combined tree was not built. Original Windows regression-first evidence used identical executables: four missing-export failures/three existing passes on baseline, then 7/7 on candidate, plus a NaN-sign negative control and restored pass. The reference/guest locale and firmware-equivalence limitations remain in debt. No local builds/runtime tests, games, proprietary modules or physical-console execution were performed for this revision. The full repository suite was not run. <!-- 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. --> ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
MarcZX10 commented 2026-10-22 14:39:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T14:39:45Z.

Review: APPROVED


I compared ParsePrefix with the pinned Dinkumware _Stopfx and _WStopfx implementations: sign flags, decimal/hex lookahead, special-token rollback, NaN payload handling and the end-pointer write cases match. The narrow classifier receives an unsigned byte; the wide helper uses the documented guest UTF-16 path. The test covers malformed and mixed-case prefixes, cursor/end-pointer behavior, all narrow payload bytes, guard-page reads and concurrent calls, with a negative control and a separately compiled reference harness.

Current-main merge-tree, diff-check and conventions are clean; the intervening main commits do not touch these parser or registration paths. Hosted conventions, relinker/ASan, write-watch and the register-context matrix pass. To be precise, the register-context job is a separate test suite and does not run guest_floating_prefix; Linux/Windows product jobs are skipped. The Windows raw/patched focused run and Linux reference comparison in the PR are author-reported. I did not run a local libc build because there is no configured build here and less than 1 GB free on disk. I found no implementation duplicate or actionable code issue.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5615998975 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9772#pullrequestreview-5615998975). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T14:39:45Z. **Review:** APPROVED --- I compared `ParsePrefix` with the pinned Dinkumware `_Stopfx` and `_WStopfx` implementations: sign flags, decimal/hex lookahead, special-token rollback, NaN payload handling and the end-pointer write cases match. The narrow classifier receives an unsigned byte; the wide helper uses the documented guest UTF-16 path. The test covers malformed and mixed-case prefixes, cursor/end-pointer behavior, all narrow payload bytes, guard-page reads and concurrent calls, with a negative control and a separately compiled reference harness. Current-main merge-tree, diff-check and conventions are clean; the intervening main commits do not touch these parser or registration paths. Hosted conventions, relinker/ASan, write-watch and the register-context matrix pass. To be precise, the register-context job is a separate test suite and does not run `guest_floating_prefix`; Linux/Windows product jobs are skipped. The Windows raw/patched focused run and Linux reference comparison in the PR are author-reported. I did not run a local libc build because there is no configured build here and less than 1 GB free on disk. I found no implementation duplicate or actionable code issue.
UnhealthyKraken commented 2026-10-22 14:43:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by UnhealthyKraken on 2026-10-22T14:43:40Z.


Thank you for the source review and precise validation boundaries. I have kept the pinned Dinkumware contract separate from unmeasured Sony behavior, and the focused author-run raw/patched regression results separate from hosted register-context/relinker checks. No additional code change is needed for this review. The full Linux/Windows product jobs remain skipped; your review did not claim a local libc build. This completes the current follow-up pass before the requested wider-audit pause.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6343559735 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9772#issuecomment-6343559735). Originally posted by [UnhealthyKraken](https://github.com/UnhealthyKraken) on 2026-10-22T14:43:40Z. --- Thank you for the source review and precise validation boundaries. I have kept the pinned Dinkumware contract separate from unmeasured Sony behavior, and the focused author-run raw/patched regression results separate from hosted register-context/relinker checks. No additional code change is needed for this review. The full Linux/Windows product jobs remain skipped; your review did not claim a local libc build. This completes the current follow-up pass before the requested wider-audit pause.
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!9772
No description provided.