fix(libc): compute exp2 with FreeBSD msun's algorithm, as titles' libc.prx does #10274

Merged
JJenkx merged 8 commits from upstream-pr/10274 into main 2026-11-12 06:15:00 +00:00
JJenkx commented 2026-10-23 16:15:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-23T16:15:29Z.


What

exp2 returned the host's exp2, so its last bit depended on the host. On Windows (UCRT) it differs from the libc.prx that titles ship on 57,412,184 of 320 million random arguments, about 18%. For example, exp2(0x401c2caf278dc3f3) is 0x40607dc899331269 on the console and 0x40607dc899331268 here, and exp2(0x404ac26689a8dc7a) is 0x4346ec6938394318 there and 0x4346ec6938394317 here.

The titles' copy (NID dnaeGXbjP6E) is FreeBSD msun's s_exp2.c. exp2 now computes it:

  • the special-value and range filter;
  • the x + redux reduction into a 1/256 step and its table index;
  • the 256-pair tbl of exp2(z + eps) and eps, taken verbatim from the source;
  • the P1–P5 polynomial;
  • the 2^k scaling with the k == 1024 and subnormal paths;
  • huge and twom1000 read at run time.

errno: msun sets none. The titles' copy sets ERANGE in exactly msun's overflow (x >= 1024) and underflow (x <= -1075) branches. All three titles do so for exp2(1024), exp2(1100), exp2(-1075) and exp2(-1100), with FE_OVERFLOW or FE_UNDERFLOW raised. exp2(1023) and exp2(-1074) leave errno alone, and so do NaN and the infinities. This port sets it there.

Change to an existing check: #3599 made exp2 keep errno unchanged, following FreeBSD's source, and added CheckExp2Errno, which expects exp2(1024) to leave errno at 0. This PR changes only that expectation, to ERANGE, because the titles' copies set it. The same check's FE_OVERFLOW | FE_INEXACT test is unchanged and still passes. cc @CouchRiv, the same point as the asin change in #10253.

Tested

Current-main integration — 2026-11-09 UTC. Head d1b49ecc308cbd4e954c04e9eb40eeaec8b706bb preserves public head 624d14c732bf72e25a44d2c9d1706471c8d4e56f and integrates pinned main 7259cce11195f360698772da8c0b3af756bf7c8f. Conflict resolution retains both the topic and main's newer source/test/debt changes; maintainer commits and attribution remain intact.

Linux x86-64, GCC 16.2.1, Ninja Release: actual libc/libkernel and focused fixture owners rebuilt. 12/12 CPU executions pass, zero skips (4 groups × three repetitions): guest_math, guest_math_elementary, guest_math_exact, guest_dinkumware_internals. public_headers, conventions and whitespace checks pass. The matching plain-main control passed 102 selected CPU executions and its header audit. CPU fixtures execute unpatched production libraries; this is not a full SDK or patched-title runtime qualification.

No new Windows/macOS, console, GPU, title or performance result is claimed. Source checks preserve the existing production topic; historical reports below retain their original pins.

Build/test logs, exact heads, source/ancestry checks and provider pins, SHA-256 52727be6594b9c15bf9a5535fef374b985e9526aabe5f3ef5cf5857dfeeb1a0d. The public archive and all 178 manifest files were download/hash verified.

Current-main integration — 2026-11-03. Head aa78a9ecd819e714b60604b4929c5c8818a1163d includes main 4f41f4c375f5abb487dbd184fbc150f31994d762 and retains the prior public history and attribution/licence notices. Main’s newer math implementations and fixtures remain alongside this topic. Actual open prerequisite #10265 head 3bf30fd4920e751df3825b9abb75f7a0832ecf37 is an ancestor.

Linux x86-64 Release, GCC 16.2.1, Ninja, BUILD_TESTING=ON: rebuilt actual libc and math executables. guest_math, guest_math_exact, and guest_dinkumware_internals each pass 3/3 (9 passes, zero skips); public_headers and conventions pass. The same three groups pass 3/3 plus headers on pinned main. All 34 recursive dependency trees and 31,551 tracked blobs verify with zero errors; the update=none QuickJS test262 corpus is excluded from these library inputs. Whitespace check passes.

