feat(libc): add Dinkumware float bit helpers from firmware #8397

Merged
hypermoist merged 8 commits from upstream-pr/8397 into main 2026-11-02 00:43:08 +00:00
hypermoist commented 2026-10-20 12:14:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-20T12:14:09Z.


What

Implements 18 absent Dinkumware floating-point helpers in MathExact.cpp, next to _LDtest / _Dclass. The behaviour comes from running the decrypted firmware 13.60 libSceLibcInternal.sprx exports in a Linux harness, not on a console.

Return codes are the Dinkumware classes: -2 denormal, -1 finite, 0 zero, 1 infinite, 2 NaN.

_Dint (-vyIrREaQ0g), _FDint (HcpmBnY1RGE), _LDint (alNWe8glQH4), (value*, short scale).

  • They clear the fraction bits below 2^scale and return -1 if any were dropped, otherwise 0. Infinity returns 1 and NaN 2, unchanged.
  • The firmware computes the drop count in 16 bits, so it wraps. For example, a long double with exponent field 0 and scale = -16411 comes back unchanged with code 0.
  • Dropping every bit gives a signed zero.

_Dscale (FMU7jRhYCRU), _FDscale (SSvY6pTRAgk), _LDscale (s-Ml8NxBKf4), (value*, int64 exponent).

  • The exponent is the guest's 64-bit long (std::int64_t here, since the host long is 32 bits on Windows): 2^31 overflows to ±inf and -2^32 + 3 underflows to zero, as on the console.
  • They multiply by 2^exponent, returning 1 on overflow (±inf) and 0 on underflow.
  • Underflow keeps the sign for double and float. For _LDscale it always stores +0.
  • Unnormal and pseudo-zero long doubles are canonicalised first. errno is untouched.

_Dunscale (4Wt5uzHO98o), _FDunscale (41SqJvOe8lA), _LDunscale (ArZF2KISb5k), (short* exponent, value*).

  • They split a finite value into a [0.5, 1) fraction and an exponent.
  • Zero, inf and NaN keep the value, store exponent 0 and return their class.

_Dnorm (NApYynEzlco), _FDnorm (0NwCmZv7XcU), _LDnorm (ldbrWsQk+2A), (uint16_t* words).

  • These are raw significand normalisers on the word array. Each returns the exponent adjustment and leaves the halves exactly as the console does: for double and float the hidden-bit position is cleared.
  • _LDnorm shifts the 64-bit mantissa until bit 63 is set and returns minus the shift.
  • With a zero mantissa, the firmware _LDnorm loops forever. This build throws std::invalid_argument instead of hanging, and docs/dev/debt/libc.md records the difference.

_Fpcomp (vhPKxN6zs+A), _FFpcomp (EBkab3s8Jto), _LFpcomp (-BwLPxElT7U) return 1 when x < y, 2 when x == y and 4 when x > y, and 0 if either operand is NaN.

  • For _LFpcomp the NaN test reads the raw bits (exponent 0x7fff and any fraction bit below bit 63).
  • An unnormal, pseudo-zero or pseudo-infinity is an invalid x87 operand, so the comparison is unordered and returns 2 whatever the values: an unnormal 1.0 against 3.0L gives 2 in both orders, as does an unnormal 1.0 against an unnormal 3.0. A pseudo-denormal is a valid operand and compares by value.

_Poly (aINUE2xbhZ4), _FPoly (5AN3vhTZ7f8), _LPoly (c6Qa0P3XKYQ), (x, table, degree).

  • They evaluate Horner from table[0]; a degree ≤ 0 returns table[0].
  • The double and float forms use vfmadd, so the code uses std::fma. _LPoly is x87 multiply then add.

