feat(libc): implement the Dinkumware _Sto*x conversions #8384

Merged
hypermoist merged 4 commits from upstream-pr/8384 into main 2026-10-24 17:35:37 +00:00
hypermoist commented 2026-10-20 11:53:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-20T11:53:06Z.


What

Implements nine absent Dinkumware conversion helpers in DinkumwareInternals.cpp. The behaviour comes from running the decrypted libSceLibcInternal.sprx exports on the host.

Floating point: _Stodx (QlcJbyd6jxM), _Stofx (7dlAxeH-htg), _Stoldx (BKidCxmLC5w), (text, end, pten, int* error).

  • They round digits × 10^(exponent + pten) once, as _Stod does.
  • *error is always written: 1 on overflow or underflow to zero (errno is then ERANGE), otherwise 0.
  • A nonzero subnormal result sets neither errno nor *error, for all three: _Stodx("1e-310", 0), _Stodx("1e-300", -10), _Stofx("1e-45", 0) and _Stoldx("1e-4940", 0) give error 0 and leave errno alone. _Stofx used to keep the ERANGE that strtof sets for an inexact subnormal; it no longer does.
  • pten is a 64-bit value.
  • A preset errno survives a call without a range error. That includes text that underflows or overflows unscaled but is brought back into range by pten: _Stodx("1e-400", 300) gives 1e-100, _Stodx("1e400", -100) gives 1e300 and _Stofx("1e39", -1) gives 1e38, all with error 0.
  • _Stoldx uses the extended range: "1e400" is finite, error 0.
  • Hexadecimal text with a non-zero pten throws, as in _Stod; the docs/dev/debt/libc.md entry for that throw now names all six float helpers.

_Stof (CpWcnrEZbLA) and _Stold (iNbtyJKM0iQ) are xor ecx, ecx plus a call to the x variant, like _Stod. _Stod now goes through _Stodx.

