feat(libc): implement _Erfc, _FErfc and _LErfc Dinkumware math helpers #12365

Closed
PrivacyOnion wants to merge 4 commits from upstream-pr/12365 into main
PrivacyOnion commented 2026-10-28 11:02:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-10-28T11:02:04Z.


What

Implement the PS5 3.20 Dinkumware sub-range complementary error function helpers _Erfc, _FErfc, and _LErfc in libc (core/libs/prx/libc/include/Api.hpp, core/libs/prx/libc/src/DinkumwareInternals.cpp), retaining the verbatim P.J. Plauger copyright and licence notice from pinned Dinkumware xxxerfc.h at the top of DinkumwareInternals.cpp. Rational approximations evaluate exp(-x * x) * NPOLY(x) / DPOLY(x) with _Exp_nid_postfix, _FExp_nid_postfix, and expl_nid_postfix, using coefficient tables derived from xxxerfc.h and propagating NaN on invalid inputs. Provenance: names and NIDs follow the PS5 3.20 export inventory libSceLibcInternal.c.

Record technical debt in docs/dev/debt/libc.md: contract preconditions restrict inputs to precision sub-ranges ([1.523, 5.84] for double, [1.523, 3.82] for float, [1.523, 6.45] for long double) with caller dispatch performing sign reflection and cutoff handling, note out-of-range evaluation matching 13.42 export measurements, and record unverified console signatures, results, exceptions, and non-FMA ULP deltas. Unit tests in core/libs/tests/GuestDinkumwareInternals.cpp cover in-range sub-domain inputs (1.523, 3.0), pin unfused polynomial evaluation, and check quiet-NaN propagation.

Sequencing: The branch is based on main directly and shares insertion sites with #12363 and #12364 (Api.hpp, DinkumwareInternals.cpp, GuestDinkumwareInternals.cpp, and docs/dev/debt/libc.md). Coordinated with #11752 on NID exports.

Tested

Windows 11 x86_64, ran guest_dinkumware_internals unit test verifying in-domain sub-range rational evaluation, unfused polynomial evaluation, and quiet-NaN propagation for _Erfc, _FErfc, and _LErfc.

Ran locally on 2fd4997231:

$ ctest --test-dir build -R '^guest_dinkumware_internals$' --output-on-failure
    Start 592: guest_dinkumware_internals
1/1 Test #592: guest_dinkumware_internals .......   Passed    0.02 sec

100% tests passed, 0 tests failed out of 1

Total Test time (real) =   0.18 sec

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: #11752
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5049367295 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12365). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-10-28T11:02:04Z. --- ### What Implement the PS5 3.20 Dinkumware sub-range complementary error function helpers `_Erfc`, `_FErfc`, and `_LErfc` in `libc` (`core/libs/prx/libc/include/Api.hpp`, `core/libs/prx/libc/src/DinkumwareInternals.cpp`), retaining the verbatim P.J. Plauger copyright and licence notice from pinned Dinkumware [`xxxerfc.h`](https://github.com/bergsteiger/realwork/blob/19b446ce8ad2adf82ab8ce7988bc003221accad2/common/components/rtl/external/Embarcadero/DelphiBerlin/cpprtl/Source/dinkumware64/source/xxxerfc.h) at the top of `DinkumwareInternals.cpp`. Rational approximations evaluate `exp(-x * x) * NPOLY(x) / DPOLY(x)` with `_Exp_nid_postfix`, `_FExp_nid_postfix`, and `expl_nid_postfix`, using coefficient tables derived from `xxxerfc.h` and propagating NaN on invalid inputs. Provenance: names and NIDs follow the PS5 3.20 export inventory [`libSceLibcInternal.c`](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceLibcInternal.c#L15996). Record technical debt in `docs/dev/debt/libc.md`: contract preconditions restrict inputs to precision sub-ranges (`[1.523, 5.84]` for double, `[1.523, 3.82]` for float, `[1.523, 6.45]` for long double) with caller dispatch performing sign reflection and cutoff handling, note out-of-range evaluation matching 13.42 export measurements, and record unverified console signatures, results, exceptions, and non-FMA ULP deltas. Unit tests in `core/libs/tests/GuestDinkumwareInternals.cpp` cover in-range sub-domain inputs (`1.523`, `3.0`), pin unfused polynomial evaluation, and check quiet-NaN propagation. Sequencing: The branch is based on `main` directly and shares insertion sites with #12363 and #12364 (`Api.hpp`, `DinkumwareInternals.cpp`, `GuestDinkumwareInternals.cpp`, and `docs/dev/debt/libc.md`). Coordinated with #11752 on NID exports. ### Tested Windows 11 x86_64, ran guest_dinkumware_internals unit test verifying in-domain sub-range rational evaluation, unfused polynomial evaluation, and quiet-NaN propagation for _Erfc, _FErfc, and _LErfc. Ran locally on `2fd4997231`: ``` $ ctest --test-dir build -R '^guest_dinkumware_internals$' --output-on-failure Start 592: guest_dinkumware_internals 1/1 Test #592: guest_dinkumware_internals ....... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 Total Test time (real) = 0.18 sec ``` ### 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: #11752 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
rooklz commented 2026-10-28 13:22:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-28T13:22:49Z.