_Dtento and the _Dsign family are left out (multi-part extended arithmetic, and #6085).

Tested

Linux (CachyOS, GCC, Release).

  • Differential test. A harness mapped the console libSceLibcInternal.sprx and compared each export against this build's libc.prx, over 200 000 random inputs per function. The inputs were random bit patterns including denormals, unnormals, pseudo-zeros and out-of-range scales. Result: 0 mismatches. Unnormal _LFpcomp operands with unequal values were also run one by one through the firmware 13.60 module and PPSA08427's bundled libc.prx in the same harness; both return 2, as this build does. Zero significands for _LDnorm were excluded because of the hang.
  • Repo test. New guest_dinkumware_float_bits covers every function, including the 64-bit scale vectors, with each expected value and return code taken from the console module's output. It passes, as do guest_math and guest_math_exact.

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 (Claude Code), reviewed by the contributor

Assisted With AI: Yes. All tests were run locally on computer hardware (AMD Ryzen 5 5600G, 32 GB RAM, NVIDIA GeForce RTX 3060, CachyOS Linux 7.3, GCC 16.2), not on an actual console.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4935553271 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8397). Originally posted by [hypermoist](https://github.com/hypermoist) on 2026-10-20T12:14:09Z. --- ### What Implements 18 absent Dinkumware floating-point helpers in `MathExact.cpp`, next to `_LDtest` / `_Dclass`. The behaviour comes from running the decrypted firmware 13.60 `libSceLibcInternal.sprx` exports in a Linux harness, not on a console. Return codes are the Dinkumware classes: -2 denormal, -1 finite, 0 zero, 1 infinite, 2 NaN. **`_Dint` (`-vyIrREaQ0g`), `_FDint` (`HcpmBnY1RGE`), `_LDint` (`alNWe8glQH4`), `(value*, short scale)`.** - They clear the fraction bits below 2^scale and return -1 if any were dropped, otherwise 0. Infinity returns 1 and NaN 2, unchanged. - The firmware computes the drop count in 16 bits, so it wraps. For example, a long double with exponent field 0 and `scale = -16411` comes back unchanged with code 0. - Dropping every bit gives a signed zero. **`_Dscale` (`FMU7jRhYCRU`), `_FDscale` (`SSvY6pTRAgk`), `_LDscale` (`s-Ml8NxBKf4`), `(value*, int64 exponent)`.** - The exponent is the guest's 64-bit `long` (`std::int64_t` here, since the host `long` is 32 bits on Windows): 2^31 overflows to ±inf and -2^32 + 3 underflows to zero, as on the console. - They multiply by 2^exponent, returning 1 on overflow (±inf) and 0 on underflow. - Underflow keeps the sign for double and float. For `_LDscale` it always stores +0. - Unnormal and pseudo-zero long doubles are canonicalised first. `errno` is untouched. **`_Dunscale` (`4Wt5uzHO98o`), `_FDunscale` (`41SqJvOe8lA`), `_LDunscale` (`ArZF2KISb5k`), `(short* exponent, value*)`.** - They split a finite value into a [0.5, 1) fraction and an exponent. - Zero, inf and NaN keep the value, store exponent 0 and return their class. **`_Dnorm` (`NApYynEzlco`), `_FDnorm` (`0NwCmZv7XcU`), `_LDnorm` (`ldbrWsQk+2A`), `(uint16_t* words)`.** - These are raw significand normalisers on the word array. Each returns the exponent adjustment and leaves the halves exactly as the console does: for double and float the hidden-bit position is cleared. - `_LDnorm` shifts the 64-bit mantissa until bit 63 is set and returns minus the shift. - With a zero mantissa, the firmware `_LDnorm` loops forever. This build throws `std::invalid_argument` instead of hanging, and `docs/dev/debt/libc.md` records the difference. **`_Fpcomp` (`vhPKxN6zs+A`), `_FFpcomp` (`EBkab3s8Jto`), `_LFpcomp` (`-BwLPxElT7U`)** return 1 when x < y, 2 when x == y and 4 when x > y, and 0 if either operand is NaN. - For `_LFpcomp` the NaN test reads the raw bits (exponent 0x7fff and any fraction bit below bit 63). - An unnormal, pseudo-zero or pseudo-infinity is an invalid x87 operand, so the comparison is unordered and returns 2 whatever the values: an unnormal 1.0 against 3.0L gives 2 in both orders, as does an unnormal 1.0 against an unnormal 3.0. A pseudo-denormal is a valid operand and compares by value. **`_Poly` (`aINUE2xbhZ4`), `_FPoly` (`5AN3vhTZ7f8`), `_LPoly` (`c6Qa0P3XKYQ`), `(x, table, degree)`.** - They evaluate Horner from `table[0]`; a degree ≤ 0 returns `table[0]`. - The double and float forms use `vfmadd`, so the code uses `std::fma`. `_LPoly` is x87 multiply then add. `_Dtento` and the `_Dsign` family are left out (multi-part extended arithmetic, and #6085). ### Tested Linux (CachyOS, GCC, Release). - **Differential test.** A harness mapped the console `libSceLibcInternal.sprx` and compared each export against this build's `libc.prx`, over 200 000 random inputs per function. The inputs were random bit patterns including denormals, unnormals, pseudo-zeros and out-of-range scales. Result: 0 mismatches. Unnormal `_LFpcomp` operands with unequal values were also run one by one through the firmware 13.60 module and PPSA08427's bundled `libc.prx` in the same harness; both return 2, as this build does. Zero significands for `_LDnorm` were excluded because of the hang. - **Repo test.** New `guest_dinkumware_float_bits` covers every function, including the 64-bit scale vectors, with each expected value and return code taken from the console module's output. It passes, as do `guest_math` and `guest_math_exact`. ### 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) - [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 (Claude Code), reviewed by the contributor Assisted With AI: Yes. All tests were run locally on computer hardware (AMD Ryzen 5 5600G, 32 GB RAM, NVIDIA GeForce RTX 3060, CachyOS Linux 7.3, GCC 16.2), not on an actual console.
nikowolf123 commented 2026-10-20 20:40:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-20T20:40:29Z.


I built this with the Windows CI toolchain (WinLibs GCC 15.2.0 r7, UCRT). Two things break on Windows, and one debt entry is missing.

1. _Dscale, _FDscale and _LDscale lose the upper 32 bits of the exponent on Windows (MathExact.cpp#L387)

The guest passes a 64-bit long, and the console vector at GuestDinkumwareFloatBits.cpp#L114 depends on the full width: _Dscale(1.0, 1099511627776) returns 1 with +inf. Host long is 32 bits on Windows, so ScaleBinary (L132) and the three exports read only ESI. I called _Dscale_nid_postfix the way guest code does, through a sysv_abi pointer that takes std::int64_t, with *value = 1.0:

  • 2^40: Linux returns 1 and +inf. Windows returns -1 and leaves 1.0 unchanged.
  • 2^31: Linux returns 1 and +inf. Windows returns 0 and +0.
  • -2^32 + 3: Linux returns 0 and +0. Windows returns -1 and 8.0.

The test has the same problem. On Windows the literal 1099511627776L narrows to 0 (GCC warns with -Woverflow), so L114 aborts. Other exports take guest long as std::int64_t: scalbln_nid_postfix in this file, and ldiv_nid_postfix and labs_nid_postfix in Math.cpp. 2243e17f34 fixed the same mismatch in _Stoul. To fix this, take std::int64_t exponent in ScaleBinary (clamped with std::clamp<std::int64_t>) and in the three exports. The test then needs the same type on L13-L15 and in CheckScale, and std::int64_t{1} << 40 on L114.

2. The new test does not compile on Windows (GuestDinkumwareFloatBits.cpp#L54)

On Windows APS5_VABI is __attribute__((sysv_abi)) (VabiMacros.hpp#L5), and GCC will not convert those functions to the plain pointers the Check* helpers take. All 70 Check* calls fail to compile. The first error is:

GuestDinkumwareFloatBits.cpp:79:14: error: invalid conversion from 'short int (__attribute__((sysv_abi)) *)(double*, short int)' to 'short int (*)(double*, short int)' [-fpermissive]

The checks on this PR skip the full windows job, because build.yml runs it only on pushes to main and on workflow_dispatch. Fiber.cpp and GuestAjmTeardown.cpp put the macro in the pointer type, and that fixes it here too:

static void CheckInt(short (APS5_VABI* function)(T*, short), T input, short scale, short code, T expected)
static void CheckScale(short (APS5_VABI* function)(T*, std::int64_t), T input, std::int64_t exponent, short code, T expected)
static void CheckUnscale(short (APS5_VABI* function)(short*, T*), T input, short code, short exponent, T expected)
static void CheckNorm(short (APS5_VABI* function)(std::uint16_t*), T input, short code, T expected)

With both changes, every vector passes on Windows and on Linux. I did not run the _LDnorm throw case, because it needs the full build.

3. The _LDnorm throw has no debt entry (MathExact.cpp#L426)

The PR description says the firmware loops forever on a zero significand, and this build throws instead. CONTRIBUTING.md asks for known gaps to be recorded in the debt files, with the gap stated first ("what differs from the console, what is unverified, what throws"). The __modti3 entry (ec2acea5bd) and the pthread_spin_lock entry record the same kind of divergence. For example, under Functional in docs/dev/debt/libc.md:

- [_LDnorm](../../../core/libs/prx/libc/src/MathExact.cpp) (libSceLibcInternal, implemented in libc) - a zero significand never returns on the console; this throws instead
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6300995613 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8397#issuecomment-6300995613). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-20T20:40:29Z. --- I built this with the Windows CI toolchain (WinLibs GCC 15.2.0 r7, UCRT). Two things break on Windows, and one debt entry is missing. **1. `_Dscale`, `_FDscale` and `_LDscale` lose the upper 32 bits of the exponent on Windows** ([MathExact.cpp#L387](https://github.com/boykopovar/AnyPS5/blob/74b5f452a5baf85c12ccdcc4a266f177707be771/core/libs/prx/libc/src/MathExact.cpp#L387)) The guest passes a 64-bit `long`, and the console vector at [GuestDinkumwareFloatBits.cpp#L114](https://github.com/boykopovar/AnyPS5/blob/74b5f452a5baf85c12ccdcc4a266f177707be771/core/libs/tests/GuestDinkumwareFloatBits.cpp#L114) depends on the full width: `_Dscale(1.0, 1099511627776)` returns 1 with +inf. Host `long` is 32 bits on Windows, so `ScaleBinary` (L132) and the three exports read only ESI. I called `_Dscale_nid_postfix` the way guest code does, through a `sysv_abi` pointer that takes `std::int64_t`, with `*value = 1.0`: - 2^40: Linux returns 1 and +inf. Windows returns -1 and leaves 1.0 unchanged. - 2^31: Linux returns 1 and +inf. Windows returns 0 and +0. - -2^32 + 3: Linux returns 0 and +0. Windows returns -1 and 8.0. The test has the same problem. On Windows the literal `1099511627776L` narrows to 0 (GCC warns with `-Woverflow`), so L114 aborts. Other exports take guest `long` as `std::int64_t`: `scalbln_nid_postfix` in this file, and `ldiv_nid_postfix` and `labs_nid_postfix` in Math.cpp. 2243e17f34 fixed the same mismatch in `_Stoul`. To fix this, take `std::int64_t exponent` in `ScaleBinary` (clamped with `std::clamp<std::int64_t>`) and in the three exports. The test then needs the same type on L13-L15 and in `CheckScale`, and `std::int64_t{1} << 40` on L114. **2. The new test does not compile on Windows** ([GuestDinkumwareFloatBits.cpp#L54](https://github.com/boykopovar/AnyPS5/blob/74b5f452a5baf85c12ccdcc4a266f177707be771/core/libs/tests/GuestDinkumwareFloatBits.cpp#L54)) On Windows `APS5_VABI` is `__attribute__((sysv_abi))` ([VabiMacros.hpp#L5](https://github.com/boykopovar/AnyPS5/blob/74b5f452a5baf85c12ccdcc4a266f177707be771/core/libs/prx/libc/include/general/VabiMacros.hpp#L5)), and GCC will not convert those functions to the plain pointers the `Check*` helpers take. All 70 `Check*` calls fail to compile. The first error is: ``` GuestDinkumwareFloatBits.cpp:79:14: error: invalid conversion from 'short int (__attribute__((sysv_abi)) *)(double*, short int)' to 'short int (*)(double*, short int)' [-fpermissive] ``` The checks on this PR skip the full `windows` job, because build.yml runs it only on pushes to main and on workflow_dispatch. Fiber.cpp and GuestAjmTeardown.cpp put the macro in the pointer type, and that fixes it here too: ```cpp static void CheckInt(short (APS5_VABI* function)(T*, short), T input, short scale, short code, T expected) static void CheckScale(short (APS5_VABI* function)(T*, std::int64_t), T input, std::int64_t exponent, short code, T expected) static void CheckUnscale(short (APS5_VABI* function)(short*, T*), T input, short code, short exponent, T expected) static void CheckNorm(short (APS5_VABI* function)(std::uint16_t*), T input, short code, T expected) ``` With both changes, every vector passes on Windows and on Linux. I did not run the `_LDnorm` throw case, because it needs the full build. **3. The `_LDnorm` throw has no debt entry** ([MathExact.cpp#L426](https://github.com/boykopovar/AnyPS5/blob/74b5f452a5baf85c12ccdcc4a266f177707be771/core/libs/prx/libc/src/MathExact.cpp#L426)) The PR description says the firmware loops forever on a zero significand, and this build throws instead. CONTRIBUTING.md asks for known gaps to be recorded in the debt files, with the gap stated first ("what differs from the console, what is unverified, what throws"). The `__modti3` entry (ec2acea5bd) and the `pthread_spin_lock` entry record the same kind of divergence. For example, under Functional in `docs/dev/debt/libc.md`: ``` - [_LDnorm](../../../core/libs/prx/libc/src/MathExact.cpp) (libSceLibcInternal, implemented in libc) - a zero significand never returns on the console; this throws instead ```
oneandonlydean commented 2026-10-20 22:54:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T22:54:16Z.


@hypermoist Agreed with nikowolf123. I can confirm point 2 independently: with the Windows toolchain, GuestDinkumwareFloatBits.cpp stops at line 79 ("no matching function for call to CheckInt"), because APS5_VABI functions are sysv_abi there and the Check* helpers take plain function pointers. Putting APS5_VABI in the helpers' pointer types fixes it. So, to land this:

  • APS5_VABI in the Check* pointer parameters;
  • std::int64_t for the long exponent of _Dscale, _FDscale, _LDscale and ScaleBinary (and in the test, including the 2^40 vector);
  • a docs/dev/debt/libc.md entry for the _LDnorm zero-significand throw.

After that, the bar is a full CI run with guest_dinkumware_float_bits passing on Linux and Windows.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6303601696 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8397#issuecomment-6303601696). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T22:54:16Z. --- @hypermoist Agreed with nikowolf123. I can confirm point 2 independently: with the Windows toolchain, `GuestDinkumwareFloatBits.cpp` stops at line 79 ("no matching function for call to `CheckInt`"), because `APS5_VABI` functions are `sysv_abi` there and the `Check*` helpers take plain function pointers. Putting `APS5_VABI` in the helpers' pointer types fixes it. So, to land this: - `APS5_VABI` in the `Check*` pointer parameters; - `std::int64_t` for the `long exponent` of `_Dscale`, `_FDscale`, `_LDscale` and `ScaleBinary` (and in the test, including the 2^40 vector); - a `docs/dev/debt/libc.md` entry for the `_LDnorm` zero-significand throw. After that, the bar is a full CI run with `guest_dinkumware_float_bits` passing on Linux and Windows.
hypermoist commented 2026-10-20 22:56:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-20T22:56:46Z.


Thanks for building it on Windows. All three are fixed in the latest push:

  1. ScaleBinary and _Dscale/_FDscale/_LDscale take std::int64_t (clamped with std::clamp<std::int64_t>), and the test declarations, CheckScale and the vectors use std::int64_t (std::int64_t{1} << 40 on L114). I added your two Windows-sensitive exponents as vectors, after running them through the console's _Dscale with *value = 1.0: 2^31 gives 1 and +inf, and -2^32 + 3 gives 0 and +0.
  2. The four Check* helpers now take short (APS5_VABI* function)(...), as Fiber.cpp and GuestAjmTeardown.cpp do.
  3. libc.md has an _LDnorm entry next to __modti3: a zero significand never returns on the console, and this throws instead.

guest_dinkumware_float_bits passes on Linux. I have no MinGW toolchain here, so I have not built it for Windows myself.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6303638261 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8397#issuecomment-6303638261). Originally posted by [hypermoist](https://github.com/hypermoist) on 2026-10-20T22:56:46Z. --- Thanks for building it on Windows. All three are fixed in the latest push: 1. `ScaleBinary` and `_Dscale`/`_FDscale`/`_LDscale` take `std::int64_t` (clamped with `std::clamp<std::int64_t>`), and the test declarations, `CheckScale` and the vectors use `std::int64_t` (`std::int64_t{1} << 40` on L114). I added your two Windows-sensitive exponents as vectors, after running them through the console's `_Dscale` with `*value = 1.0`: 2^31 gives 1 and +inf, and -2^32 + 3 gives 0 and +0. 2. The four `Check*` helpers now take `short (APS5_VABI* function)(...)`, as Fiber.cpp and GuestAjmTeardown.cpp do. 3. `libc.md` has an `_LDnorm` entry next to `__modti3`: a zero significand never returns on the console, and this throws instead. `guest_dinkumware_float_bits` passes on Linux. I have no MinGW toolchain here, so I have not built it for Windows myself.
harisibrar1 commented 2026-10-24 15:34:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T15:34:12Z.

Review: COMMENTED


Checked against main b607bfdc8b and the Dinkumware V5.00 sources in openqnx (trunk/lib/c/ansi xdscale.c, xdnorm.c, xdunscal.c, xldscale.c, inc/xmath.h):

  • The earlier review points (std::int64_t exponent, APS5_VABI in the Check* pointers, the _LDnorm debt entry) all look addressed in e9a3d03. None of these 18 functions exists on main yet, the branch merges without conflicts, and all 18 NIDs match their names.
  • The _Dint/_FDint/_LDint drop count and cut-offs match xdint's (_DBIAS + 48 + _DOFF + 1) - xchar - xexp (1075 / 150 / 0x3ffe + 64), and _Dnorm matches xdnorm.c, including the zero-fraction case returning 1 with only the sign kept. QNX's 80-bit _LDscale keeps the sign on underflow, so the always-+0 behaviour here really is a newer-firmware difference, which your measurement covers.
  • Small description fix: _Dint returns 0, not "the class", when no fraction bits are dropped. The code and the 3.0 vector already do this, matching Dinkumware.
  • On "An unnormal compares by value" for _LFpcomp: the only unnormal vector compares two operands with the same value, so it can't distinguish that from the x87 unordered path (SDM vol. 1 §8.2.2 treats unnormals as invalid operands, which the pseudo-infinity → 2 vector also suggests). Reading the code, an unnormal 1.0 against 3.0L would give 2 here. I couldn't run it, so a console vector with unequal values would pin it down either way.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638800344 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8397#pullrequestreview-5638800344). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-24T15:34:12Z. **Review:** COMMENTED --- Checked against main b607bfdc8b and the Dinkumware V5.00 sources in openqnx (trunk/lib/c/ansi xdscale.c, xdnorm.c, xdunscal.c, xldscale.c, inc/xmath.h): - The earlier review points (`std::int64_t` exponent, `APS5_VABI` in the `Check*` pointers, the `_LDnorm` debt entry) all look addressed in e9a3d03. None of these 18 functions exists on main yet, the branch merges without conflicts, and all 18 NIDs match their names. - The `_Dint`/`_FDint`/`_LDint` drop count and cut-offs match xdint's `(_DBIAS + 48 + _DOFF + 1) - xchar - xexp` (1075 / 150 / 0x3ffe + 64), and `_Dnorm` matches xdnorm.c, including the zero-fraction case returning 1 with only the sign kept. QNX's 80-bit `_LDscale` keeps the sign on underflow, so the always-+0 behaviour here really is a newer-firmware difference, which your measurement covers. - Small description fix: `_Dint` returns 0, not "the class", when no fraction bits are dropped. The code and the 3.0 vector already do this, matching Dinkumware. - On "An unnormal compares by value" for `_LFpcomp`: the only unnormal vector compares two operands with the same value, so it can't distinguish that from the x87 unordered path (SDM vol. 1 §8.2.2 treats unnormals as invalid operands, which the pseudo-infinity → 2 vector also suggests). Reading the code, an unnormal 1.0 against 3.0L would give 2 here. I couldn't run it, so a console vector with unequal values would pin it down either way. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
MarcZX10 commented 2026-10-30 01:31:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T01:31:18Z.

Review: APPROVED


Reviewed — looks good

Reviewed exact head 1e89d2117d9448d9976510d88a0df1308f789911; the 18 declarations, implementations, CMake registration and regression cases align, and I found no blocking issue.

The current upstream main is 8abc96f0aefea85ee48601b936dd1401b24bf901; none of the five PR files changed since its base f26434afa36e58778a9ff4b948aea52dff19eb0c, and GitHub reports the PR mergeable. Hosted conventions, eligibility, report, relinker, registration and write-watch checks pass; hosted Linux and Windows product jobs are skipped. The author reports 200,000 randomized firmware-module comparisons per helper with no mismatches, passing Linux math/helper tests, and a 3/3 Windows helper-test run; I did not build or run tests locally. _LDnorm's zero-significand throw instead of the module's non-returning loop is recorded as a remaining difference in the PR's debt entry.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5707078076 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8397#pullrequestreview-5707078076). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-30T01:31:18Z. **Review:** APPROVED --- # Reviewed — looks good Reviewed exact head `1e89d2117d9448d9976510d88a0df1308f789911`; the 18 declarations, implementations, CMake registration and regression cases align, and I found no blocking issue. The current upstream `main` is `8abc96f0aefea85ee48601b936dd1401b24bf901`; none of the five PR files changed since its base `f26434afa36e58778a9ff4b948aea52dff19eb0c`, and GitHub reports the PR mergeable. Hosted conventions, eligibility, report, relinker, registration and write-watch checks pass; hosted Linux and Windows product jobs are skipped. The author reports 200,000 randomized firmware-module comparisons per helper with no mismatches, passing Linux math/helper tests, and a 3/3 Windows helper-test run; I did not build or run tests locally. `_LDnorm`'s zero-significand throw instead of the module's non-returning loop is recorded as a remaining difference in the PR's debt entry.
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!8397
No description provided.