fix(libc): preserve Dinkumware zero signs when no conversion occurs #14595

Merged
Danigamer05 merged 2 commits from upstream-pr/14595 into main 2026-11-14 03:55:40 +00:00
Danigamer05 commented 2026-11-01 16:14:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Danigamer05 on 2026-11-01T16:14:23Z.


What

When the host parser consumes no characters, ScaledFloat now obtains the zero sign from _Stopfx. For example, _Stodx("-z", ...) and _WStod(u"-z", ...) return negative zero while keeping the end pointer at the original input. Incomplete -i and -n prefixes retain positive zero. This changes the shared _Stodx / _Stofx / _Stoldx path and the wide wrappers added by #11733, without changing strtod or adding exports.

The contract was read and executed from PPSA03671 v01.001.005's bundled libc.prx (SHA-256 483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6). No original binary or extracted bytes are committed. The debt edit removes only the corrected zero-sign gap and retains the other parser qualifications.

Tested

Windows x86-64, WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON, main f2d874c1fdccf781c0fa5d86619bb5dd8894b958.

  • Compiled libc and the affected test executables. All 12 selected CTests pass: guest_dinkumware_internals, guest_wide_conversion, guest_math, guest_math_exact, guest_wide_strings, guest_strtod_subnormal, all four guest_floating_prefix_* cases, public_headers and libc_floating_point_contraction.
  • Negative control: the same regression tests with main's production source fail guest_dinkumware_internals and guest_wide_conversion; the other nine selected baseline tests pass.
  • Direct native comparison of the original module and the patched production library: 2,073,600 comparisons, zero differences after the change versus 506,880 differences before it. Six narrow/wide exports, 120 no-conversion texts, five scales including both int64 limits, three initial errno values, optional end/error pointers, four rounding modes, four DAZ/FTZ combinations and four initial floating-exception states. Compared result bits, final pointers, errno, error output, x87 exception flags/control and MXCSR. Original initializers are not run; unknown imports stop the comparison. This qualifies no-conversion behavior on this SDK module, not all numeric inputs or the console system libc.
  • Executable code was tested at 6af78ee89c; the final 5f320fed14 changes only documentation, with byte-identical C++ sources. Conventions were rerun on the final head: all checks pass. git diff --check passes.
  • Refreshed official overlap check: 1,796 open PRs, no confirmed overlap. It retains exit 2 for 31 branches already conflicting with main, sharing only the debt file. Their debt diffs were checked against every merge base; none changes the _WStod / _WStof / _WStold entry. This does not claim those branches merge cleanly. #11892 changes wcstod's subnormal-errno path and does not contain this correction.