Review: COMMENTED


macOS check at head 5c11861612 (base main 3a40945e62; merges cleanly onto 750cf6cf48)

Forwarding _Erfc/_FErfc/_LErfc to the existing erfc/erfcf/erfcl exports looks right to me. The NIDs match tools/nid_names.py hashing of the three names (aQURHgjHo-w, qwR1gtp-WS0, PG4HVe4X+Oc). The debt entry says correctly that console behaviour is unverified.

  • check_conventions.py --base upstream/main: passes. Relinker-only build + ctest on macOS: 378/378.
  • pr_overlap.py: no conflicting files or same exports among the 153 comparable PRs.
  • Merge order with #12364 (_Rint): the body lists #12364 under Depends on, but this branch is not stacked on it. It is based on main directly. Both PRs append at the same place in DinkumwareInternals.cpp, GuestDinkumwareInternals.cpp and debt/libc.md, so git merge-tree reports content conflicts in all three files. They are additive and easy to resolve, but whichever lands second needs a rebase. "Depends on: none, conflicts textually with #12364" would describe it more accurately.
  • #10321 / #10226 (JJenkx) change how erfc/erfcf are computed. Because these helpers forward, they pick up that change automatically. That's another reason for the tests to compare against erfc*_nid_postfix rather than std::erfc.

Tests don't discriminate. I built the three bodies as a separate TU with sysv_abi and ran the PR's four Require lines unchanged, using Apple clang -O2 on x86_64 (Rosetta) and on arm64. All of these mutants pass the PR's tests:

mutant PR tests + 3 lines below (x86_64) arm64
head OK OK OK
1 - erf(x) for all three (loses the tail) OK RED (3) RED
_LErfc → erfc_nid_postfix((double)x) (narrowing) OK RED OK (long double == double, equivalent)
_LErfc → x == 0 ? 1 : 0 OK RED RED
_Erfc → x == 0 ? 1 : x > 0 ? 0 : 2 OK RED RED

0, ±inf are fixed points that any erfc-shaped function hits exactly. A tail argument, compared to the forwarded export, kills all four:

    Require(_Erfc_nid_postfix(10.0) == erfc_nid_postfix(10.0) && _Erfc_nid_postfix(10.0) > 0.0, "_Erfc tail");
    Require(_FErfc_nid_postfix(5.0f) == erfcf_nid_postfix(5.0f) && _FErfc_nid_postfix(5.0f) > 0.0f, "_FErfc tail");
    Require(_LErfc_nid_postfix(27.0L) == erfcl_nid_postfix(27.0L) && _LErfc_nid_postfix(27.0L) > 0.0L, "_LErfc tail");

(erfc(27) is subnormal in double (0x1.9e0fp-1058, low precision) but a full-precision normal in x87 extended (0xc.f07866fc1d3afd4p-1061), so on x86_64 the third line also catches narrowing to double.) The erfc*_nid_postfix declarations are already in Api.hpp, which the test includes.