Source/parent/gitlink proofs, exact library/test hashes, raw logs/JUnit, and head-leased push receipts: qualification archive, SHA-256 e6a50522bc28e30871fdc2c12a88d2537515914239e8166f6237f48895126a06 (download verified). Older platform/reference reports retain their original pins; no new Windows/macOS, SDK-module, console, title/GPU or performance claim. AI-assisted: yes (Codex).

Earlier dated qualifications below retain their recorded source/platform pins.

Current-main integration (2026-11-02): f105d143c56cf6e4e0255a342b4f470720e97d43 includes main a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8 and retains the existing public commits. Conflicts preserve main’s math implementations, regression checks and debt entries alongside this topic. Linux x86-64 Release, GCC 16.2.1: rebuilt libc and the three math executables; guest_math, guest_math_exact and guest_dinkumware_internals each pass three times (9 passes, zero skips), and public_headers passes. The same baseline groups pass on main; conventions and whitespace pass. Source and dependency blobs, executable/library hashes, raw logs and JUnit are retained. This refresh adds no new console, Windows, title, GPU or numerical-reference measurement. Qualification evidence, SHA-256 22866bd2a060ba69cd4387d471605afe20ed644e3257174b2d1488635f8c9b52 (download verified).

The current prerequisite #10265 head 3bf30fd4920e751df3825b9abb75f7a0832ecf37 is an ancestor of refreshed head aa78a9ecd819e714b60604b4929c5c8818a1163d.

Main conflict refresh, 2026-10-27 10:18 UTC pass: exact head 26ea9fdf6abedd3c11cc4d8c8b601cd51dacc102 on tested main 3fea2a937ba9fbab2f06c51691fe0c5763659aa3. The topic implementations and fixtures are retained alongside current main's newer math functions and coverage.

Linux Release focused rebuild: guest_math and guest_math_exact each pass three repetitions: 6 passes, zero skips. Conventions, whitespace and merge checks pass. Every refreshed head's submodule pointers match the pinned main; the private dependency checkouts used for the gates are aligned. No new negative-control, Windows, console, title, GPU, full-suite or performance run is claimed. Earlier measurements below retain their original exact pins. Fulfilled merge-order dependencies have been cleared from the checklist; open prerequisites remain.

