Commit Graph
276 Commits
Author SHA1 Message Date
JJenkx 3bf30fd492 chore(libc): integrate current main math regressions 2026-11-03 08:08:15 -05:00
JJenkxandClaude Opus 5.5 2c8a5d59f8 chore: merge main into the exp topic
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 18:24:28 -05:00
JJenkx 1c4650937d chore(libc): integrate current main math regressions 2026-11-02 12:46:25 -05:00
Dean f133e5e326 Merge pull request #11892 from JJenkx/windows/libc-wcstod-subnormal-erange
fix(libc): set ERANGE for decimal subnormals in wcstod as strtod does
2026-11-03 01:28:05 +13:00
Dean 0f0452e319 Merge pull request #11077 from JJenkx/fix/libc-frexp-floating-environment
fix(libc): preserve frexp decomposition and exception behavior
2026-11-02 23:26:47 +13:00
Dean 5c3e446c0b Merge pull request #10317 from JJenkx/windows/libc-log2-fdlibm
fix(libc): compute log2 with fdlibm's algorithm, as titles' libc.prx does
2026-11-02 23:25:45 +13:00
Dean Galvin d68b404d4a Merge commit '88e804b0a7df1f1ac373a9e2f72fb378d925fdd4' into HEAD
# Conflicts:
#	core/libs/prx/libc/src/Math.cpp
#	core/libs/tests/GuestMath.cpp
#	docs/dev/debt/libc.md
2026-11-02 21:06:56 +13:00
Dean 67a7602c33 Merge pull request #10247 from JJenkx/windows/libc-log10-msun
fix(libc): compute log10 with fdlibm's algorithm, as titles' libc.prx does
2026-11-02 21:00:20 +13:00
Dean 2aee0b06f6 Merge pull request #10229 from JJenkx/windows/libc-atan-atan2-msun
fix(libc): compute atan and atan2 with FreeBSD msun's algorithm, as titles' libc.prx does
2026-11-02 21:00:13 +13:00
Qu Yi 4a65ddf97c chore(libc): synchronize nearbyint fix with main
Preserve the nearbyint implementation and regression coverage while incorporating current main. The write-watch registration prerequisite is now part of main.