I didn't build the full guest_dinkumware_internals_tests target, because the libc submodules aren't available here. The harness uses the PR's code and test lines verbatim.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5683257362 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12365#pullrequestreview-5683257362). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-28T13:22:49Z. **Review:** COMMENTED --- ### macOS check at head `5c11861612` (base `main` `3a40945e62`; merges cleanly onto `750cf6cf48`) Forwarding `_Erfc`/`_FErfc`/`_LErfc` to the existing `erfc`/`erfcf`/`erfcl` exports looks right to me. The NIDs match `tools/nid_names.py` hashing of the three names (`aQURHgjHo-w`, `qwR1gtp-WS0`, `PG4HVe4X+Oc`). The debt entry says correctly that console behaviour is unverified. - `check_conventions.py --base upstream/main`: passes. Relinker-only build + ctest on macOS: 378/378. - `pr_overlap.py`: no conflicting files or same exports among the 153 comparable PRs. - **Merge order with #12364 (`_Rint`):** the body lists #12364 under **Depends on**, but this branch is not stacked on it. It is based on `main` directly. Both PRs append at the same place in `DinkumwareInternals.cpp`, `GuestDinkumwareInternals.cpp` and `debt/libc.md`, so `git merge-tree` reports content conflicts in all three files. They are additive and easy to resolve, but whichever lands second needs a rebase. "Depends on: none, conflicts textually with #12364" would describe it more accurately. - #10321 / #10226 (JJenkx) change how `erfc`/`erfcf` are computed. Because these helpers forward, they pick up that change automatically. That's another reason for the tests to compare against `erfc*_nid_postfix` rather than `std::erfc`. **Tests don't discriminate.** I built the three bodies as a separate TU with `sysv_abi` and ran the PR's four `Require` lines unchanged, using Apple clang -O2 on x86_64 (Rosetta) and on arm64. All of these mutants **pass** the PR's tests: | mutant | PR tests | + 3 lines below (x86_64) | arm64 | |---|---|---|---| | head | OK | OK | OK | | `1 - erf(x)` for all three (loses the tail) | OK | RED (3) | RED | | `_LErfc` → `erfc_nid_postfix((double)x)` (narrowing) | OK | RED | OK (long double == double, equivalent) | | `_LErfc` → `x == 0 ? 1 : 0` | OK | RED | RED | | `_Erfc` → `x == 0 ? 1 : x > 0 ? 0 : 2` | OK | RED | RED | 0, ±inf are fixed points that any erfc-shaped function hits exactly. A tail argument, compared to the forwarded export, kills all four: ```cpp Require(_Erfc_nid_postfix(10.0) == erfc_nid_postfix(10.0) && _Erfc_nid_postfix(10.0) > 0.0, "_Erfc tail"); Require(_FErfc_nid_postfix(5.0f) == erfcf_nid_postfix(5.0f) && _FErfc_nid_postfix(5.0f) > 0.0f, "_FErfc tail"); Require(_LErfc_nid_postfix(27.0L) == erfcl_nid_postfix(27.0L) && _LErfc_nid_postfix(27.0L) > 0.0L, "_LErfc tail"); ``` (`erfc(27)` is subnormal in double (`0x1.9e0fp-1058`, low precision) but a full-precision normal in x87 extended (`0xc.f07866fc1d3afd4p-1061`), so on x86_64 the third line also catches narrowing to double.) The `erfc*_nid_postfix` declarations are already in `Api.hpp`, which the test includes. I didn't build the full `guest_dinkumware_internals_tests` target, because the libc submodules aren't available here. The harness uses the PR's code and test lines verbatim.
rooklz commented 2026-10-28 14:34:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-28T14:34:11Z.

Review: COMMENTED


macOS re-check at head cd0317aab9 (merges cleanly onto main 446bd8776c)

My iter109 point no longer applies: the helpers stopped forwarding to erfc* and now evaluate the sub-range rational form, so the tail lines I posted then don't fit. I checked the new head again.

  • check_conventions.py --base upstream/main: passes. git merge-tree against 446bd8776c: clean.
  • I built DinkumwareInternals.cpp unchanged with Apple clang -O2 -ffp-contract=off for x86_64 (Rosetta), linked it to stubs for the imports it doesn't need here, and ran the PR's ten new Require lines verbatim. All of them pass. (On arm64 _LErfc finite fails because long double is 64-bit there. That's expected, and the libc lane doesn't target it.)
  • Mutants:
mutant PR tests
drop the isnan(y) early return RED (_Erfc special, _FErfc special)
_LErfc through double std::exp RED (_LErfc finite)
_Erfc as std::exp(z) * y instead of _Exp(&z, y, 0) RED (_Erfc 3)
EvaluatePolynomial with std::fma passes