Exact source/dependency pins, patch-preservation and gitlink proofs, builds, verbose tests, JUnit and lease-push receipts. SHA-256: 702c4110ee9dde421c2dd5e057ed53a2df05e0cf7b01f67e8fb9cb779e332f7c; downloaded copy verified.

Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release, BUILD_TESTING=ON, main 15e71dbe11.

  • Comparison: a scratch loader runs the decrypted libc.prx of PPSA07923, PPSA05916 and PPSA13934 natively and supplies __error. It compared their exp2 with this PR's code, checking result bits (NaN payloads included) and errno, on:

    • 320 million random arguments per title: a third random bit patterns, a third with exponents 2^-63 to 2^8, and a third with exponents 2^9 to 2^10, around the thresholds;
    • 44,624 structured arguments:
      • every integer from −1100 to 1100;
      • halves from −200 to 200, quarters from −100 to 100, and 1/256 steps from −1.5625 to 1.5625;
      • the 4,000 floats on each side of 1024, −1021, −1022, −1074, −1075, ±2^-54, ±1 and 0.5;
      • the special values.

    Results:

    • PPSA07923 and PPSA05916: identical bits and errno on all of them.
    • PPSA13934: identical errno. The bits differ on 30,671 random arguments, because that copy is an FMA-contracted build.
    • The console sets ERANGE on exactly the arguments in msun's overflow and underflow branches.
  • guest_math: the new CheckExp2ConsoleBits has 31 cases with the console's results and errno:

    • ±0 and both sides of the 2^-54 shortcut;
    • ±1, 0.5 and ±10;
    • both sides of 1024;
    • −1022, −1021, the subnormal range and both sides of −1075;
    • ±DBL_MAX, the infinities and NaN payloads of both signs;
    • six arguments where UCRT differs.

    guest_math and guest_dinkumware_internals pass in three runs out of three on the exact head.

  • Negative control: with main's Math.cpp and these tests, guest_math aborts in a Require, while guest_dinkumware_internals still passes.

  • python tools/check_conventions.py --base origin/main and git diff --check pass.

  • Overlap and order: #9850, #10222, #10229, #10234, #10247, #10317, #10253 and #10265, all mine, replace one-line host wrappers near exp2's or add tests and debt entries at the same anchors, so they conflict textually. This PR lands last: #9777 → #9784 → #10222 → #9850 → #10229 → #10234 → #10245 → #10247 → #10317 → #10250 → #10253 → #10265 → this PR, with #10226 after #10222, #9857 before #10250 and #9771 before #10253. It merges cleanly with #9844 (exp2f). A combined preview of all fifteen heads (f1c3cf72af) resolves every conflict by keeping each port and dropping each host wrapper; each ported function is defined once and each console test is called once, and guest_math and guest_dinkumware_internals pass in three runs out of three on it. This is the historical fifteen-head preview and did not include #10317. The new order declaration does not extend that historical test claim.

  • Not tested: Linux and macOS (the result no longer depends on the host's exp2), a console, the floating-point exception flags beyond the existing check, and exp2l.

Review follow-up (2026-10-26): private pair 53817b0358f81e7eec203f08f59bf109270dfe73 combines current #10317 and this PR, with one definition and regression call per topic. After rebuilding libc and the three executables, guest_math, guest_math_exact, guest_dinkumware_internals and the public_headers manifest audit each pass three repetitions (12 passes, no skips). This is pair integration at the pinned main ancestry, not complete-series or newest-main qualification. Pins, source retention and CPU logs, SHA-256 71cdbc1d4d45522c328ccf80b51393626b7b0438d1805397608e8c081d1b9f69.

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: none; the msun function and its table are rewritten, as #9668, #5036 and the sinhf entry did
  • Generic behaviour, not specific to one title
  • Depends on: #10265 (actual refreshed head 3bf30fd4920e751df3825b9abb75f7a0832ecf37)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4985792235 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10274). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-23T16:15:29Z. --- ### What `exp2` returned the host's `exp2`, so its last bit depended on the host. On Windows (UCRT) it differs from the `libc.prx` that titles ship on 57,412,184 of 320 million random arguments, about 18%. For example, `exp2(0x401c2caf278dc3f3)` is `0x40607dc899331269` on the console and `0x40607dc899331268` here, and `exp2(0x404ac26689a8dc7a)` is `0x4346ec6938394318` there and `0x4346ec6938394317` here. The titles' copy (NID `dnaeGXbjP6E`) is FreeBSD msun's [`s_exp2.c`](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/lib/msun/src/s_exp2.c). `exp2` now computes it: - the special-value and range filter; - the `x + redux` reduction into a 1/256 step and its table index; - the 256-pair `tbl` of `exp2(z + eps)` and `eps`, taken verbatim from the source; - the `P1`–`P5` polynomial; - the `2^k` scaling with the `k == 1024` and subnormal paths; - `huge` and `twom1000` read at run time. **`errno`:** msun sets none. The titles' copy sets `ERANGE` in exactly msun's overflow (`x >= 1024`) and underflow (`x <= -1075`) branches. All three titles do so for `exp2(1024)`, `exp2(1100)`, `exp2(-1075)` and `exp2(-1100)`, with `FE_OVERFLOW` or `FE_UNDERFLOW` raised. `exp2(1023)` and `exp2(-1074)` leave `errno` alone, and so do NaN and the infinities. This port sets it there. **Change to an existing check:** #3599 made `exp2` keep `errno` unchanged, following FreeBSD's source, and added `CheckExp2Errno`, which expects `exp2(1024)` to leave `errno` at 0. This PR changes only that expectation, to `ERANGE`, because the titles' copies set it. The same check's `FE_OVERFLOW | FE_INEXACT` test is unchanged and still passes. cc @CouchRiv, the same point as the `asin` change in #10253. ### Tested <!-- codex-maintenance-20261109-cpu-10274 --> **Current-main integration — 2026-11-09 UTC.** Head `d1b49ecc308cbd4e954c04e9eb40eeaec8b706bb` preserves public head `624d14c732bf72e25a44d2c9d1706471c8d4e56f` and integrates pinned main `7259cce11195f360698772da8c0b3af756bf7c8f`. Conflict resolution retains both the topic and main's newer source/test/debt changes; maintainer commits and attribution remain intact. Linux x86-64, GCC 16.2.1, Ninja Release: actual libc/libkernel and focused fixture owners rebuilt. **12/12 CPU executions pass, zero skips** (4 groups × three repetitions): `guest_math`, `guest_math_elementary`, `guest_math_exact`, `guest_dinkumware_internals`. `public_headers`, conventions and whitespace checks pass. The matching plain-main control passed 102 selected CPU executions and its header audit. CPU fixtures execute unpatched production libraries; this is not a full SDK or patched-title runtime qualification. No new Windows/macOS, console, GPU, title or performance result is claimed. Source checks preserve the existing production topic; historical reports below retain their original pins. [Build/test logs, exact heads, source/ancestry checks and provider pins](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/cpu8-main7259-linux-20261109.tar.gz), SHA-256 `52727be6594b9c15bf9a5535fef374b985e9526aabe5f3ef5cf5857dfeeb1a0d`. The public archive and all 178 manifest files were download/hash verified. **Current-main integration — 2026-11-03.** Head `aa78a9ecd819e714b60604b4929c5c8818a1163d` includes main `4f41f4c375f5abb487dbd184fbc150f31994d762` and retains the prior public history and attribution/licence notices. Main’s newer math implementations and fixtures remain alongside this topic. Actual open prerequisite #10265 head `3bf30fd4920e751df3825b9abb75f7a0832ecf37` is an ancestor. Linux x86-64 Release, GCC 16.2.1, Ninja, BUILD_TESTING=ON: rebuilt actual libc and math executables. `guest_math`, `guest_math_exact`, and `guest_dinkumware_internals` each pass 3/3 (**9 passes, zero skips**); `public_headers` and conventions pass. The same three groups pass 3/3 plus headers on pinned main. All 34 recursive dependency trees and 31,551 tracked blobs verify with zero errors; the update=none QuickJS test262 corpus is excluded from these library inputs. Whitespace check passes. Source/parent/gitlink proofs, exact library/test hashes, raw logs/JUnit, and head-leased push receipts: [qualification archive](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/math15-main4f41-linux-20261103.tar.gz), SHA-256 `e6a50522bc28e30871fdc2c12a88d2537515914239e8166f6237f48895126a06` (download verified). Older platform/reference reports retain their original pins; no new Windows/macOS, SDK-module, console, title/GPU or performance claim. AI-assisted: yes (Codex). Earlier dated qualifications below retain their recorded source/platform pins. **Current-main integration (2026-11-02):** `f105d143c56cf6e4e0255a342b4f470720e97d43` includes main `a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8` and retains the existing public commits. Conflicts preserve main’s math implementations, regression checks and debt entries alongside this topic. Linux x86-64 Release, GCC 16.2.1: rebuilt libc and the three math executables; `guest_math`, `guest_math_exact` and `guest_dinkumware_internals` each pass three times (9 passes, zero skips), and `public_headers` passes. The same baseline groups pass on main; conventions and whitespace pass. Source and dependency blobs, executable/library hashes, raw logs and JUnit are retained. This refresh adds no new console, Windows, title, GPU or numerical-reference measurement. [Qualification evidence](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/math-root14-maina4eca-linux-20261102-terminal.tar.gz), SHA-256 `22866bd2a060ba69cd4387d471605afe20ed644e3257174b2d1488635f8c9b52` (download verified). The current prerequisite #10265 head `3bf30fd4920e751df3825b9abb75f7a0832ecf37` is an ancestor of refreshed head `aa78a9ecd819e714b60604b4929c5c8818a1163d`. <!-- codex-main-refresh-20261027-1018-pr10274 --> **Main conflict refresh, 2026-10-27 10:18 UTC pass:** exact head `26ea9fdf6abedd3c11cc4d8c8b601cd51dacc102` on tested main `3fea2a937ba9fbab2f06c51691fe0c5763659aa3`. The topic implementations and fixtures are retained alongside current main's newer math functions and coverage. Linux Release focused rebuild: `guest_math` and `guest_math_exact` each pass three repetitions: 6 passes, zero skips. Conventions, whitespace and merge checks pass. Every refreshed head's submodule pointers match the pinned main; the private dependency checkouts used for the gates are aligned. No new negative-control, Windows, console, title, GPU, full-suite or performance run is claimed. Earlier measurements below retain their original exact pins. Fulfilled merge-order dependencies have been cleared from the checklist; open prerequisites remain. [Exact source/dependency pins, patch-preservation and gitlink proofs, builds, verbose tests, JUnit and lease-push receipts](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/owned-cpu11-main3fea-linux-20261027-1018.tar.gz). SHA-256: `702c4110ee9dde421c2dd5e057ed53a2df05e0cf7b01f67e8fb9cb779e332f7c`; downloaded copy verified. Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release, `BUILD_TESTING=ON`, `main` 15e71dbe11. - **Comparison:** a scratch loader runs the decrypted `libc.prx` of PPSA07923, PPSA05916 and PPSA13934 natively and supplies `__error`. It compared their `exp2` with this PR's code, checking result bits (NaN payloads included) and `errno`, on: - 320 million random arguments per title: a third random bit patterns, a third with exponents 2^-63 to 2^8, and a third with exponents 2^9 to 2^10, around the thresholds; - 44,624 structured arguments: - every integer from −1100 to 1100; - halves from −200 to 200, quarters from −100 to 100, and 1/256 steps from −1.5625 to 1.5625; - the 4,000 floats on each side of 1024, −1021, −1022, −1074, −1075, ±2^-54, ±1 and 0.5; - the special values. Results: - PPSA07923 and PPSA05916: identical bits and `errno` on all of them. - PPSA13934: identical `errno`. The bits differ on 30,671 random arguments, because that copy is an FMA-contracted build. - The console sets `ERANGE` on exactly the arguments in msun's overflow and underflow branches. - **`guest_math`:** the new `CheckExp2ConsoleBits` has 31 cases with the console's results and `errno`: - ±0 and both sides of the 2^-54 shortcut; - ±1, 0.5 and ±10; - both sides of 1024; - −1022, −1021, the subnormal range and both sides of −1075; - `±DBL_MAX`, the infinities and NaN payloads of both signs; - six arguments where UCRT differs. `guest_math` and `guest_dinkumware_internals` pass in three runs out of three on the exact head. - **Negative control:** with `main`'s `Math.cpp` and these tests, `guest_math` aborts in a `Require`, while `guest_dinkumware_internals` still passes. - `python tools/check_conventions.py --base origin/main` and `git diff --check` pass. - **Overlap and order:** #9850, #10222, #10229, #10234, #10247, #10317, #10253 and #10265, all mine, replace one-line host wrappers near `exp2`'s or add tests and debt entries at the same anchors, so they conflict textually. This PR lands last: #9777 → #9784 → #10222 → #9850 → #10229 → #10234 → #10245 → #10247 → #10317 → #10250 → #10253 → #10265 → this PR, with #10226 after #10222, #9857 before #10250 and #9771 before #10253. It merges cleanly with #9844 (`exp2f`). A combined preview of all fifteen heads (`f1c3cf72af`) resolves every conflict by keeping each port and dropping each host wrapper; each ported function is defined once and each console test is called once, and `guest_math` and `guest_dinkumware_internals` pass in three runs out of three on it. This is the historical fifteen-head preview and did not include #10317. The new order declaration does not extend that historical test claim. - **Not tested:** Linux and macOS (the result no longer depends on the host's `exp2`), a console, the floating-point exception flags beyond the existing check, and `exp2l`. Review follow-up (2026-10-26): private pair `53817b0358f81e7eec203f08f59bf109270dfe73` combines current #10317 and this PR, with one definition and regression call per topic. After rebuilding libc and the three executables, guest_math, guest_math_exact, guest_dinkumware_internals and the public_headers manifest audit each pass three repetitions (12 passes, no skips). This is pair integration at the pinned main ancestry, not complete-series or newest-main qualification. [Pins, source retention and CPU logs](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/pr-review-math-clock-integrations-linux-20261026.tar.gz), SHA-256 `71cdbc1d4d45522c328ccf80b51393626b7b0438d1805397608e8c081d1b9f69`. ### 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: none; the msun function and its table are rewritten, as #9668, #5036 and the `sinhf` entry did - [x] Generic behaviour, not specific to one title - [x] Depends on: #10265 (actual refreshed head `3bf30fd4920e751df3825b9abb75f7a0832ecf37`) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
harisibrar1 commented 2026-10-24 13:08:46 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Checked against main 99feaf0eb8 and FreeBSD release/11.4.0 lib/msun/src/s_exp2.c:

  • The port matches s_exp2.c line by line. redux, P1–P5, the filter thresholds and the scaling paths are the same, and all 512 tbl entries are bit-identical to the source when compared as packed doubles.
  • A separate reimplementation of s_exp2.c reproduces all 31 expected bits and errno values in CheckExp2ConsoleBits.
  • One suggestion on test strength: every finite expected value there, including the six "UCRT differs" ones, equals the correctly rounded 2^x. So the test catches a revert to the host exp2 only on hosts that misround those inputs, and the negative control was Windows-only. Adding an input where msun itself is not correctly rounded would make it host-independent. Candidates from my reference port, worth confirming against the bundled prx first:
    • 0xc0321ba29677ea92 → 0x3ecdb167a3cd19aa (correctly rounded: ...ab)
    • 0x40310f6e2ae38766 → 0x4100aec0c9ca9cd0 (correctly rounded: ...d1)
  • Minor: the order list in the description doesn't include #10317 (log2), which also inserts at the MakeExtended / CheckExpm1ConsoleBits anchors in GuestMath.cpp.
  • It still merges cleanly onto current main, which still has the host wrapper.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638357113 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10274#pullrequestreview-5638357113). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-24T13:08:46Z. **Review:** COMMENTED --- Checked against main 99feaf0eb8 and FreeBSD `release/11.4.0` `lib/msun/src/s_exp2.c`: - The port matches `s_exp2.c` line by line. `redux`, P1–P5, the filter thresholds and the scaling paths are the same, and all 512 `tbl` entries are bit-identical to the source when compared as packed doubles. - A separate reimplementation of s_exp2.c reproduces all 31 expected bits and `errno` values in `CheckExp2ConsoleBits`. - One suggestion on test strength: every finite expected value there, including the six "UCRT differs" ones, equals the correctly rounded 2^x. So the test catches a revert to the host `exp2` only on hosts that misround those inputs, and the negative control was Windows-only. Adding an input where msun itself is not correctly rounded would make it host-independent. Candidates from my reference port, worth confirming against the bundled prx first: - `0xc0321ba29677ea92` → `0x3ecdb167a3cd19aa` (correctly rounded: `...ab`) - `0x40310f6e2ae38766` → `0x4100aec0c9ca9cd0` (correctly rounded: `...d1`) - Minor: the order list in the description doesn't include #10317 (log2), which also inserts at the `MakeExtended` / `CheckExpm1ConsoleBits` anchors in `GuestMath.cpp`. - It still merges cleanly onto current main, which still has the host wrapper. 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!10274
No description provided.