Commit Graph
267 Commits
Author SHA1 Message Date
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 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
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
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 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 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
JJenkxandClaude Opus 5.5 fab2ee750e fix(libc): compute log2 with fdlibm's algorithm, as titles' libc.prx does
log2 returned the host's log2, whose last bit differs from the titles' copy
on Windows. The titles' copy is the fdlibm e_log2.c over the same k_log.h
kernel as log10, 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. log2 now computes that over the kernel, renamed KernelLog because both
functions use it, and sets EDOM there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 08:21:39 -04:00
JJenkxandClaude Opus 5.5 563e305965 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:21:39 -04:00
Alexandre Figueiredo def9214119 fix(libc): return the sign mask from __signbit, __signbitf and __signbitl 2026-10-28 11:37:31 +00:00
JJenkxandClaude Opus 5.5 e4fb8ed169 fix(libc): raise FE_UNDERFLOW from powf when the result underflows
powf returns sn * tiny * tiny for an underflowing result, as FreeBSD
msun's e_powf.c does, so that the multiplication raises the underflow
and inexact flags. Math.cpp is built without -frounding-math and tiny
was a local constant, so GCC folded the product to zero at compile time
and no flag was raised; titles' libc.prx raises FE_UNDERFLOW with ERANGE.
Read tiny through a volatile, so the product is computed at run time.
The results and errno are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 06:47:33 -04:00
JJenkxandClaude Opus 5.5 297e1000cd fix(libc): return the default NaN from tgammaf domain errors
For a negative integer and -inf, titles' libc.prx returns the x86
default NaN (0xffc00000) from tgammaf, where the host tgamma returns
0x7fc00000. Return the titles' NaN when the result is NaN and the
argument is not; errno and the raised flags are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 05:38:20 -04:00
JJenkxandClaude Opus 5.5 8b5c02ca61 fix(libc): store EDOM and raise FE_INVALID from acosf and asinf domain errors
For |x| > 1, the infinities and NaN, titles' libc.prx stores EDOM and
raises FE_INVALID from acosf, quiet NaN included, and asinf also
raises FE_INVALID for a quiet NaN. acosf returned the same NaN bits
without either, and asinf set errno but raised nothing for a quiet NaN.
Both now call _Feraise with the invalid exception, which stores EDOM
and raises the flag in both units; the results are unchanged.

The acosf test asserted the old errno-preserving behaviour from a
FreeBSD reading; it now checks the titles' EDOM and FE_INVALID.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 05:17:22 -04:00
Dean da6b0ea8dd Merge pull request #11884 from JJenkx/windows/libc-strtof-nan-payload
fix(libc): keep NaN payloads in strtof and wcstof as titles' libc.prx does
2026-10-28 20:11:27 +13:00
Dean 24795c0f56 Merge pull request #10529 from JJenkx/fix/libc-expm1-scaling-association
fix(libc): preserve expm1 rounding during exponent scaling
2026-10-28 17:49:49 +13:00
xXPBSXxandClaude Sonnet 5.5 893250cf72 Merge main (951399570d) into libm/asinh-msun
The only conflict was in GuestMath.cpp, where main's sinh tests and this
branch's asinh tests were inserted at the same place. Keep both: the asinh
checks follow the sinh ones.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-28 01:31:59 +01:00