The tests don't pin the unfused choice that the debt entry documents. Going by @BunnyFl's numbers, the firmware is the FMA build, so a fused mutant agrees with the 13.42 table to the digits the tests compare. Non-blocking: if unfused evaluation is meant to be kept, a bit-exact input from @BunnyFl's differential run where the two disagree would lock it in.

Provenance question for the maintainers. The coefficient tables are taken verbatim from xxxerfc.h. It is a file from the Dinkumware C library shipped in Embarcadero's C++Builder RTL source, in a third-party GitHub repo with no licence (bergsteiger/realwork; the header starts /* xxxerfc.h -- common _[FL]Erfc functionality */). There is precedent for citing Dinkumware headers: #9631 (merged) and the _Thrd_sleep / _Fetch_* debt entries cite VC12 CRT sources. But those cite them for types and semantics. This PR copies a data table that was redistributed without a licence. REVERSE_ENGINEERING.md asks contributors to "rebuild data tables from a public source when one exists". I can't tell whether these coefficients have a public origin (for example a published minimax fit), so I'm asking @boykopovar / the maintainers to say whether this source is acceptable before merging. I'm not blocking on it.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5684384582 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12365#pullrequestreview-5684384582). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-28T14:34:11Z. **Review:** COMMENTED --- ### macOS re-check at head `cd0317aab9` (merges cleanly onto `main` `446bd8776c`) My iter109 point no longer applies: the helpers stopped forwarding to `erfc*` and now evaluate the sub-range rational form, so the tail lines I posted then don't fit. I checked the new head again. - `check_conventions.py --base upstream/main`: passes. `git merge-tree` against `446bd8776c`: clean. - I built `DinkumwareInternals.cpp` unchanged with Apple clang `-O2 -ffp-contract=off` for x86_64 (Rosetta), linked it to stubs for the imports it doesn't need here, and ran the PR's ten new `Require` lines verbatim. All of them pass. (On arm64 `_LErfc finite` fails because `long double` is 64-bit there. That's expected, and the libc lane doesn't target it.) - Mutants: | mutant | PR tests | |---|---| | drop the `isnan(y)` early return | RED (`_Erfc special`, `_FErfc special`) | | `_LErfc` through double `std::exp` | RED (`_LErfc finite`) | | `_Erfc` as `std::exp(z) * y` instead of `_Exp(&z, y, 0)` | RED (`_Erfc 3`) | | `EvaluatePolynomial` with `std::fma` | **passes** | The tests don't pin the unfused choice that the debt entry documents. Going by @BunnyFl's numbers, the firmware is the FMA build, so a fused mutant agrees with the 13.42 table to the digits the tests compare. Non-blocking: if unfused evaluation is meant to be kept, a bit-exact input from @BunnyFl's differential run where the two disagree would lock it in. **Provenance question for the maintainers.** The coefficient tables are taken verbatim from `xxxerfc.h`. It is a file from the Dinkumware C library shipped in Embarcadero's C++Builder RTL source, in a third-party GitHub repo with no licence (`bergsteiger/realwork`; the header starts `/* xxxerfc.h -- common _[FL]Erfc functionality */`). There is precedent for citing Dinkumware headers: #9631 (merged) and the `_Thrd_sleep` / `_Fetch_*` debt entries cite VC12 CRT sources. But those cite them for types and semantics. This PR copies a data table that was redistributed without a licence. REVERSE_ENGINEERING.md asks contributors to "rebuild data tables from a public source when one exists". I can't tell whether these coefficients have a public origin (for example a published minimax fit), so I'm asking @boykopovar / the maintainers to say whether this source is acceptable before merging. I'm not blocking on it. AI-assisted: yes
MarcZX10 commented 2026-10-28 16:53:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T16:53:13Z.

Review: CHANGES_REQUESTED


Tests run and reviewed — build fails on Linux, changes requested

The new test does not build on Linux with libstdc++ (std::fabsl, GuestDinkumwareInternals.cpp:411), and CI does not catch it because the linux job is skipped on this PR.

What I ran

  • Head tested: 97272c1877 merged onto current main (merges cleanly)
  • Environment: Linux x86-64, GCC 12.2 (Debian), throwaway archive build. Not run: Windows, macOS, a console.
  • Commands:
    python3 tools/check_conventions.py --base upstream/main
    git diff --check upstream/main
    python3 core/libs/tests/test_public_headers.py --audit-only --manifest /tmp/ph.json
    run_tests.sh '^guest_dinkumware_internals' guest_dinkumware_internals_tests
    