Validation: freshly compiled production MathExact.cpp regression passes; ASan/UBSan passes with detect_leaks=0. The same fixture compiles against main Math.cpp and fails at the FE_INEXACT assertion (exit 134). Conventions, whitespace and 235 script registrations pass. Full product build and full CTest were not rerun for this synchronization.
2026-11-01 14:56:40 +08:00
Dean 88b7503129 Merge pull request #10222 from JJenkx/windows/libc-expm1f-msun
fix(libc): compute expm1f with FreeBSD msun's algorithm, as titles' libc.prx does
2026-11-01 14:57:48 +13:00
JJenkxandClaude Opus 5.5 af2d1f35e3 fix(libc): compute exp with FreeBSD msun's algorithm, as titles' libc.prx does
exp returned the host's exp, whose last bit differs from the titles' copy on
Windows on 9,892,285 of 320 million random arguments. The titles' copy is
FreeBSD msun's e_exp.c, except that exp(1) returns the correctly rounded e,
and it sets ERANGE only in msun's overflow and underflow branches. exp now
computes that and sets ERANGE there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 10:24:02 -04:00
Qu Yi 4c41442276 fix(libc): match nearbyint inexact flags to guest libc 2026-10-31 15:51:17 +08:00
Oscar45397andClaude Opus 5.5 66f151fd7d test(libc): cover remainderf
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 18:35:56 +01:00
JJenkx 250f5b51de fix(libc): integrate expm1f on refreshed tanhf parent 2026-10-30 07:33:46 -04:00
JJenkx a06ed844e3 fix(libc): integrate current main into tanhf port 2026-10-30 07:32:57 -04:00
JJenkx edceab45c7 fix(libc): integrate current main and log10 parent into log2 2026-10-29 23:22:00 -04:00
JJenkx 8bb1886d3a fix(libc): integrate current main into PR 10229 2026-10-29 23:21:11 -04:00
JJenkx 476bb9f96c fix(libc): integrate current main into PR 10247 2026-10-29 23:20:34 -04:00
Adrià 18bf374028 Merge pull request #12178 from Henryisdjfunkyho/fix/libc-nearbyintf-current
fix(libc): raise inexact for nearbyintf
2026-10-30 02:00:49 +01:00
Adrià f0c8f26eec Merge pull request #12676 from JJenkx/windows/libc-ldexpf-errno
fix(libc): leave errno unchanged from ldexpf, as titles' libc.prx does
2026-10-30 00:18:56 +01:00
Adrià 2e55a9d0f6 Merge pull request #12681 from JJenkx/windows/libc-scalbn-errno
fix(libc): leave errno unchanged from scalbn and scalbnf on every host
2026-10-30 00:02:33 +01:00
Adnan Khan c118a61fdd fix(libc): keep clang's SLP vectorizer from raising spurious FP exceptions in libc 2026-10-29 21:00:41 +05:30
JJenkxandClaude Opus 5.5 f6ca8993e8 fix(libc): set ERANGE for decimal subnormals in wcstod as strtod does
wcstod parsed through the host strtod directly, so a decimal input with
a nonzero subnormal result left errno alone, where strtod sets ERANGE.
The wcstod of the libc.prx bundled with eleven titles sets it in the
same cases as their strtod: 1e-310, the smallest subnormal and 1e-330
set it, 2.2250738585072014e-308 and 0x1p-1074 do not, and 0x1.8p-1075
does. wcstod now parses through strtod.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 08:49:40 -04:00
Dean 8efa579b15 Merge pull request #12361 from JJenkx/windows/libc-powf-underflow-flag
fix(libc): raise FE_UNDERFLOW from powf when the result underflows
2026-10-29 23:49:09 +13:00
Dean 8a1e06ec98 Merge pull request #11203 from MarcZX10/marc/test-name-failing-math-checks
test(libc): name the failing check in the math tests
2026-10-29 18:48:33 +13:00
Henryisdjfunkyho 472500cb80 fix(libc): honor rounding modes in nearbyintf 2026-10-28 22:06:25 -07:00
Henryisdjfunkyho 3182d23266 fix(libc): raise inexact for nearbyintf 2026-10-28 22:06:24 -07:00
Dean 444407ddd6 Merge pull request #11278 from AlexFigas/fix/libc-signbit-sign-mask
fix(libc): return the sign mask from __signbit, __signbitf and __signbitl
2026-10-29 16:25:03 +13:00
JJenkxandClaude Opus 5.5 a561f4e591 fix(libc): leave errno unchanged from scalbn and scalbnf on every host
The titles' scalbn and scalbnf never set errno, at any exponent. On
Windows the host scalbn already matches, but glibc's scalbn and scalbnf
set ERANGE on overflow and on underflow to zero (found by rooklz while
reviewing #12676), so on Linux they did. Both now keep errno across the
host call, as scalbln and scalblnf already do. CheckScalbnErrno checks
results read from the titles' libc.prx.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 21:47:44 -04:00
JJenkxandClaude Opus 5.5 03f5cfafe1 fix(libc): leave errno unchanged from ldexpf, as titles' libc.prx does
ldexpf called the host ldexp on a float, which computes in double and
sets ERANGE only when the double result leaves the double range, so
ldexpf(0x1.3d1c6p-95f, 1262) set ERANGE while ldexpf(1.0f, 200) did
not. The titles' ldexpf never sets errno, as their scalbnf does not.
ldexpf now computes like scalbnf: on 100,000 random arguments it
matches the libc.prx of PPSA07923 and PPSA05916 in every value and
errno, against 63,957 errno differences before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 21:27:48 -04:00
Dean e46ace76a4 Merge pull request #12118 from JJenkx/windows/libc-tgammaf-errno
fix(libc): set errno from tgammaf only where titles' libc.prx does
2026-10-29 12:09:01 +13:00
JJenkxandClaude Opus 5.5 b5dc3b4296 fix(libc): raise FE_OVERFLOW from pow for bases from 2^971 up as titles do
The pow of the libc.prx that titles ship (PPSA07923) multiplies |x| by
2^53 for its subnormal normalization on every general-path call and
keeps the product only for subnormal x. For |x| from 2^971 up the
unused product overflows, so pow raises FE_OVERFLOW there for any
exponent that reaches the general path, even when the result is
finite (pow(1e300, -0.25)). The product is now computed the same way;
it is exact below 2^971, so only that flag changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 16:37:52 -04:00
Adrià 7fea87746b Merge pull request #11737 from xXPBSXx/libm/asinh-msun
fix(libc): compute asinh with FreeBSD msun's algorithm
2026-10-28 17:58:59 +01:00
JJenkx 2f72ecea04 test(libc): use canonical math export declarations 2026-10-28 12:12:16 -04:00
JJenkx 7d51a8b331 test(libc): use canonical math export declarations 2026-10-28 12:12:14 -04:00
JJenkx 6a21bbac54 test(libc): pin huge-exponent powf flags and errno 2026-10-28 10:37:46 -04:00
JJenkxandClaude Opus 5.5 b5e3c56252 test(libc): check more powf subnormal results against titles' libc.prx
2^-149 and -2^-141 are exact subnormal powf results that raise no flag,
and 3^-90 is an inexact one that raises FE_UNDERFLOW and FE_INEXACT;
none sets errno, as in the libc.prx of PPSA07923 and PPSA13934.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 08:40:08 -04:00
JJenkx dc4f3a075f test(libc): keep exact powf subnormals free of underflow 2026-10-28 08:24:48 -04:00
JJenkx 56b82ac96e fix(libc): compute tanhf with FreeBSD msun's algorithm, as titles' libc.prx does 2026-10-28 08:23:44 -04:00
JJenkx cf5648a723 fix(libc): compute expm1f with FreeBSD msun's algorithm, as titles' libc.prx does 2026-10-28 08:23:41 -04:00
JJenkx 6aaad6df3e fix(libc): compute tanhf with FreeBSD msun's algorithm, as titles' libc.prx does 2026-10-28 08:23:40 -04:00
JJenkx 2b011faec6 fix(libc): compute atan and atan2 with FreeBSD msun's algorithm, as titles' libc.prx does 2026-10-28 08:23:29 -04:00
JJenkx a411706c97 fix(libc): compute expm1f with FreeBSD msun's algorithm, as titles' libc.prx does 2026-10-28 08:23:28 -04:00
JJenkx f899951415 fix(libc): compute tanhf with FreeBSD msun's algorithm, as titles' libc.prx does 2026-10-28 08:23:27 -04:00
JJenkxandClaude Opus 5.5 6bceecd018 fix(libc): raise the titles' flags from log10 at its special inputs
Titles' libc.prx raises FE_INVALID wherever log10 stores EDOM, a NaN
argument included, where (x - x) / zero raised nothing for a NaN
operand. The domain path now raises through _Feraise, which stores EDOM
and raises the flag in both units. For +-0 it now returns -inf without raising FE_DIVBYZERO, as the titles do; the port divided -two54 by zero.
Results and errno are unchanged. CheckLog10EdgeFlags covers it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 08:23:02 -04:00
JJenkxandClaude Opus 5.5 0bb14d3794 fix(libc): compute log10 with fdlibm's algorithm, as titles' libc.prx does
log10 returned the host's log10, whose last bit differs from the titles'
copy on Windows on 3,066,397 of 320 million random arguments. The titles'
copy is the fdlibm e_log10.c over its k_log.h, which FreeBSD 11.4 later
replaced, and it sets EDOM for every nonzero argument with the sign bit set
but leaves errno alone for +-0. log10 now computes that and sets EDOM there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 08:23:01 -04:00
JJenkxandClaude Opus 5.5 9a47f3f910 fix(libc): raise pow's overflow and underflow flags where titles do
Titles' libc.prx raises FE_UNDERFLOW and FE_INEXACT when pow underflows
for 2^31 < |y| <= 2^64 and at the final range check, and raises nothing
for |y| > 2^64, where its huge * huge and tiny * tiny were folded into
constants. Here GCC folded every tiny * tiny product, so no underflow
flag was raised, while huge * huge for |y| > 2^64 raised FE_OVERFLOW.

Return +inf directly for |y| > 2^64 and compute the other underflowing
products through a volatile, so the flags match on every path. Results
and errno are unchanged. CheckPowRangeFlags covers each path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 08:22:01 -04:00
JJenkxandClaude Opus 5.5 ed18156072 fix(libc): compute pow with fdlibm's algorithm, as titles' libc.prx does
pow returned the host's pow, whose last bit differs from the titles' copy on
Windows on 17,275,531 of 320 million random pairs, and which follows C99
for pow(1, NaN) and pow(-1, +-inf) where the titles' copy returns NaN. The
titles' copy is FreeBSD msun's e_pow.c with those two original fdlibm
rules. It sets EDOM where a negative base meets a non-integer exponent and
ERANGE only in the final overflow and underflow checks. pow now computes
that and sets errno there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 08:21:44 -04:00
JJenkxandClaude Opus 5.5 2cf7d26d3c fix(libc): raise the titles' flags from log2 and log10 at their special inputs
Titles' libc.prx raises FE_INVALID wherever log2 and log10 stores EDOM, a NaN
argument included, where (x - x) / zero raised nothing for a NaN
operand. The domain path now raises through _Feraise, which stores EDOM
and raises the flag in both units. For +-0 it now returns -inf without raising FE_DIVBYZERO, as the titles do; the port divided -two54 by zero.
Results and errno are unchanged. CheckLog2EdgeFlags and CheckLog10EdgeFlags cover it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 08:21:39 -04:00