feat(libSceLibcInternal): parse numbers in num_get::do_get #21894

Merged
MarrasFederico merged 2 commits from upstream-pr/21894 into main 2026-11-19 23:52:16 +00:00
MarrasFederico commented 2026-11-16 20:30:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarrasFederico on 2026-11-16T20:30:25Z.


What

libSceLibcInternal had parameterless throwing placeholders for the 18 numeric std::num_get::do_get virtual exports, the two _Getffld helpers, and num_get<char>::_Getcat. They now parse integers and floating-point values for both char and wchar_t and allocate the num_get<char> facet.

  • Scope (21 exports):
    • 9 num_get<char>::do_get (double, long double, float, unsigned int, long, unsigned long, unsigned short, long long, unsigned long long) and _Getffld;
    • the matching 9 num_get<wchar_t>::do_get overloads and _Getffld;
    • num_get<char>::_Getcat returning 4 (LC_NUMERIC) and installing a 15-slot GuestLocale::NumGetVtable on guest-heap GuestLocale::Facet.
  • Behaviour: Adapted from pinned Microsoft STL xlocnum for PS5 LP64 and SysV x86_64:
    • long/unsigned long route through 64-bit _Stolx/_Stoulx;
    • unsigned int clamps at UINT32_MAX rather than delegating to 64-bit unsigned long;
    • long double parses as 80-bit extended precision through _Stoldx with decimal/hex exponent bounds raised to 6000/20000;
    • explicit hex float overflow (std::isinf) and underflow checks set failbit, and classic "C" fallback disables thousands separators so "1,234" stops at ',';
    • a leading 0 in a floating-point field counts as the first digit group, as it already does for integers, instead of failing grouping as xlocnum does.
  • Where: Implemented in core/libs/prx/libSceLibcInternal/NumGet.cpp with typed APS5_VABI declarations in ErrExports.hpp and InventoryExports6.hpp, and placeholders removed from Err.cpp and InventoryExports6.cpp.
  • Still a stub: bool& and void*& do_get, _Getifld, _Getffldx, and num_get<wchar_t>::_Getcat keep throwing via NotImplemented_nid_no_patch (getBool/getPointer slots in g_charNumGetVtable throw the same way).
  • Debt: Added docs/dev/debt/changes/feat-libcinternal-num-get-do-get.md removing the 21 stub entries, updating the NumGet.cpp get entry, and adding an entry for the implemented exports (all under 1000 characters).

Tested

Ubuntu 26.04.1 LTS, GCC 15.2.0, Release, BUILD_TESTING=ON, on main at 207fca028a. The branch merges cleanly with main at f2a25e5b42.

  • guest_libc_internal_num_get_do_get: New host-executed guest test covering all 18 numeric do_get overloads (char and wchar_t, buffered and uflow/underflow chunked streambufs), classic "C" "1,234", grouped numpunct (valid, bad, multi-byte, open, CHAR_MAX, heap string), custom ctype widening, base auto/oct/dec/hex, overflow/underflow, 80-bit long double beyond double range, _Getffld V1/V2/hex/bad grouping, and num_get<char>::_Getcat virtual dispatch.

  • Results: ctest -R "^(guest_libc_internal_(num_get|num_get_do_get|numpunct|wide_numpunct|wide_ctype|ctype|facet_put|facet_queries|locale_objects|ios_base|stream|time_get|money_get_put)|guest_locale|guest_sce_v2_locale|guest_sce_v2_facet_ids|guest_sce_v2_locale_basics)$": 17 of 17 pass. The new test passed 3 runs in a row.

  • Negative controls: Seven single-line fault injections in NumGet.cpp (uint overflow clamp, grouping mismatch return, eofbit, 80-bit long double exponent bound, custom ctype<wchar_t> lookup, _Getcat return category, long overflow failbit) each failed guest_libc_internal_num_get_do_get at the matching check before exact restoration.

  • Repository checks: tools/check_conventions.py --base upstream/main: no findings. core/libs/tests/test_public_headers.py --audit-only: 413 libraries, 34651 exports. git diff --check upstream/main...HEAD: clean. Pre-existing unrelated docs/dev/debt/changes/docs-nkwebkit-drop-readded-count-lines.md fails global tools/debt_fold.py --check, while isolated folding of this branch's fragment succeeds cleanly.

  • Independent Windows 11 verification: guest_libc_internal_num_get_do_get passed 3/3 on cf7aa63f5652c9f767324621419ff93600f91590 merged into main at 56c87adbdc. The reviewer reported no additional build failure from this PR. The baseline build had a separate setenv compilation error and Defender quarantined some AGC test executables on both trees.

