mirror of
https://github.com/daijro/camoufox.git
synced 2026-11-19 00:07:28 +00:00
UcrtMathPow.c and UcrtMathTrig.c carried their tables as literal values with no account of where they came from. They are the tables of the published algorithms the CRT uses: P. T. P. Tang's table-driven logarithm and exponential (ACM TOMS 1990 and 1989) for pow, and Cody and Waite's and Payne and Hanek's argument reduction with AMD LibM's polynomial kernels for sin, cos and tan. Every table and constant is the same as in AMD's aocl-libm-ose (src/isa/avx/gas/pow.S and remainder_piby2_new.S), and the minimax coefficients are AMD's. browser/scripts/gen-ucrt-math-tables.py now computes them from their definitions (1/F, ln(2F), 2^(j/64), the bits of 2/pi, splits of ln 2 and pi/2) with the standard library, at two precisions, and writes UcrtMathPowTables.h and UcrtMathTrigTables.h. Every value is bit-identical to the old literals. The 2/pi table keeps the 158 bytes that hold 2/pi's bits; the 98 bytes after them were not part of it and are never read. check.py fails if the headers are stale, and still matches ucrtbase.dll on all 33,386 sin, cos and tan and 27,249 pow inputs under GCC and Clang. The file headers now describe the algorithms and cite their sources, carry the MPL-2.0 notice, and name the special cases by AMD's flags. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>