fix(libc): compute sin, cos and tan with FreeBSD msun's algorithm, as titles' libc.prx does #10250

Merged
JJenkx merged 9 commits from upstream-pr/10250 into main 2026-11-05 17:48:20 +00:00
JJenkx commented 2026-10-23 15:41:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-23T15:41:56Z.


What

sin, cos and tan returned the host's functions, so their last bit and their errno depended on the host. On Windows (UCRT) they differ from the libc.prx that titles ship on 3,338,607, 3,340,843 and 8,098,628 of 320 million random arguments. Three examples, each a value where UCRT is 1 ulp off:

call console UCRT
sin(0x3fdada3603b109eb) 0x3fda124ac129e754 0x3fda124ac129e755
cos(0x4079ab389c31a606) 0xbfe52f138550db6f 0xbfe52f138550db6e
tan(0xbfcdf9356ad39d8f) 0xbfce889b662f705f 0xbfce889b662f705e

The titles' copies (NIDs H8ya2H00jbI, 2WE3BTYVwKM and T7uyNqP7vQA) are FreeBSD msun's s_sin.c, s_cos.c and s_tan.c, over its k_sin.c, k_cos.c, k_tan.c and e_rem_pio2.c, plus k_rem_pio2.c for huge arguments. These now compute them:

  • RemPio2: the small multiples of π/2, the medium path with its two refinements, and the large-argument path through k_rem_pio2.c;
  • KernelSin, KernelCos and KernelTan;
  • the three entry points.

Shared reduction. #9857 ported k_rem_pio2.c for sinf, cosf and tanf, but only for one input word and prec 0, as TrigfKernelRemPio2. This PR gives it msun's nx and prec parameters and renames it KernelRemPio2, with its tables RemPio2Ipio2 and RemPio2Parts. The double path calls it with up to three words and prec 1, which adds msun's second output word; the float path calls it with (…, 1, 0) and computes exactly what it did before. The float debt entry is updated to say the port is shared.

errno: msun sets none. The titles' copies set EDOM when the argument's high word is 0x7ff00000 or 0xfff00000: the infinities, and also the NaNs that share that high word, such as 0xfff0000054442d18. Other NaNs, such as 0x7ff8000000000001, leave errno alone. They return msun's x - x. This port tests the same high word.

Tested

Current-main refresh — 2026-11-04. Head 7a21d9762f01427c9a3ef744f4f753162419442e merges main 9ab6a281ea61c9e62a7eb07eb4cef8f19ede1c5c while retaining the prior public head as an ancestor. Main’s newer code, regression fixtures and debt entries are preserved alongside this topic.

Linux x86-64, GCC16.2.1, Ninja Release: actual libc, libkernel and libSceAmpr CMake owners rebuilt coherently. guest_math, guest_math_exact, guest_dinkumware_internals each pass three consecutive runs (9 passes, zero skips). The same groups pass three times on pinned main. Public-header audit and conventions pass. Original licence-notice trailing whitespace is retained where present. The scoped recipe reuses frozen ZArchive/zstd providers; this is not a whole-project build. No new Windows, bundled-SDK, physical-console, title/GPU or FPS measurement is claimed; earlier reports retain their original pins.

Exact source/parent proofs, per-branch patches/input manifests, build and CTest logs/JUnit, library/executable hashes and scoped CMake recipe, SHA-256 97a2377bc996be1690e8853e1ea090a98b5ed808bcc37a15a5cdada5c2e00845 (download verified). AI-assisted: yes (Codex).