Not tested: Linux, macOS, unmasked floating exceptions, non-C locales, another SDK, a title or a console. This is not a complete qualification of the wide floating conversions.

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:5109151486 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14595). Originally posted by [Danigamer05](https://github.com/Danigamer05) on 2026-11-01T16:14:23Z. --- ### What When the host parser consumes no characters, `ScaledFloat` now obtains the zero sign from `_Stopfx`. For example, `_Stodx("-z", ...)` and `_WStod(u"-z", ...)` return negative zero while keeping the end pointer at the original input. Incomplete `-i` and `-n` prefixes retain positive zero. This changes the shared `_Stodx` / `_Stofx` / `_Stoldx` path and the wide wrappers added by #11733, without changing `strtod` or adding exports. The contract was read and executed from PPSA03671 v01.001.005's bundled `libc.prx` (SHA-256 `483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6`). No original binary or extracted bytes are committed. The debt edit removes only the corrected zero-sign gap and retains the other parser qualifications. ### 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 `f2d874c1fdccf781c0fa5d86619bb5dd8894b958`. - Compiled libc and the affected test executables. All 12 selected CTests pass: `guest_dinkumware_internals`, `guest_wide_conversion`, `guest_math`, `guest_math_exact`, `guest_wide_strings`, `guest_strtod_subnormal`, all four `guest_floating_prefix_*` cases, `public_headers` and `libc_floating_point_contraction`. - Negative control: the same regression tests with main's production source fail `guest_dinkumware_internals` and `guest_wide_conversion`; the other nine selected baseline tests pass. - Direct native comparison of the original module and the patched production library: 2,073,600 comparisons, zero differences after the change versus 506,880 differences before it. Six narrow/wide exports, 120 no-conversion texts, five scales including both int64 limits, three initial errno values, optional end/error pointers, four rounding modes, four DAZ/FTZ combinations and four initial floating-exception states. Compared result bits, final pointers, errno, error output, x87 exception flags/control and MXCSR. Original initializers are not run; unknown imports stop the comparison. This qualifies no-conversion behavior on this SDK module, not all numeric inputs or the console system libc. - Executable code was tested at `6af78ee89c`; the final `5f320fed14` changes only documentation, with byte-identical C++ sources. Conventions were rerun on the final head: all checks pass. `git diff --check` passes. - Refreshed official overlap check: 1,796 open PRs, no confirmed overlap. It retains exit 2 for 31 branches already conflicting with main, sharing only the debt file. Their debt diffs were checked against every merge base; none changes the `_WStod` / `_WStof` / `_WStold` entry. This does not claim those branches merge cleanly. #11892 changes `wcstod`'s subnormal-errno path and does not contain this correction. Not tested: Linux, macOS, unmasked floating exceptions, non-C locales, another SDK, a title or a console. This is not a complete qualification of the wide floating conversions. ### 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
CnRJay commented 2026-11-01 19:48:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:48:52Z.

Review: COMMENTED


Withdrawn. This review applied a title-ID/log requirement that is not in CONTRIBUTING (Unblocks: none is allowed), and it contained no code review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729920465 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14595#pullrequestreview-5729920465). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T19:48:52Z. **Review:** COMMENTED --- Withdrawn. This review applied a title-ID/log requirement that is not in CONTRIBUTING (`Unblocks: none` is allowed), and it contained no code review.
MarcZX10 commented 2026-11-02 04:51:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T04:51:17Z.

Review: COMMENTED


Reviewed — no blocking findings

When a Dinkumware strtod-family conversion consumes nothing, the change returns a zero whose sign follows the leading - that _Stopfx reports (bit 8). I traced ParsePrefix (FloatingPrefix.cpp lines 29-71) for each row of the test's no-conversion table: -z, - 5, -. and --1 give a negative zero; -i and -n reset the result and give a positive zero; +z and an empty string give a positive zero. The hosted Windows run passed guest_wide_conversion. The debt entry's measurement claims for the wide functions were not verified here.

What I ran

  • Head 5f320fed149ec62183fba3263bafe94c08754e0a; base f2d874c1fdccf781c0fa5d86619bb5dd8894b958. 4 files, +54/-1: core/libs/prx/libc/src/DinkumwareInternals.cpp (+5), core/libs/tests/GuestDinkumwareInternals.cpp (+24), core/libs/tests/GuestWideConversion.cpp (+24) and docs/dev/debt/libc.md.
  • Read the changed function (DinkumwareInternals.cpp lines 216-223 at head), ParsePrefix (FloatingPrefix.cpp lines 29-71 at base), and the no-conversion table in the test.
  • Registration: guest_dinkumware_internals_tests (libc/CMakeLists.txt line 795) and guest_wide_conversion_tests (line 452).
  • Read-only checks from the trusted main checkout (precheck not run: this session does not run code from PR heads): diff check, conventions and the stack check passed; the ABI audit reported 25 symbols with no findings.
  • Hosted: the windows CTest run has two cases, guest_wide_conversion (Passed) and a tool check; guest_dinkumware_internals was compiled and was not in the run.
  • No MarcZX10 review at this head.

Results

Check Result Note
Diff check passed
Conventions and PR template passed conventions check from the main checkout
Mergeability and dependencies passed depends on none; the stack check passed
Sign of zero for -z, - 5, -., --1 passed ParsePrefix sets bit 8 from the leading - (line 35), and the result keeps it
Sign of zero for -i and -n passed the word test fails and resets the result to 0 (lines 52-57 and 40-45)
+z and the empty string passed no sign bit
guest_wide_conversion (hosted) passed in the Windows CTest run
guest_dinkumware_internals (hosted) not run compiled, not in the Windows CTest run
Debt-entry measurement claims (wide functions) not verified based on SDK 7.00 libc.prx comparisons not repeated here
ABI audit (main-checkout tool) passed 25 symbols, no findings
Build and runtime tests not run no local build
Negative controls not run no local build
Hosted CI passed windows passed (two CTest cases); linux and relinkers skipped
Read-only check output

Precheck was not run: this session does not run code from PR heads. The two "possible-unregistered" heuristic flags are false positives: both test files are registered (see Results notes). Hosted: gh api repos/boykopovar/AnyPS5/commits/5f320fed149ec62183fba3263bafe94c08754e0a/check-runs.

Negative control

Not run here. A negative control needs a build, and code from this head is not run here.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

  • The debt entry's measurements for the wide functions (SDK 7.00 comparisons) were not repeated.
  • guest_dinkumware_internals did not run hosted.

To get this to a good state

  • Nothing blocking. A run of guest_dinkumware_internals on Windows, or a note of how it was run, would close the hosted gap.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5732210297 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14595#pullrequestreview-5732210297). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-02T04:51:17Z. **Review:** COMMENTED --- # Reviewed — no blocking findings When a Dinkumware `strtod`-family conversion consumes nothing, the change returns a zero whose sign follows the leading `-` that `_Stopfx` reports (bit 8). I traced `ParsePrefix` (`FloatingPrefix.cpp` lines 29-71) for each row of the test's no-conversion table: `-z`, `- 5`, `-.` and `--1` give a negative zero; `-i` and `-n` reset the result and give a positive zero; `+z` and an empty string give a positive zero. The hosted Windows run passed `guest_wide_conversion`. The debt entry's measurement claims for the wide functions were not verified here. ## What I ran - Head `5f320fed149ec62183fba3263bafe94c08754e0a`; base `f2d874c1fdccf781c0fa5d86619bb5dd8894b958`. 4 files, +54/-1: `core/libs/prx/libc/src/DinkumwareInternals.cpp` (+5), `core/libs/tests/GuestDinkumwareInternals.cpp` (+24), `core/libs/tests/GuestWideConversion.cpp` (+24) and `docs/dev/debt/libc.md`. - Read the changed function (`DinkumwareInternals.cpp` lines 216-223 at head), `ParsePrefix` (`FloatingPrefix.cpp` lines 29-71 at base), and the no-conversion table in the test. - Registration: `guest_dinkumware_internals_tests` (`libc/CMakeLists.txt` line 795) and `guest_wide_conversion_tests` (line 452). - Read-only checks from the trusted main checkout (precheck not run: this session does not run code from PR heads): diff check, conventions and the stack check passed; the ABI audit reported 25 symbols with no findings. - Hosted: the windows CTest run has two cases, `guest_wide_conversion` (Passed) and a tool check; `guest_dinkumware_internals` was compiled and was not in the run. - No MarcZX10 review at this head. ## Results | Check | Result | Note | | --- | --- | --- | | Diff check | passed | | | Conventions and PR template | passed | conventions check from the main checkout | | Mergeability and dependencies | passed | depends on none; the stack check passed | | Sign of zero for `-z`, `- 5`, `-.`, `--1` | passed | `ParsePrefix` sets bit 8 from the leading `-` (line 35), and the result keeps it | | Sign of zero for `-i` and `-n` | passed | the word test fails and resets the result to 0 (lines 52-57 and 40-45) | | `+z` and the empty string | passed | no sign bit | | `guest_wide_conversion` (hosted) | passed | in the Windows CTest run | | `guest_dinkumware_internals` (hosted) | not run | compiled, not in the Windows CTest run | | Debt-entry measurement claims (wide functions) | not verified | based on SDK 7.00 `libc.prx` comparisons not repeated here | | ABI audit (main-checkout tool) | passed | 25 symbols, no findings | | Build and runtime tests | not run | no local build | | Negative controls | not run | no local build | | Hosted CI | passed | windows passed (two CTest cases); linux and relinkers skipped | <details><summary>Read-only check output</summary> Precheck was not run: this session does not run code from PR heads. The two "possible-unregistered" heuristic flags are false positives: both test files are registered (see Results notes). Hosted: `gh api repos/boykopovar/AnyPS5/commits/5f320fed149ec62183fba3263bafe94c08754e0a/check-runs`. </details> ## Negative control Not run here. A negative control needs a build, and code from this head is not run here. ## Findings **Blocking** None. **Non-blocking** None. ## Sources - Changed function: https://github.com/boykopovar/AnyPS5/blob/5f320fed149ec62183fba3263bafe94c08754e0a/core/libs/prx/libc/src/DinkumwareInternals.cpp#L216-L223 - `ParsePrefix`: https://github.com/boykopovar/AnyPS5/blob/f2d874c1fdccf781c0fa5d86619bb5dd8894b958/core/libs/prx/libc/src/FloatingPrefix.cpp#L29-L71 - Registration: https://github.com/boykopovar/AnyPS5/blob/5f320fed149ec62183fba3263bafe94c08754e0a/core/libs/prx/libc/CMakeLists.txt#L452 and #L795 ## Not verified - The debt entry's measurements for the wide functions (SDK 7.00 comparisons) were not repeated. - `guest_dinkumware_internals` did not run hosted. ## To get this to a good state - Nothing blocking. A run of `guest_dinkumware_internals` on Windows, or a note of how it was run, would close the hosted gap.
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!14595
No description provided.