Results

Check Result
Conventions / git diff --check pass
Public-header audit pass
Build of guest_dinkumware_internals_tests fails, exit 1
Same build with std::fabs instead of std::fabsl (scratch copy) exit 0, test passes 1/1
Build error
GuestDinkumwareInternals.cpp:411: error: 'fabsl' is not a member of 'std'

Negative control

Run on the scratch copy that has the std::fabs fix, new tests kept, code under test changed:

Change to the code Outcome
use std::fma in EvaluatePolynomial fails at _Erfc 1.523 unfused
scale the _LErfc polynomial by 1.0001 fails at _LErfc finite
remove the NaN return in _FErfc fails at _FErfc special

So the new assertions do pin the cases they name.

Findings

Blocking

  1. std::fabsl does not exist in libstdc++ (GuestDinkumwareInternals.cpp:L411)
    <cmath> in C++ provides std::fabs(long double); fabsl is only the C name. The Windows and macOS libraries happen to declare std::fabsl, which is probably why those runs pass. The linux job is skipped on this PR, so nothing in CI compiles this file with libstdc++. Suggested change on that line (both occurrences):
    std::fabs(
    

Non-blocking

  • Sequencing. The body says "Depends on: #12364", but the branch is based on main, not stacked on it. #12363, #12364 and #12365 conflict textually in docs/dev/debt/libc.md, GuestDinkumwareInternals.cpp and core/libs/prx/libc/include/Api.hpp (I confirmed #12365 onto #12363 conflicts). Whichever lands second needs a rebase; saying so in the body would be enough.

Sources

Not verified

  • The ≤ 9 ULP bound for _Erfc recorded in the debt entry. My port substituted std::exp(z) * y for the real _Exp path, so my ULP figures are not comparable and I am not treating them as a finding.
  • Windows and macOS builds, and any behaviour on a console.
  • The licence of the coefficient tables raised by another reviewer; that question is for the maintainers.

To get this to a good state

Replace std::fabsl with std::fabs and mention the merge order in the body. I will re-run the same commands on the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5686468449 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12365#pullrequestreview-5686468449). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T16:53:13Z. **Review:** CHANGES_REQUESTED --- # Tests run and reviewed — build fails on Linux, changes requested The new test does not build on Linux with libstdc++ (`std::fabsl`, `GuestDinkumwareInternals.cpp:411`), and CI does not catch it because the `linux` job is skipped on this PR. ### What I ran - Head tested: `97272c1877` merged onto current `main` (merges cleanly) - Environment: Linux x86-64, GCC 12.2 (Debian), throwaway archive build. Not run: Windows, macOS, a console. - Commands: ``` python3 tools/check_conventions.py --base upstream/main git diff --check upstream/main python3 core/libs/tests/test_public_headers.py --audit-only --manifest /tmp/ph.json run_tests.sh '^guest_dinkumware_internals' guest_dinkumware_internals_tests ``` ### Results | Check | Result | |---|---| | Conventions / `git diff --check` | pass | | Public-header audit | pass | | Build of `guest_dinkumware_internals_tests` | **fails, exit 1** | | Same build with `std::fabs` instead of `std::fabsl` (scratch copy) | exit 0, test passes 1/1 | <details><summary>Build error</summary> ``` GuestDinkumwareInternals.cpp:411: error: 'fabsl' is not a member of 'std' ``` </details> ### Negative control Run on the scratch copy that has the `std::fabs` fix, new tests kept, code under test changed: | Change to the code | Outcome | |---|---| | use `std::fma` in `EvaluatePolynomial` | fails at `_Erfc 1.523 unfused` | | scale the `_LErfc` polynomial by 1.0001 | fails at `_LErfc finite` | | remove the NaN return in `_FErfc` | fails at `_FErfc special` | So the new assertions do pin the cases they name. ### Findings #### Blocking 1. **`std::fabsl` does not exist in libstdc++** ([`GuestDinkumwareInternals.cpp:L411`](https://github.com/boykopovar/AnyPS5/blob/97272c1877/core/libs/tests/GuestDinkumwareInternals.cpp#L411)) `<cmath>` in C++ provides `std::fabs(long double)`; `fabsl` is only the C name. The Windows and macOS libraries happen to declare `std::fabsl`, which is probably why those runs pass. The `linux` job is skipped on this PR, so nothing in CI compiles this file with libstdc++. Suggested change on that line (both occurrences): ```suggestion std::fabs( ``` #### Non-blocking - **Sequencing.** The body says "Depends on: #12364", but the branch is based on `main`, not stacked on it. #12363, #12364 and #12365 conflict textually in `docs/dev/debt/libc.md`, `GuestDinkumwareInternals.cpp` and `core/libs/prx/libc/include/Api.hpp` (I confirmed #12365 onto #12363 conflicts). Whichever lands second needs a rebase; saying so in the body would be enough. ### Sources - Test line: [`GuestDinkumwareInternals.cpp:L411` at `97272c1877`](https://github.com/boykopovar/AnyPS5/blob/97272c1877/core/libs/tests/GuestDinkumwareInternals.cpp#L411) - Earlier asks (source link in the debt entry, sequencing): the debt entry now links the 3.20 inventory and `xxxerfc.h`, so that one is resolved. ### Not verified - The ≤ 9 ULP bound for `_Erfc` recorded in the debt entry. My port substituted `std::exp(z) * y` for the real `_Exp` path, so my ULP figures are not comparable and I am not treating them as a finding. - Windows and macOS builds, and any behaviour on a console. - The licence of the coefficient tables raised by another reviewer; that question is for the maintainers. ### To get this to a good state Replace `std::fabsl` with `std::fabs` and mention the merge order in the body. I will re-run the same commands on the new head.
MarcZX10 commented 2026-10-28 17:28:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T17:28:02Z.

Review: APPROVED


Reviewed — looks good\n\nThe Linux portability issue is fixed with std::fabs, and the exact-head Linux/GCC target build and guest_dinkumware_internals CTest passed locally. The Windows hosted job passes; other pending platform jobs and console behavior remain unverified. No blocking issue found.\n\nReviewed head against base ; no blocking finding. This approval covers this exact diff only.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5686932379 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12365#pullrequestreview-5686932379). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T17:28:02Z. **Review:** APPROVED --- # Reviewed — looks good\n\nThe Linux portability issue is fixed with std::fabs, and the exact-head Linux/GCC target build and guest_dinkumware_internals CTest passed locally. The Windows hosted job passes; other pending platform jobs and console behavior remain unverified. No blocking issue found.\n\nReviewed head against base ; no blocking finding. This approval covers this exact diff only.
MarcZX10 commented 2026-10-28 17:29:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T17:29:07Z.

Review: APPROVED


Reviewed — looks good

The Linux portability issue is fixed with std::fabs, and the exact-head Linux/GCC target build and guest_dinkumware_internals CTest passed locally. The Windows hosted job passes; other pending platform jobs and console behavior remain unverified. No blocking issue found.

Reviewed head 9d907a63f8bd62843cdcb2d3e5bb89ed53a08743 against base 7fea87746b; no blocking finding. This approval covers this exact diff.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5686947311 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12365#pullrequestreview-5686947311). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T17:29:07Z. **Review:** APPROVED --- # Reviewed — looks good The Linux portability issue is fixed with std::fabs, and the exact-head Linux/GCC target build and guest_dinkumware_internals CTest passed locally. The Windows hosted job passes; other pending platform jobs and console behavior remain unverified. No blocking issue found. Reviewed head 9d907a63f8bd62843cdcb2d3e5bb89ed53a08743 against base 7fea87746bde8e14a1d3341af85377c5b53f89ad; no blocking finding. This approval covers this exact diff.
MarcZX10 commented 2026-10-29 05:25:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T05:25:40Z.

Review: CHANGES_REQUESTED


Re-checked — changes requested

The author resolved the provenance, sequencing, and Linux std::fabs feedback, but the implementation, tests, and debt entry still treat a range-reduced rational helper as if its valid input domain were all non-negative values.

What I ran

  • Reviewed exact PR head 6617d13fb171be3c33089a5b3f83272dcd07a77b against current main 52c09d567d.
  • Read the cited Dinkumware xxxerfc.h at pinned commit 19b446ce8ad2adf82ab8ce7988bc003221accad2, including the coefficient-range comments and Erf_small/Erf_one bounds.
  • Ran git merge-tree --write-tree and git diff --check against current main.
  • Inspected the changed implementation, assertions, debt text, and current CI. I did not run the CTest target locally.

Results

Check Result
Current-main merge preview Clean
git diff --check Pass
Author-reported focused test guest_dinkumware_internals 1/1 on this head
Author-reported Windows focused test 3/3 on this head
Hosted checks Windows, macOS/Linux register-context, relinker, write-watch, conventions, eligibility, labels, and report pass; Linux product job is skipped

Negative control

  • Not run locally. The current tests assert exact outputs at x = 0, 0.5, and 1, but do not establish those inputs as within the approximation's documented range.

Findings

Blocking

The cited Dinkumware header labels these coefficient tables as sub-range approximations: all start at x = 1.523, with upper bounds 3.82 for float, 5.84 for double, and 6.45 for long double. It defines Erf_small = 1.523 and each precision's Erf_one cutoff. The implementation here evaluates the rational at any input, without the surrounding dispatcher's small-input/sign handling or large-input cutoff, while the debt entry says the helpers accept x >= 0.

That mismatch is observable in the new test: _Erfc_nid_postfix(0.0) is pinned to 0.99999422623189549, although erfc(0) is exactly 1. The test currently blesses a below-range approximation as a valid result. The infinity-to-NaN assertions likewise test outside the table's finite interval.

Please clarify which contract this exported helper is intended to implement:

  1. If this is the range-reduced Dinkumware sub-helper, document the precision-specific supported interval and precondition, remove below-range/out-of-range assertions as correctness tests, and cover the boundaries/cutoff in the caller that performs dispatch; or
  2. If callers may invoke the export for arbitrary x >= 0, add the missing small-input and upper-range handling so it returns the documented erfc behavior over that domain.

Non-blocking

  • The coefficient provenance/licensing question raised by another reviewer still appears to need a maintainer decision. I am not treating it as a separate blocker here.

Sources

Not verified

  • I did not independently run the focused CTest, compare firmware behavior, or validate on console hardware. The test results above are author-reported.
  • The clean merge preview does not replace testing on the integrated current-main head.

To get this to a good state

Resolve the helper's actual input contract as above, update the assertions and debt wording to match it, then rerun the focused test on the resulting head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5693246387 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12365#pullrequestreview-5693246387). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T05:25:40Z. **Review:** CHANGES_REQUESTED --- # Re-checked — changes requested The author resolved the provenance, sequencing, and Linux std::fabs feedback, but the implementation, tests, and debt entry still treat a range-reduced rational helper as if its valid input domain were all non-negative values. ## What I ran - Reviewed exact PR head 6617d13fb171be3c33089a5b3f83272dcd07a77b against current main 52c09d567d2fa453494dd720fcf53a98149468e4. - Read the cited Dinkumware xxxerfc.h at pinned commit 19b446ce8ad2adf82ab8ce7988bc003221accad2, including the coefficient-range comments and Erf_small/Erf_one bounds. - Ran git merge-tree --write-tree and git diff --check against current main. - Inspected the changed implementation, assertions, debt text, and current CI. I did not run the CTest target locally. ## Results | Check | Result | |---|---| | Current-main merge preview | Clean | | git diff --check | Pass | | Author-reported focused test | guest_dinkumware_internals 1/1 on this head | | Author-reported Windows focused test | 3/3 on this head | | Hosted checks | Windows, macOS/Linux register-context, relinker, write-watch, conventions, eligibility, labels, and report pass; Linux product job is skipped | ## Negative control - Not run locally. The current tests assert exact outputs at x = 0, 0.5, and 1, but do not establish those inputs as within the approximation's documented range. ## Findings ### Blocking The cited Dinkumware header labels these coefficient tables as sub-range approximations: all start at x = 1.523, with upper bounds 3.82 for float, 5.84 for double, and 6.45 for long double. It defines Erf_small = 1.523 and each precision's Erf_one cutoff. The implementation here evaluates the rational at any input, without the surrounding dispatcher's small-input/sign handling or large-input cutoff, while the debt entry says the helpers accept x >= 0. That mismatch is observable in the new test: _Erfc_nid_postfix(0.0) is pinned to 0.99999422623189549, although erfc(0) is exactly 1. The test currently blesses a below-range approximation as a valid result. The infinity-to-NaN assertions likewise test outside the table's finite interval. Please clarify which contract this exported helper is intended to implement: 1. If this is the range-reduced Dinkumware sub-helper, document the precision-specific supported interval and precondition, remove below-range/out-of-range assertions as correctness tests, and cover the boundaries/cutoff in the caller that performs dispatch; or 2. If callers may invoke the export for arbitrary x >= 0, add the missing small-input and upper-range handling so it returns the documented erfc behavior over that domain. ### Non-blocking - The coefficient provenance/licensing question raised by another reviewer still appears to need a maintainer decision. I am not treating it as a separate blocker here. ## Sources - [Dinkumware xxxerfc.h, pinned coefficient intervals and dispatch constants](https://github.com/bergsteiger/realwork/blob/19b446ce8ad2adf82ab8ce7988bc003221accad2/common/components/rtl/external/Embarcadero/DelphiBerlin/cpprtl/Source/dinkumware64/source/xxxerfc.h) - [Implementation at reviewed head](https://github.com/boykopovar/AnyPS5/blob/6617d13fb171be3c33089a5b3f83272dcd07a77b/core/libs/prx/libc/src/DinkumwareInternals.cpp) - [Tests at reviewed head](https://github.com/boykopovar/AnyPS5/blob/6617d13fb171be3c33089a5b3f83272dcd07a77b/core/libs/tests/GuestDinkumwareInternals.cpp) - [Debt entry at reviewed head](https://github.com/boykopovar/AnyPS5/blob/6617d13fb171be3c33089a5b3f83272dcd07a77b/docs/dev/debt/libc.md) ## Not verified - I did not independently run the focused CTest, compare firmware behavior, or validate on console hardware. The test results above are author-reported. - The clean merge preview does not replace testing on the integrated current-main head. ## To get this to a good state Resolve the helper's actual input contract as above, update the assertions and debt wording to match it, then rerun the focused test on the resulting head.
MarcZX10 commented 2026-10-29 09:34:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T09:34:07Z.

Review: APPROVED


Re-checked — approved

The updated contract resolves my range-domain finding. The debt entry now identifies the precision-specific sub-ranges as preconditions and explains that the caller handles sign reflection and cutoffs; the tests no longer treat below-range inputs or infinities as valid outputs. The implementation matches the cited range-reduced Dinkumware helper, and the focused finite assertions remain within the documented intervals.

What I checked

  • Reviewed exact head c044ff4f0d15dc5d68cd5ad33f7fc08f145566b0.
  • Checked the implementation, test changes and updated debt wording against the pinned xxxerfc.h reference and the earlier review findings.
  • Compared with current main aaccd0ba39b7d40fdbf19664575a7e567d8542f7: the merge preview is clean, and current main has no changes to the PR's implementation, API, tests or debt paths since the merge base.
  • Checked hosted results: Windows, relinker (Linux/macOS/Windows), ASAN, register-context, conventions, eligibility and report pass. The Linux product job is skipped.

Test evidence

The author reports guest_dinkumware_internals passing on this exact head on Windows. I did not run the test locally or verify behavior on console hardware. Console signatures/results and exception details remain appropriately listed as unverified.

No blocking issue remains in this diff. Approval covers this exact head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5695556591 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12365#pullrequestreview-5695556591). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T09:34:07Z. **Review:** APPROVED --- # Re-checked — approved The updated contract resolves my range-domain finding. The debt entry now identifies the precision-specific sub-ranges as preconditions and explains that the caller handles sign reflection and cutoffs; the tests no longer treat below-range inputs or infinities as valid outputs. The implementation matches the cited range-reduced Dinkumware helper, and the focused finite assertions remain within the documented intervals. ## What I checked - Reviewed exact head `c044ff4f0d15dc5d68cd5ad33f7fc08f145566b0`. - Checked the implementation, test changes and updated debt wording against the pinned `xxxerfc.h` reference and the earlier review findings. - Compared with current `main` `aaccd0ba39b7d40fdbf19664575a7e567d8542f7`: the merge preview is clean, and current main has no changes to the PR's implementation, API, tests or debt paths since the merge base. - Checked hosted results: Windows, relinker (Linux/macOS/Windows), ASAN, register-context, conventions, eligibility and report pass. The Linux product job is skipped. ## Test evidence The author reports `guest_dinkumware_internals` passing on this exact head on Windows. I did not run the test locally or verify behavior on console hardware. Console signatures/results and exception details remain appropriately listed as unverified. No blocking issue remains in this diff. Approval covers this exact head.

Pull request closed

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!12365
No description provided.