Integers: _Stollx (mOnfZ5aNDQE), _Stoullx (pSpDCDyxkaY), _Stoulx (YDnLaav6W6Q), (text, end, base, int* error). All return 64-bit values (_Stoulx is std::uint64_t, not the host's unsigned long, which is 32 bits on Windows).

  • These are strtoll / strtoull with *error set to the errno they produce (ERANGE) or 0.
  • A base outside 0 and 2 to 36 returns 0, sets *error = EINVAL (22) and *end = text, and leaves errno alone.
  • _Stoll now goes through _Stollx, so it handles an invalid base the same way.

_Stolx (Ecwid6wJMhY) returns std::int64_t and has a quirk:

  • the value and *error are strtoll's;
  • errno is set only when the text also overflows strtoull.

So "9223372036854775808" and "-18446744073709551615" give the clamped value with *error = ERANGE and errno untouched, while "18446744073709551616" sets both.

Tested

Linux (CachyOS, GCC, Release). guest_dinkumware_internals gains TestFloatErrors and TestIntegerErrors and passes. Every assertion is a value, end pointer, error-argument value and errno taken from the console module's output. Removing the overflow-rescale condition makes the test fail on the rescaled vectors. The subnormal vectors were measured by running firmware 13.60's libSceLibcInternal.sprx (and PPSA08427's libc.prx, which agrees) in a Linux host process, not on a console; restoring the old errno handling fails _Stofx inexact subnormal. Also built for Windows (MinGW, Wine).

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: #8376 (adds DinkumwareInternals.cpp and its test; this branch is stacked on it)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code), reviewed by the contributor

Assisted With AI: Yes But all test done locally on actual hardware

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4935321248 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8384). Originally posted by [hypermoist](https://github.com/hypermoist) on 2026-10-20T11:53:06Z. --- ### What Implements nine absent Dinkumware conversion helpers in `DinkumwareInternals.cpp`. The behaviour comes from running the decrypted `libSceLibcInternal.sprx` exports on the host. **Floating point: `_Stodx` (`QlcJbyd6jxM`), `_Stofx` (`7dlAxeH-htg`), `_Stoldx` (`BKidCxmLC5w`), `(text, end, pten, int* error)`.** - They round digits × `10^(exponent + pten)` once, as `_Stod` does. - `*error` is always written: 1 on overflow or underflow to zero (`errno` is then `ERANGE`), otherwise 0. - A nonzero subnormal result sets neither `errno` nor `*error`, for all three: `_Stodx("1e-310", 0)`, `_Stodx("1e-300", -10)`, `_Stofx("1e-45", 0)` and `_Stoldx("1e-4940", 0)` give error 0 and leave `errno` alone. `_Stofx` used to keep the `ERANGE` that `strtof` sets for an inexact subnormal; it no longer does. - `pten` is a 64-bit value. - A preset `errno` survives a call without a range error. That includes text that underflows or overflows unscaled but is brought back into range by `pten`: `_Stodx("1e-400", 300)` gives `1e-100`, `_Stodx("1e400", -100)` gives `1e300` and `_Stofx("1e39", -1)` gives `1e38`, all with error 0. - `_Stoldx` uses the extended range: `"1e400"` is finite, error 0. - Hexadecimal text with a non-zero `pten` throws, as in `_Stod`; the `docs/dev/debt/libc.md` entry for that throw now names all six float helpers. **`_Stof` (`CpWcnrEZbLA`) and `_Stold` (`iNbtyJKM0iQ`)** are `xor ecx, ecx` plus a call to the `x` variant, like `_Stod`. `_Stod` now goes through `_Stodx`. **Integers: `_Stollx` (`mOnfZ5aNDQE`), `_Stoullx` (`pSpDCDyxkaY`), `_Stoulx` (`YDnLaav6W6Q`), `(text, end, base, int* error)`.** All return 64-bit values (`_Stoulx` is `std::uint64_t`, not the host's `unsigned long`, which is 32 bits on Windows). - These are `strtoll` / `strtoull` with `*error` set to the `errno` they produce (`ERANGE`) or 0. - A base outside 0 and 2 to 36 returns 0, sets `*error = EINVAL` (22) and `*end = text`, and leaves `errno` alone. - `_Stoll` now goes through `_Stollx`, so it handles an invalid base the same way. **`_Stolx` (`Ecwid6wJMhY`)** returns `std::int64_t` and has a quirk: - the value and `*error` are `strtoll`'s; - `errno` is set only when the text also overflows `strtoull`. So `"9223372036854775808"` and `"-18446744073709551615"` give the clamped value with `*error = ERANGE` and `errno` untouched, while `"18446744073709551616"` sets both. ### Tested Linux (CachyOS, GCC, Release). `guest_dinkumware_internals` gains `TestFloatErrors` and `TestIntegerErrors` and passes. Every assertion is a value, end pointer, error-argument value and `errno` taken from the console module's output. Removing the overflow-rescale condition makes the test fail on the rescaled vectors. The subnormal vectors were measured by running firmware 13.60's `libSceLibcInternal.sprx` (and PPSA08427's `libc.prx`, which agrees) in a Linux host process, not on a console; restoring the old `errno` handling fails `_Stofx inexact subnormal`. Also built for Windows (MinGW, Wine). ### 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: #8376 (adds `DinkumwareInternals.cpp` and its test; this branch is stacked on it) - [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 But all test done locally on actual hardware
nikowolf123 commented 2026-10-20 20:40:25 +00:00 (Migrated from github.com)

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


1. _Stolx and _Stoulx return a 32-bit value on Windows

DinkumwareInternals.cpp#L135 returns the host's long, and #L131 returns the host's unsigned long. Both are 32 bits on Windows, but the guest's long is 64 bits. I built the file with the Windows job's toolchain (WinLibs GCC 15.2.0, -O3). _Stolx returns through mov eax, ebx, so a guest calling _Stolx(text, &end, 10, &err) gets:

  • "-5" → 4294967291
  • "4294967296" → 0, with err == 0
  • "9223372036854775807" → 4294967295, with err == 0

On Windows, guest_dinkumware_internals stops with _Stolx overflow inside the unsigned range (line 129). The PR checks don't show this because the windows job runs only on push and workflow_dispatch (build.yml#L560). 2243e17f34 fixed the same problem for _Stoul:

std::uint64_t APS5_VABI _Stoulx_nid_postfix(const char* text, char** end, int base, int* error) {
std::int64_t APS5_VABI _Stolx_nid_postfix(const char* text, char** end, int base, int* error) {

The test declares both functions with the same 32-bit types (lines 18-19), so it needs the change too. With only _Stolx changed, it still fails at line 134 (_Stoulx wraps a negative value). With both changes, the test passed in my WinLibs build. That build linked the two files against stand-ins that call the host's strto*, as Strings.cpp does. The long pten parameters are also guest longs, so they should be std::int64_t too.

2. Digits that overflow before scaling are never rescaled

DinkumwareInternals.cpp#L52 rescales only when std::isfinite(value) is true. That keeps "inf" and "nan" unscaled. But it also skips the inf that strtof/strtod return when the digits alone overflow, so a negative pten can't bring the value back.

  • _Stofx("1e39", &end, -1, &err) returns inf with err == 1 and errno == ERANGE, on both Linux and Windows.
  • _Stodx("1e400", &end, -100, &err) does the same.

By the rule in the PR description (digits × 10^(exponent + pten), rounded once), these should be 1e38f and 1e300 with no error. That is the mirror image of the "1e-400" with 300 case the test already covers.

Dinkumware's _Stodx also scales by pten + lo[0] in a single _Dtentox call (xxstod.h#L45). Only that call reports the range error (xxxdtent.h#L102-L107), and inf and nan are recognised from their text (FL_INF, FL_NAN).

A negative pten is an ordinary input: Dinkumware's num_get counts leading fraction zeros into it (xlocnum#L752-L756). So reading "0.0001e41" as a float calls _Stofx("0.01e41", &ep, -2, &err), which here sets failbit instead of giving 1e37. A minimal fix:

const bool overflowed = std::isinf(value) && guestErrno == RangeError;
if (pten != 0 && stop != text && (std::isfinite(value) || overflowed)) {

"inf" text does not set ERANGE, so it still passes through unscaled. The existing guestErrno = 0 before the second parse clears the leftover ERANGE. With this change, "1e39" with -1 gives 1e38f with error 0, and "1e400" with -100 gives 1e300. Running _Stofx("1e39", -1) through the console module would confirm the value to put in TestFloatErrors.

3. The hexadecimal throw has no debt entry

DinkumwareInternals.cpp#L53 throws for hexadecimal text with a non-zero pten, for example _Stod("0x3", &end, -1). This now covers _Stodx, _Stofx and _Stoldx, and through them _Stod, _Stof and _Stold. #8376 says the console's result there "does not follow a simple rule".

AGENTS.md says "if the general behaviour is unknown, throw and record it in docs/dev/debt/<library>.md", but neither PR changes docs/dev/debt/libc.md. A libc.md entry linking DinkumwareInternals.cpp would cover it. It would first say that these functions throw for hexadecimal text with a non-zero scale, then give the console data point from #8376 (0x3 with -1 gives 0.29999999999999999).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6300994637 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8384#issuecomment-6300994637). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-20T20:40:25Z. --- **1. `_Stolx` and `_Stoulx` return a 32-bit value on Windows** [`DinkumwareInternals.cpp#L135`](https://github.com/boykopovar/AnyPS5/blob/f0bdc8d8d8d7ffe1e93b08877723dc8fa7e4689c/core/libs/prx/libc/src/DinkumwareInternals.cpp#L135) returns the host's `long`, and [`#L131`](https://github.com/boykopovar/AnyPS5/blob/f0bdc8d8d8d7ffe1e93b08877723dc8fa7e4689c/core/libs/prx/libc/src/DinkumwareInternals.cpp#L131) returns the host's `unsigned long`. Both are 32 bits on Windows, but the guest's `long` is 64 bits. I built the file with the Windows job's toolchain (WinLibs GCC 15.2.0, `-O3`). `_Stolx` returns through `mov eax, ebx`, so a guest calling `_Stolx(text, &end, 10, &err)` gets: - `"-5"` → 4294967291 - `"4294967296"` → 0, with `err == 0` - `"9223372036854775807"` → 4294967295, with `err == 0` On Windows, `guest_dinkumware_internals` stops with `_Stolx overflow inside the unsigned range` ([line 129](https://github.com/boykopovar/AnyPS5/blob/f0bdc8d8d8d7ffe1e93b08877723dc8fa7e4689c/core/libs/tests/GuestDinkumwareInternals.cpp#L129)). The PR checks don't show this because the `windows` job runs only on push and workflow_dispatch ([build.yml#L560](https://github.com/boykopovar/AnyPS5/blob/f0bdc8d8d8d7ffe1e93b08877723dc8fa7e4689c/.github/workflows/build.yml#L560)). 2243e17f34 fixed the same problem for `_Stoul`: ```cpp std::uint64_t APS5_VABI _Stoulx_nid_postfix(const char* text, char** end, int base, int* error) { std::int64_t APS5_VABI _Stolx_nid_postfix(const char* text, char** end, int base, int* error) { ``` The test declares both functions with the same 32-bit types ([lines 18-19](https://github.com/boykopovar/AnyPS5/blob/f0bdc8d8d8d7ffe1e93b08877723dc8fa7e4689c/core/libs/tests/GuestDinkumwareInternals.cpp#L18)), so it needs the change too. With only `_Stolx` changed, it still fails at line 134 (`_Stoulx wraps a negative value`). With both changes, the test passed in my WinLibs build. That build linked the two files against stand-ins that call the host's `strto*`, as `Strings.cpp` does. The `long pten` parameters are also guest `long`s, so they should be `std::int64_t` too. **2. Digits that overflow before scaling are never rescaled** [`DinkumwareInternals.cpp#L52`](https://github.com/boykopovar/AnyPS5/blob/f0bdc8d8d8d7ffe1e93b08877723dc8fa7e4689c/core/libs/prx/libc/src/DinkumwareInternals.cpp#L52) rescales only when `std::isfinite(value)` is true. That keeps `"inf"` and `"nan"` unscaled. But it also skips the inf that `strtof`/`strtod` return when the digits alone overflow, so a negative pten can't bring the value back. - `_Stofx("1e39", &end, -1, &err)` returns inf with `err == 1` and `errno == ERANGE`, on both Linux and Windows. - `_Stodx("1e400", &end, -100, &err)` does the same. By the rule in the PR description (digits × 10^(exponent + pten), rounded once), these should be 1e38f and 1e300 with no error. That is the mirror image of the `"1e-400"` with 300 case the test already covers. Dinkumware's `_Stodx` also scales by `pten + lo[0]` in a single `_Dtentox` call ([xxstod.h#L45](https://github.com/vocho/openqnx/blob/cc95df3543a1c481d4f8ad387e29f0d1ff0c87fe/trunk/lib/c/inc/xxstod.h#L45)). Only that call reports the range error ([xxxdtent.h#L102-L107](https://github.com/vocho/openqnx/blob/cc95df3543a1c481d4f8ad387e29f0d1ff0c87fe/trunk/lib/c/inc/xxxdtent.h#L102-L107)), and inf and nan are recognised from their text (`FL_INF`, `FL_NAN`). A negative pten is an ordinary input: Dinkumware's `num_get` counts leading fraction zeros into it ([xlocnum#L752-L756](https://github.com/styx-emulator/styx-emulator/blob/d743b1931d8740903fb40b6adb4b7700101316db/styx/generated/styx-blackfin-sys/include/cplus/xlocnum#L752-L756)). So reading `"0.0001e41"` as a float calls `_Stofx("0.01e41", &ep, -2, &err)`, which here sets failbit instead of giving 1e37. A minimal fix: ```cpp const bool overflowed = std::isinf(value) && guestErrno == RangeError; if (pten != 0 && stop != text && (std::isfinite(value) || overflowed)) { ``` `"inf"` text does not set `ERANGE`, so it still passes through unscaled. The existing `guestErrno = 0` before the second parse clears the leftover `ERANGE`. With this change, `"1e39"` with -1 gives 1e38f with error 0, and `"1e400"` with -100 gives 1e300. Running `_Stofx("1e39", -1)` through the console module would confirm the value to put in `TestFloatErrors`. **3. The hexadecimal throw has no debt entry** [`DinkumwareInternals.cpp#L53`](https://github.com/boykopovar/AnyPS5/blob/f0bdc8d8d8d7ffe1e93b08877723dc8fa7e4689c/core/libs/prx/libc/src/DinkumwareInternals.cpp#L53) throws for hexadecimal text with a non-zero pten, for example `_Stod("0x3", &end, -1)`. This now covers `_Stodx`, `_Stofx` and `_Stoldx`, and through them `_Stod`, `_Stof` and `_Stold`. #8376 says the console's result there "does not follow a simple rule". [AGENTS.md](https://github.com/boykopovar/AnyPS5/blob/f0bdc8d8d8d7ffe1e93b08877723dc8fa7e4689c/AGENTS.md#L7) says "if the general behaviour is unknown, throw and record it in `docs/dev/debt/<library>.md`", but neither PR changes `docs/dev/debt/libc.md`. A `libc.md` entry linking `DinkumwareInternals.cpp` would cover it. It would first say that these functions throw for hexadecimal text with a non-zero scale, then give the console data point from #8376 (`0x3` with -1 gives 0.29999999999999999).
oneandonlydean commented 2026-10-20 22:48:54 +00:00 (Migrated from github.com)

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


@hypermoist agreed with nikowolf123's three points. To keep it in one place:

  • _Stolx/_Stoulx (and every long pten) should be std::int64_t/std::uint64_t, in the test declarations too. On Windows long is 32 bits, so the values and scales are cut to their low half.
  • An inf that comes from digits overflowing before the scale should still be rescaled ("1e400" with -100 is 1e300 by the rule in the description). "inf" text sets no ERANGE, so it can be told apart.
  • The hexadecimal-with-scale throw needs a docs/dev/debt/libc.md entry.

The same three apply to #8376, which this branch builds on, so fixing them there first and rebasing this one keeps the two in step. After that, the bar is a full CI run with guest_dinkumware_internals passing on Linux and Windows.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6303517354 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8384#issuecomment-6303517354). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T22:48:54Z. --- @hypermoist agreed with nikowolf123's three points. To keep it in one place: - `_Stolx`/`_Stoulx` (and every `long pten`) should be `std::int64_t`/`std::uint64_t`, in the test declarations too. On Windows `long` is 32 bits, so the values and scales are cut to their low half. - An inf that comes from digits overflowing before the scale should still be rescaled (`"1e400"` with -100 is 1e300 by the rule in the description). `"inf"` text sets no ERANGE, so it can be told apart. - The hexadecimal-with-scale throw needs a `docs/dev/debt/libc.md` entry. The same three apply to #8376, which this branch builds on, so fixing them there first and rebasing this one keeps the two in step. After that, the bar is a full CI run with `guest_dinkumware_internals` passing on Linux and Windows.
hypermoist commented 2026-10-20 23:11:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-20T23:11:52Z.


Thanks @nikowolf123 and @oneandonlydean. All three points are fixed in 6a23fe146a (the merge of the updated #8376 into this branch):

  1. _Stolx now returns std::int64_t and _Stoulx returns std::uint64_t. Every pten (_Stodx/_Stofx/_Stoldx/_Stod/_Stof/_Stold and ScaledFloat) is std::int64_t, and the test declarations match. The 64-bit expectations in the test used l/ul literals, which are also 32 bits on Windows, so they are now ll/ull.
  2. ScaledFloat still rescales when the first parse overflowed to infinity with ERANGE. "inf" text sets no ERANGE, so it is left as it is. New vectors, both checked against the firmware: _Stofx("1e39", -1) gives 1e38 with *error == 0, and _Stodx("1e400", -100) gives 1e300 with *error == 0. With the overflow term removed, the test fails on an overflowing text scaled back into range.
  3. The docs/dev/debt/libc.md entry for the hexadecimal-with-scale throw now names _Stod, _Stodx, _Stofx, _Stoldx, _Stof and _Stold.

guest_dinkumware_internals_tests passes on Linux and tools/check_conventions.py is clean. I have no Windows toolchain locally, so the Windows CI job is the check for point 1.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6303860745 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8384#issuecomment-6303860745). Originally posted by [hypermoist](https://github.com/hypermoist) on 2026-10-20T23:11:52Z. --- Thanks @nikowolf123 and @oneandonlydean. All three points are fixed in 6a23fe146a (the merge of the updated #8376 into this branch): 1. `_Stolx` now returns `std::int64_t` and `_Stoulx` returns `std::uint64_t`. Every `pten` (`_Stodx`/`_Stofx`/`_Stoldx`/`_Stod`/`_Stof`/`_Stold` and `ScaledFloat`) is `std::int64_t`, and the test declarations match. The 64-bit expectations in the test used `l`/`ul` literals, which are also 32 bits on Windows, so they are now `ll`/`ull`. 2. `ScaledFloat` still rescales when the first parse overflowed to infinity with ERANGE. `"inf"` text sets no ERANGE, so it is left as it is. New vectors, both checked against the firmware: `_Stofx("1e39", -1)` gives 1e38 with `*error == 0`, and `_Stodx("1e400", -100)` gives 1e300 with `*error == 0`. With the overflow term removed, the test fails on `an overflowing text scaled back into range`. 3. The `docs/dev/debt/libc.md` entry for the hexadecimal-with-scale throw now names `_Stod`, `_Stodx`, `_Stofx`, `_Stoldx`, `_Stof` and `_Stold`. `guest_dinkumware_internals_tests` passes on Linux and `tools/check_conventions.py` is clean. I have no Windows toolchain locally, so the Windows CI job is the check for point 1.
harisibrar1 commented 2026-10-24 13:56:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T13:56:25Z.

Review: COMMENTED


Checked against main 522e32e3b6 and Dinkumware's xxstod.h / xxxdtent.h (openqnx cc95df35):

  • The earlier review points are all fixed in 6a23fe1 (64-bit returns and pten, rescaling an overflowed inf, the libc.md entry). The branch still merges cleanly into current main now that #8376 is in; the merged DinkumwareInternals.cpp is exactly this branch's file, and _Stod behaves as on main.
  • All nine NIDs in the description match the names.
  • One question on subnormal results. ScaledFloat (DinkumwareInternals.cpp:70) sets *error = 1 only when the result is 0 or inf, but keeps whatever ERANGE the host strtod/strtof set. In Dinkumware's _Dtentox, errno and *perr are set in the same branch (xxxdtent.h L102-107), and the QNX copy also counts a denormal as underflow (L80-88). I couldn't run this; reading glibc's strtod suggests _Stodx("1e-310", &end, 0, &err) here gives errno = ERANGE with err = 0, which neither variant does. Since you note the console rounds once (so it may not be stock Dinkumware), could you run one subnormal case ("1e-310" with scale 0, and maybe "1e-300" with -10) through the console module and add it to TestFloatErrors? Whichever way it answers, the test would then pin the combination down.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638496098 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8384#pullrequestreview-5638496098). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-24T13:56:25Z. **Review:** COMMENTED --- Checked against main 522e32e3b6 and Dinkumware's xxstod.h / xxxdtent.h (openqnx cc95df35): - The earlier review points are all fixed in 6a23fe1 (64-bit returns and `pten`, rescaling an overflowed inf, the libc.md entry). The branch still merges cleanly into current main now that #8376 is in; the merged `DinkumwareInternals.cpp` is exactly this branch's file, and `_Stod` behaves as on main. - All nine NIDs in the description match the names. - One question on subnormal results. `ScaledFloat` (DinkumwareInternals.cpp:70) sets `*error = 1` only when the result is 0 or inf, but keeps whatever ERANGE the host `strtod`/`strtof` set. In Dinkumware's `_Dtentox`, errno and `*perr` are set in the same branch (xxxdtent.h L102-107), and the QNX copy also counts a denormal as underflow (L80-88). I couldn't run this; reading glibc's strtod suggests `_Stodx("1e-310", &end, 0, &err)` here gives errno = ERANGE with err = 0, which neither variant does. Since you note the console rounds once (so it may not be stock Dinkumware), could you run one subnormal case (`"1e-310"` with scale 0, and maybe `"1e-300"` with -10) through the console module and add it to `TestFloatErrors`? Whichever way it answers, the test would then pin the combination down. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
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!8384
No description provided.