Current-main integration — 2026-11-03. Head 5c054e6b5e48aef1bde87b7f6c31b70a9e00d563 includes main 4f41f4c375f5abb487dbd184fbc150f31994d762 and retains the prior public history and attribution/licence notices. Main’s newer math implementations and fixtures remain alongside this topic. Main’s float argument-reduction tables, helper and TrigfRemPio2 remain byte-identical and separate from the retained topic double-trig implementation.

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. git diff --check reports the preserved verbatim licence trailing-space line; no other whitespace warnings occur.

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): 4947eef3565f9117da59c10574a5c68df3f29760 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).

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

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

    • 320 million random arguments per title: half random bit patterns, a quarter with exponents 2^-31 to 2^32, and a quarter with exponents 2^1 to 2^80 (reaching k_rem_pio2.c), plus infinities;
    • 69,316 structured arguments:
      • the 81 floats around each multiple of π/4 up to 100π, both signs;
      • every range edge in e_rem_pio2.c and the three kernels, with four low words each;
      • every power of two from 2^-1074 to 2^1023, both signs;
      • the special values.

    Results:

    • PPSA07923 and PPSA05916: identical bits and errno on all of them.
    • PPSA13934: identical errno. The bits differ on about 0.35% (sin, cos) and 0.7% (tan) of the random arguments, because that copy is an FMA-contracted build.
  • guest_math: the new CheckTrigConsoleBits has 24 arguments, each with the console's sin, cos and tan and its errno:

    • ±0 and the tiny-argument edge;
    • π/4, π/2, ±π, 2π and 3π/2;
    • 10^6 and 1638400 on the medium path;
    • 10^300 and ±DBL_MAX through k_rem_pio2.c;
    • ±inf, a NaN with an infinity's high word, and a quiet NaN;
    • two arguments per function where UCRT differs.

    The existing CheckTrigfConsoleBits still passes over the shared reduction.

    guest_math passes in three runs out of three on the exact head. (guest_dinkumware_internals did not exist on #9857's base; it runs in the combined preview below.)

  • Negative control: with #9857's Math.cpp and this test, guest_math aborts in a Require.

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

  • Overlap and order: this PR is stacked on #9857, which merges cleanly with the rest of my math series. It replaces host wrappers next to those of #10222, #10229, #10234, #10245 and #10247, so it lands last: #9777 → #9784 → #10222 → #9850 → #10229 → #10234 → #10245 → #10247 → #10250 → #10253 → the pow PR, with #10226 after #10222, #9857 before #10250 and #9771 before #10253. A combined preview of all ten heads (3e088f450d), including #9857, resolves every conflict by keeping each port and dropping each host wrapper. Each ported function is defined once and each of the eight console tests is called once, and guest_math and guest_dinkumware_internals pass in three runs out of three on it.

  • Not tested: Linux and macOS (the result no longer depends on the host's functions), a console, the floating-point exception flags, and sinl/cosl/tanl (still the host's, as listed in the debt file).

Current Linux qualification (2026-10-28)

Rebased onto main 2227f1366188cda5699dd20e2e756a18006a5d4b. Linux CPU validation on 2026-10-28 at 4d98e8148f038bca77cc104a1796608d5e99999a (Arch Linux 7.2.9, AMD Ryzen 9 7950X, GCC 16.2.1, Ninja Release, BUILD_TESTING=ON).

libc, guest_math_tests and guest_math_exact_tests rebuilt from this exact source. guest_math and guest_math_exact each passed three consecutive runs (6/6, no skips); the same two suites each passed three runs on the pinned main (6/6). Conventions and whitespace checks pass.

Exact source pins, preservation proofs, dependency checks, build logs and JUnit, SHA-256 1176269c9e6948b5252a5db9e660978d7f978fb2d9f4ed6c68bc050b10b5ae68. This is focused Linux CPU qualification; earlier Windows/title/reference measurements retain their original pins. No new title or performance result is claimed.

Canonical declaration cleanup (2026-10-28)

At a3b71d51a5cd, removed 94 duplicate local export declarations from GuestMath.cpp; its included Api.hpp supplies them. Production code and numeric test bodies are unchanged. Original fails the actual header audit; candidate passes. Per-branch affected-test syntax compilation and conventions/whitespace pass; full standalone-header compilation passed once for the byte-identical header tree shared by the four affected PRs. Source/proofs/logs, SHA256 44f560018e4f6b52e8dda4158383f64fc3059fcdb6444840fe5c04fb2c884f11. No new numerical-runtime/platform claim; earlier runs retain original pins. Normal fast-forward only, no rebase. AI-assisted: Codex.

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 functions are rewritten, as #9668, #5036 and the sinhf entry did
  • Generic behaviour, not specific to one title
  • Depends on: none (#10247 is merged)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4985343082 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10250). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-23T15:41:56Z. --- ### What `sin`, `cos` and `tan` returned the host's functions, so their last bit and their `errno` depended on the host. On Windows (UCRT) they differ from the `libc.prx` that titles ship on 3,338,607, 3,340,843 and 8,098,628 of 320 million random arguments. Three examples, each a value where UCRT is 1 ulp off: | call | console | UCRT | |---|---|---| | `sin(0x3fdada3603b109eb)` | `0x3fda124ac129e754` | `0x3fda124ac129e755` | | `cos(0x4079ab389c31a606)` | `0xbfe52f138550db6f` | `0xbfe52f138550db6e` | | `tan(0xbfcdf9356ad39d8f)` | `0xbfce889b662f705f` | `0xbfce889b662f705e` | The titles' copies (NIDs `H8ya2H00jbI`, `2WE3BTYVwKM` and `T7uyNqP7vQA`) are FreeBSD msun's [`s_sin.c`, `s_cos.c` and `s_tan.c`](https://github.com/freebsd/freebsd-src/tree/release/11.4.0/lib/msun/src), over its `k_sin.c`, `k_cos.c`, `k_tan.c` and `e_rem_pio2.c`, plus `k_rem_pio2.c` for huge arguments. These now compute them: - `RemPio2`: the small multiples of π/2, the medium path with its two refinements, and the large-argument path through `k_rem_pio2.c`; - `KernelSin`, `KernelCos` and `KernelTan`; - the three entry points. **Shared reduction.** #9857 ported `k_rem_pio2.c` for `sinf`, `cosf` and `tanf`, but only for one input word and `prec` 0, as `TrigfKernelRemPio2`. This PR gives it msun's `nx` and `prec` parameters and renames it `KernelRemPio2`, with its tables `RemPio2Ipio2` and `RemPio2Parts`. The double path calls it with up to three words and `prec` 1, which adds msun's second output word; the float path calls it with `(…, 1, 0)` and computes exactly what it did before. The float debt entry is updated to say the port is shared. **`errno`:** msun sets none. The titles' copies set `EDOM` when the argument's high word is `0x7ff00000` or `0xfff00000`: the infinities, and also the NaNs that share that high word, such as `0xfff0000054442d18`. Other NaNs, such as `0x7ff8000000000001`, leave `errno` alone. They return msun's `x - x`. This port tests the same high word. ### Tested <!-- libc-main9ab-refresh-20261104-10250 --> **Current-main refresh — 2026-11-04.** Head `7a21d9762f01427c9a3ef744f4f753162419442e` merges main `9ab6a281ea61c9e62a7eb07eb4cef8f19ede1c5c` while retaining the prior public head as an ancestor. Main’s newer code, regression fixtures and debt entries are preserved alongside this topic. Linux x86-64, GCC16.2.1, Ninja Release: actual libc, libkernel and libSceAmpr CMake owners rebuilt coherently. `guest_math`, `guest_math_exact`, `guest_dinkumware_internals` each pass three consecutive runs (**9 passes, zero skips**). The same groups pass three times on pinned main. Public-header audit and conventions pass. Original licence-notice trailing whitespace is retained where present. The scoped recipe reuses frozen ZArchive/zstd providers; this is not a whole-project build. No new Windows, bundled-SDK, physical-console, title/GPU or FPS measurement is claimed; earlier reports retain their original pins. [Exact source/parent proofs, per-branch patches/input manifests, build and CTest logs/JUnit, library/executable hashes and scoped CMake recipe](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/owned-libc11-main9ab-linux-20261104.tar.gz), SHA-256 `97a2377bc996be1690e8853e1ea090a98b5ed808bcc37a15a5cdada5c2e00845` (download verified). AI-assisted: yes (Codex). **Current-main integration — 2026-11-03.** Head `5c054e6b5e48aef1bde87b7f6c31b70a9e00d563` includes main `4f41f4c375f5abb487dbd184fbc150f31994d762` and retains the prior public history and attribution/licence notices. Main’s newer math implementations and fixtures remain alongside this topic. Main’s float argument-reduction tables, helper and `TrigfRemPio2` remain byte-identical and separate from the retained topic double-trig implementation. 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. `git diff --check` reports the preserved verbatim licence trailing-space line; no other whitespace warnings occur. 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):** `4947eef3565f9117da59c10574a5c68df3f29760` 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). Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release, `BUILD_TESTING=ON`. - **Comparison:** a scratch loader runs the decrypted `libc.prx` of PPSA07923, PPSA05916 and PPSA13934 natively and supplies `__error`. It compared their `sin`, `cos` and `tan` with this PR's code, checking result bits (NaN payloads included) and `errno`, on: - 320 million random arguments per title: half random bit patterns, a quarter with exponents 2^-31 to 2^32, and a quarter with exponents 2^1 to 2^80 (reaching `k_rem_pio2.c`), plus infinities; - 69,316 structured arguments: - the 81 floats around each multiple of π/4 up to 100π, both signs; - every range edge in `e_rem_pio2.c` and the three kernels, with four low words each; - every power of two from 2^-1074 to 2^1023, both signs; - the special values. Results: - PPSA07923 and PPSA05916: identical bits and `errno` on all of them. - PPSA13934: identical `errno`. The bits differ on about 0.35% (`sin`, `cos`) and 0.7% (`tan`) of the random arguments, because that copy is an FMA-contracted build. - **`guest_math`:** the new `CheckTrigConsoleBits` has 24 arguments, each with the console's `sin`, `cos` and `tan` and its `errno`: - ±0 and the tiny-argument edge; - π/4, π/2, ±π, 2π and 3π/2; - 10^6 and 1638400 on the medium path; - 10^300 and ±`DBL_MAX` through `k_rem_pio2.c`; - ±`inf`, a NaN with an infinity's high word, and a quiet NaN; - two arguments per function where UCRT differs. The existing `CheckTrigfConsoleBits` still passes over the shared reduction. `guest_math` passes in three runs out of three on the exact head. (`guest_dinkumware_internals` did not exist on #9857's base; it runs in the combined preview below.) - **Negative control:** with #9857's `Math.cpp` and this test, `guest_math` aborts in a `Require`. - `python tools/check_conventions.py --base e601dbd7a4` and `git diff --check` pass. - **Overlap and order:** this PR is stacked on #9857, which merges cleanly with the rest of my math series. It replaces host wrappers next to those of #10222, #10229, #10234, #10245 and #10247, so it lands last: #9777 → #9784 → #10222 → #9850 → #10229 → #10234 → #10245 → #10247 → #10250 → #10253 → the `pow` PR, with #10226 after #10222, #9857 before #10250 and #9771 before #10253. A combined preview of all ten heads (`3e088f450d`), including #9857, resolves every conflict by keeping each port and dropping each host wrapper. Each ported function is defined once and each of the eight console tests is called once, and `guest_math` and `guest_dinkumware_internals` pass in three runs out of three on it. - **Not tested:** Linux and macOS (the result no longer depends on the host's functions), a console, the floating-point exception flags, and `sinl`/`cosl`/`tanl` (still the host's, as listed in the debt file). <!-- codex-math-refresh-20261028-repeat-pr10250 --> ### Current Linux qualification (2026-10-28) Rebased onto `main` `2227f1366188cda5699dd20e2e756a18006a5d4b`. Linux CPU validation on 2026-10-28 at `4d98e8148f038bca77cc104a1796608d5e99999a` (Arch Linux 7.2.9, AMD Ryzen 9 7950X, GCC 16.2.1, Ninja Release, BUILD_TESTING=ON). `libc`, `guest_math_tests` and `guest_math_exact_tests` rebuilt from this exact source. `guest_math` and `guest_math_exact` each passed three consecutive runs (6/6, no skips); the same two suites each passed three runs on the pinned main (6/6). Conventions and whitespace checks pass. [Exact source pins, preservation proofs, dependency checks, build logs and JUnit](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/owned-math25-main2227-linux-20261028-repeat.tar.gz), SHA-256 `1176269c9e6948b5252a5db9e660978d7f978fb2d9f4ed6c68bc050b10b5ae68`. This is focused Linux CPU qualification; earlier Windows/title/reference measurements retain their original pins. No new title or performance result is claimed. ### Canonical declaration cleanup (2026-10-28) At `a3b71d51a5cd`, removed 94 duplicate local export declarations from `GuestMath.cpp`; its included `Api.hpp` supplies them. Production code and numeric test bodies are unchanged. Original fails the actual header audit; candidate passes. Per-branch affected-test syntax compilation and conventions/whitespace pass; full standalone-header compilation passed once for the byte-identical header tree shared by the four affected PRs. [Source/proofs/logs](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/math-canonical-declarations-linux-20261028.tar.gz), SHA256 `44f560018e4f6b52e8dda4158383f64fc3059fcdb6444840fe5c04fb2c884f11`. No new numerical-runtime/platform claim; earlier runs retain original pins. Normal fast-forward only, no rebase. AI-assisted: Codex. ### 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 functions are rewritten, as #9668, #5036 and the `sinhf` entry did - [x] Generic behaviour, not specific to one title - [x] Depends on: none (#10247 is merged) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
harisibrar1 commented 2026-10-24 13:29:02 +00:00 (Migrated from github.com)

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

Review: APPROVED


Checked against main 6cd36e6517 and FreeBSD release/11.4.0 lib/msun/src (s_sin.c, s_cos.c, s_tan.c, k_sin.c, k_cos.c, k_tan.c, e_rem_pio2.c, k_rem_pio2.c):

  • RemPio2 and RemPio2Near match e_rem_pio2.c, including the three goto medium cases, the two medium-path refinements and the 3-word large-argument split. KernelRemPio2's nx and prec support matches k_rem_pio2.c (init_jk 3/4, case 1 tail), and the float callers still get the same code as before.
  • The kernels and entry points match the 11.4 source, with identical coefficient literals. The only addition is EDOM for an infinite argument, as described.
  • Ran all 24 CheckTrigConsoleBits arguments through an independent Python port of the 11.4 source; every sin, cos and tan result and errno matches.
  • Small description nit: "Depends on: #9857, #10247" looks out of date. #9857 is merged, and this branch merges cleanly onto main without #10247, so the series-order paragraph could be updated the way #10265's was. With the other open msun PRs it only conflicts at the shared insertion points in GuestMath.cpp, and no function is defined twice. Looks good to me.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638414981 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10250#pullrequestreview-5638414981). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-24T13:29:02Z. **Review:** APPROVED --- Checked against main 6cd36e6517 and FreeBSD release/11.4.0 lib/msun/src (s_sin.c, s_cos.c, s_tan.c, k_sin.c, k_cos.c, k_tan.c, e_rem_pio2.c, k_rem_pio2.c): - `RemPio2` and `RemPio2Near` match e_rem_pio2.c, including the three `goto medium` cases, the two medium-path refinements and the 3-word large-argument split. `KernelRemPio2`'s `nx` and `prec` support matches k_rem_pio2.c (`init_jk` 3/4, case 1 tail), and the float callers still get the same code as before. - The kernels and entry points match the 11.4 source, with identical coefficient literals. The only addition is `EDOM` for an infinite argument, as described. - Ran all 24 `CheckTrigConsoleBits` arguments through an independent Python port of the 11.4 source; every sin, cos and tan result and errno matches. - Small description nit: "Depends on: #9857, #10247" looks out of date. #9857 is merged, and this branch merges cleanly onto main without #10247, so the series-order paragraph could be updated the way #10265's was. With the other open msun PRs it only conflicts at the shared insertion points in GuestMath.cpp, and no function is defined twice. Looks good to me. 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!10250
No description provided.