Overlap: tools/pr_overlap.py --base main --names shows open: none across all 21 symbols in 1756 open PRs. tools/pr_overlap.py --base main --branch notes #17746 (num_put) on header include lines of ErrExports.hpp and 4 uncompared PRs (#13778, #14834, #17300, #18135), none of which implements these exports (#17300 only renames the remaining num_get<wchar_t> _Getffldx/_Getcat stubs).

Checked on November 18, 2026: head cf7aa63f5652c9f767324621419ff93600f91590 has a clean merge with main at 02650d94a5f171dc333d13fc5abed43faf440a1a and passes git diff --check. The published head retains the GCC 13 test portability fix using std::fabs.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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:5344570596 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21894). Originally posted by [MarrasFederico](https://github.com/MarrasFederico) on 2026-11-16T20:30:25Z. --- ### What `libSceLibcInternal` had parameterless throwing placeholders for the 18 numeric `std::num_get::do_get` virtual exports, the two `_Getffld` helpers, and `num_get<char>::_Getcat`. They now parse integers and floating-point values for both `char` and `wchar_t` and allocate the `num_get<char>` facet. - **Scope (21 exports):** - 9 `num_get<char>::do_get` (`double`, `long double`, `float`, `unsigned int`, `long`, `unsigned long`, `unsigned short`, `long long`, `unsigned long long`) and `_Getffld`; - the matching 9 `num_get<wchar_t>::do_get` overloads and `_Getffld`; - `num_get<char>::_Getcat` returning `4` (`LC_NUMERIC`) and installing a 15-slot `GuestLocale::NumGetVtable` on guest-heap `GuestLocale::Facet`. - **Behaviour:** Adapted from pinned Microsoft STL [xlocnum](https://github.com/microsoft/STL/blob/770da5aa457af11f0a796600e1aa6f7f6fce14a6/stl/inc/xlocnum#L285-L1200) for PS5 LP64 and SysV x86_64: - `long`/`unsigned long` route through 64-bit `_Stolx`/`_Stoulx`; - `unsigned int` clamps at `UINT32_MAX` rather than delegating to 64-bit `unsigned long`; - `long double` parses as 80-bit extended precision through `_Stoldx` with decimal/hex exponent bounds raised to `6000`/`20000`; - explicit hex float overflow (`std::isinf`) and underflow checks set `failbit`, and classic `"C"` fallback disables thousands separators so `"1,234"` stops at `','`; - a leading `0` in a floating-point field counts as the first digit group, as it already does for integers, instead of failing grouping as `xlocnum` does. - **Where:** Implemented in `core/libs/prx/libSceLibcInternal/NumGet.cpp` with typed `APS5_VABI` declarations in `ErrExports.hpp` and `InventoryExports6.hpp`, and placeholders removed from `Err.cpp` and `InventoryExports6.cpp`. - **Still a stub:** `bool&` and `void*&` `do_get`, `_Getifld`, `_Getffldx`, and `num_get<wchar_t>::_Getcat` keep throwing via `NotImplemented_nid_no_patch` (`getBool`/`getPointer` slots in `g_charNumGetVtable` throw the same way). - **Debt:** Added `docs/dev/debt/changes/feat-libcinternal-num-get-do-get.md` removing the 21 stub entries, updating the `NumGet.cpp` `get` entry, and adding an entry for the implemented exports (all under 1000 characters). ### Tested Ubuntu 26.04.1 LTS, GCC 15.2.0, Release, `BUILD_TESTING=ON`, on `main` at `207fca028a`. The branch merges cleanly with `main` at `f2a25e5b42`. - **`guest_libc_internal_num_get_do_get`:** New host-executed guest test covering all 18 numeric `do_get` overloads (`char` and `wchar_t`, buffered and `uflow`/`underflow` chunked streambufs), classic `"C"` `"1,234"`, grouped `numpunct` (valid, bad, multi-byte, open, `CHAR_MAX`, heap string), custom `ctype` widening, base auto/oct/dec/hex, overflow/underflow, 80-bit `long double` beyond `double` range, `_Getffld` V1/V2/hex/bad grouping, and `num_get<char>::_Getcat` virtual dispatch. - **Results:** `ctest -R "^(guest_libc_internal_(num_get|num_get_do_get|numpunct|wide_numpunct|wide_ctype|ctype|facet_put|facet_queries|locale_objects|ios_base|stream|time_get|money_get_put)|guest_locale|guest_sce_v2_locale|guest_sce_v2_facet_ids|guest_sce_v2_locale_basics)$"`: 17 of 17 pass. The new test passed 3 runs in a row. - **Negative controls:** Seven single-line fault injections in `NumGet.cpp` (`uint` overflow clamp, grouping mismatch return, `eofbit`, 80-bit `long double` exponent bound, custom `ctype<wchar_t>` lookup, `_Getcat` return category, `long` overflow `failbit`) each failed `guest_libc_internal_num_get_do_get` at the matching check before exact restoration. - **Repository checks:** `tools/check_conventions.py --base upstream/main`: no findings. `core/libs/tests/test_public_headers.py --audit-only`: 413 libraries, 34651 exports. `git diff --check upstream/main...HEAD`: clean. Pre-existing unrelated `docs/dev/debt/changes/docs-nkwebkit-drop-readded-count-lines.md` fails global `tools/debt_fold.py --check`, while isolated folding of this branch's fragment succeeds cleanly. - Independent [Windows 11 verification](https://github.com/boykopovar/AnyPS5/pull/21894#issuecomment-6972585353): `guest_libc_internal_num_get_do_get` passed 3/3 on `cf7aa63f5652c9f767324621419ff93600f91590` merged into `main` at `56c87adbdc`. The reviewer reported no additional build failure from this PR. The baseline build had a separate `setenv` compilation error and Defender quarantined some AGC test executables on both trees. Overlap: `tools/pr_overlap.py --base main --names` shows `open: none` across all 21 symbols in 1756 open PRs. `tools/pr_overlap.py --base main --branch` notes `#17746` (`num_put`) on header include lines of `ErrExports.hpp` and 4 uncompared PRs (`#13778`, `#14834`, `#17300`, `#18135`), none of which implements these exports (`#17300` only renames the remaining `num_get<wchar_t>` `_Getffldx`/`_Getcat` stubs). Checked on November 18, 2026: head `cf7aa63f5652c9f767324621419ff93600f91590` has a clean merge with `main` at `02650d94a5f171dc333d13fc5abed43faf440a1a` and passes `git diff --check`. The published head retains the GCC 13 test portability fix using `std::fabs`. ### Checklist - [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) and the licence notice of code adapted from upstream (see AGENTS.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
PrivacyOnion commented 2026-11-16 20:32:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T20:32:21Z.

Review: CHANGES_REQUESTED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 036b4b315e:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libc_internal_num_get_do_get_tests failed to build.
    core/libs/tests/GuestLibcInternalNumGetDoGet.cpp:553:22: error: ‘fabsl’ is not a member of ‘std’; did you mean ‘fabs’?
    core/libs/tests/GuestLibcInternalNumGetDoGet.cpp:559:46: error: ‘fabsl’ is not a member of ‘std’; did you mean ‘fabs’?
    core/libs/tests/GuestLibcInternalNumGetDoGet.cpp:730:46: error: ‘fabsl’ is not a member of ‘std’; did you mean ‘fabs’?
    core/libs/tests/GuestLibcInternalNumGetDoGet.cpp:895:46: error: ‘fabsl’ is not a member of ‘std’; did you mean ‘fabs’?
    

Requesting changes for the points above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5927103545 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21894#pullrequestreview-5927103545). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-16T20:32:21Z. **Review:** CHANGES_REQUESTED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `036b4b315e`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libc_internal_num_get_do_get_tests` failed to build. ``` core/libs/tests/GuestLibcInternalNumGetDoGet.cpp:553:22: error: ‘fabsl’ is not a member of ‘std’; did you mean ‘fabs’? core/libs/tests/GuestLibcInternalNumGetDoGet.cpp:559:46: error: ‘fabsl’ is not a member of ‘std’; did you mean ‘fabs’? core/libs/tests/GuestLibcInternalNumGetDoGet.cpp:730:46: error: ‘fabsl’ is not a member of ‘std’; did you mean ‘fabs’? core/libs/tests/GuestLibcInternalNumGetDoGet.cpp:895:46: error: ‘fabsl’ is not a member of ‘std’; did you mean ‘fabs’? ``` Requesting changes for the points above.
PrivacyOnion commented 2026-11-16 20:57:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T20:57:08Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against d2b5d909fb:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libc_internal_num_get_do_get_tests built cleanly.
  • CTest (guest_libc_internal_num_get_do_get):
    1/1 Test #4043: guest_libc_internal_num_get_do_get ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibcInternal/Err.cpp, core/libs/prx/libSceLibcInternal/InventoryExports6.cpp, core/libs/prx/libSceLibcInternal/NumGet.cpp, core/libs/prx/libSceLibcInternal/include/ErrExports.hpp, core/libs/prx/libSceLibcInternal/include/InventoryExports6.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified null-pointer checks in ValidateNumGetArgs and GetFloatingFieldExport for stream, state, value, digits, hexExp, and stream->locale
    • Checked integer parsing in ParseIntField, DoGetBoundedUnsigned, and DoGetFullInt, verifying base deduction (octal, hex, decimal), sign handling, and UINT32_MAX clamping
    • Checked floating point parsing in ParseFloatField and DoGetFloat, verifying maxSigDig limits, decimal point conversion via localeconv, exponent bounds clamping, and hex float overflow/underflow checks
    • Verified grouping validation and separator skipping in SkipSeparators, ValidateGroups, and ParseIntField/ParseFloatField
    • Verified 64-bit LP64/LLP64 type conversions and VABI export definitions across all 18 do_get overloads, _Getffld, and _Getcat

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5927514968 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21894#pullrequestreview-5927514968). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-16T20:57:08Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `d2b5d909fb`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libc_internal_num_get_do_get_tests` built cleanly. - **CTest** (`guest_libc_internal_num_get_do_get`): ``` 1/1 Test #4043: guest_libc_internal_num_get_do_get ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceLibcInternal/Err.cpp`, `core/libs/prx/libSceLibcInternal/InventoryExports6.cpp`, `core/libs/prx/libSceLibcInternal/NumGet.cpp`, `core/libs/prx/libSceLibcInternal/include/ErrExports.hpp`, `core/libs/prx/libSceLibcInternal/include/InventoryExports6.hpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified null-pointer checks in ValidateNumGetArgs and GetFloatingFieldExport for stream, state, value, digits, hexExp, and stream->locale - Checked integer parsing in ParseIntField, DoGetBoundedUnsigned, and DoGetFullInt, verifying base deduction (octal, hex, decimal), sign handling, and UINT32_MAX clamping - Checked floating point parsing in ParseFloatField and DoGetFloat, verifying maxSigDig limits, decimal point conversion via localeconv, exponent bounds clamping, and hex float overflow/underflow checks - Verified grouping validation and separator skipping in SkipSeparators, ValidateGroups, and ParseIntField/ParseFloatField - Verified 64-bit LP64/LLP64 type conversions and VABI export definitions across all 18 do_get overloads, _Getffld, and _Getcat Looks Good To Me
PrivacyOnion commented 2026-11-16 22:42:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T22:42:51Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 35ecb7de23:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libc_internal_num_get_do_get_tests built cleanly.
  • CTest (guest_libc_internal_num_get_do_get):
    1/1 Test #4054: guest_libc_internal_num_get_do_get ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibcInternal/Err.cpp, core/libs/prx/libSceLibcInternal/InventoryExports6.cpp, core/libs/prx/libSceLibcInternal/NumGet.cpp, core/libs/prx/libSceLibcInternal/include/ErrExports.hpp, core/libs/prx/libSceLibcInternal/include/InventoryExports6.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • core/libs/prx/libSceLibcInternal/NumGet.cpp: validated null argument handling in ValidateNumGetArgs and GetFloatingFieldExport for stream, state, value, digits, and hexExp
    • core/libs/prx/libSceLibcInternal/NumGet.cpp: verified integer parsing in ParseIntField, DoGetBoundedUnsigned, and DoGetFullInt, including base deduction (octal, hex, decimal), sign handling, and UINT32_MAX clamping
    • core/libs/prx/libSceLibcInternal/NumGet.cpp: checked floating point parsing in ParseFloatField and DoGetFloat, including maxSigDig limits, decimal point conversion via localeconv, exponent bounds clamping, and hex float overflow/underflow checks
    • core/libs/prx/libSceLibcInternal/NumGet.cpp: verified grouping validation and separator skipping in SkipSeparators, ValidateGroups, and ParseIntField/ParseFloatField
    • core/libs/prx/libSceLibcInternal/NumGet.cpp: verified 64-bit LP64/LLP64 type conversions and VABI export definitions across all 18 do_get overloads, _Getffld, and _Getcat
    • core/libs/prx/libSceLibcInternal/NumGet.cpp: verified memory management and vtable initialization in _Getcat, DeleteNumGetFacet, RetainNumGetFacet, and ReleaseNumGetFacet

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5929182538 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21894#pullrequestreview-5929182538). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-16T22:42:51Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `35ecb7de23`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_libc_internal_num_get_do_get_tests` built cleanly. - **CTest** (`guest_libc_internal_num_get_do_get`): ``` 1/1 Test #4054: guest_libc_internal_num_get_do_get ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceLibcInternal/Err.cpp`, `core/libs/prx/libSceLibcInternal/InventoryExports6.cpp`, `core/libs/prx/libSceLibcInternal/NumGet.cpp`, `core/libs/prx/libSceLibcInternal/include/ErrExports.hpp`, `core/libs/prx/libSceLibcInternal/include/InventoryExports6.hpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - core/libs/prx/libSceLibcInternal/NumGet.cpp: validated null argument handling in ValidateNumGetArgs and GetFloatingFieldExport for stream, state, value, digits, and hexExp - core/libs/prx/libSceLibcInternal/NumGet.cpp: verified integer parsing in ParseIntField, DoGetBoundedUnsigned, and DoGetFullInt, including base deduction (octal, hex, decimal), sign handling, and UINT32_MAX clamping - core/libs/prx/libSceLibcInternal/NumGet.cpp: checked floating point parsing in ParseFloatField and DoGetFloat, including maxSigDig limits, decimal point conversion via localeconv, exponent bounds clamping, and hex float overflow/underflow checks - core/libs/prx/libSceLibcInternal/NumGet.cpp: verified grouping validation and separator skipping in SkipSeparators, ValidateGroups, and ParseIntField/ParseFloatField - core/libs/prx/libSceLibcInternal/NumGet.cpp: verified 64-bit LP64/LLP64 type conversions and VABI export definitions across all 18 do_get overloads, _Getffld, and _Getcat - core/libs/prx/libSceLibcInternal/NumGet.cpp: verified memory management and vtable initialization in _Getcat, DeleteNumGetFacet, RetainNumGetFacet, and ReleaseNumGetFacet Looks Good To Me
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!21894
No description provided.