Commit Graph
239 Commits
Author SHA1 Message Date
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
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 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
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
Dean 057de19313 Merge pull request #11556 from xXPBSXx/libm/sinh-msun
fix(libc): compute sinh with FreeBSD msun's algorithm
2026-10-28 13:03:47 +13:00
Dean 9f605c98d2 Merge pull request #10283 from JJenkx/windows/libc-cbrt-msun
fix(libc): compute cbrt with FreeBSD msun's algorithm, as titles' libc.prx does
2026-10-28 13:01:01 +13:00
Dean 46b9aa3768 Merge pull request #9648 from JJenkx/windows/libc-rand-console
fix(libc): follow the console's rand, srand and rand_r
2026-10-28 13:00:35 +13:00
JJenkxandClaude Opus 5.5 a3b829b38f fix(libc): set errno from tgammaf only where titles' libc.prx does
tgammaf goes through the host's double tgamma, and Windows UCRT sets
ERANGE at the poles and on double overflow and EDOM for -inf. The
libc.prx that titles ship sets EDOM for a finite negative integer and
leaves errno unchanged for every other argument, including 0, -0, -inf
and overflow. tgammaf now does the same; results are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 17:42:33 -04:00
JJenkxandClaude Opus 5.5 bece5871e2 fix(libc): keep NaN payloads in strtof and wcstof as titles' libc.prx does
strtof and wcstof returned the default quiet NaN for any NAN(...)
sequence. The libc.prx bundled with eleven titles reads the payload as
its strtod does, but into one 32-bit word: a blank after the first group
of digits ends it, the first 8 digits are kept and cut to 24 bits, the
result goes under the quiet bit with the sign, and a zero payload
becomes 1. HexNanPayload now takes the word count, two for double and
one for float, and the NaN table test checks the measured float bits
and end for all 64 inputs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 07:13:19 -04:00
JJenkx f89e32170c fix(libc): preserve expm1 scaling association under directed rounding 2026-10-27 06:20:52 -04:00
JJenkxandClaude Opus 5.5 8f39bcc549 Merge main into PR #10283
Conflicts with main's newer libc changes resolved without changing either
side: the debt list keeps each side's entry changes (per entry, deletions
included), GuestMath.cpp keeps both sides' test functions and calls, and
Math.cpp differs from main by exactly this branch's own changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 05:06:27 -04:00
Dean fd4a4ca3dc Merge pull request #11277 from AlexFigas/fix/libc-fpclassifyf-dinkumware-codes
fix(libc): return Dinkumware codes from __fpclassifyf
2026-10-27 21:22:30 +13:00
Dean d5f7d86ccc Merge pull request #11139 from JJenkx/fix/libc-modf-floating-environment
fix(libc): preserve modf decomposition and floating-point status
2026-10-27 21:20:33 +13:00
Dean d090e62841 Merge pull request #11074 from JJenkx/fix/libc-frexpf-floating-environment
fix(libc): preserve frexpf decomposition and exception behavior
2026-10-27 21:18:34 +13:00
Dean 2aacb376ee Merge pull request #10346 from JJenkx/windows/libc-logb-msun
fix(libc): compute logb and logbf with FreeBSD msun's algorithm, as titles' libc.prx does
2026-10-27 21:09:12 +13:00
Dean 5a36b2df1e Merge pull request #9850 from JJenkx/windows/libc-powf-msun
fix(libc): compute powf like the libc.prx that titles ship
2026-10-27 21:07:00 +13:00
Dean 853b370f01 Merge pull request #9784 from JJenkx/windows/libc-atan2f-msun
fix(libc): compute atan2f with FreeBSD msun's algorithm, as titles' libc.prx does
2026-10-27 21:06:05 +13:00
Dean 619ac3c2b6 Merge pull request #10467 from MarcZX10/fix/libc-tgammaf-underflow-sign
fix(libc): preserve tgammaf underflow sign
2026-10-27 20:53:02 +13:00
xXPBSXxandClaude Sonnet 5.5 a7685595cd test(libc): check the errno sinh sets on overflow
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-27 08:00:05 +01:00
xXPBSXx fccdc6d687 Merge main (951e5963a4) into libm/sinh-msun 2026-10-27 07:58:16 +01:00
MarcZX10 7054089279 test(libc): name the failing check in guest_math 2026-10-27 06:34:18 +00:00
xXPBSXxandClaude Sonnet 5.5 19a8d9ee9a test(libc): pin asinh bits to FreeBSD msun's results
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-27 07:10:31 +01:00
Dean 1eb876b63a Merge pull request #10907 from imellag/test/libc-math-standard-exception-flags
test(libc): compare the C exception flags in the scaled hyperbolic checks
2026-10-27 18:28:30 +13:00
Dean 1a13c2969f Merge pull request #9833 from MarcZX10/codex/libc-strtod-decimal-subnormal-erange
fix(libc): set ERANGE for decimal strtod subnormals
2026-10-27 18:21:37 +13:00
Dean 304bea47ca Merge pull request #9771 from JJenkx/windows/libc-asinf-msun
fix(libc): compute asinf with FreeBSD msun's algorithm, as titles' libc.prx does
2026-10-27 14:58:25 +13:00
JJenkxandClaude Opus 5.5 1add0a5859 fix(libc): follow the console's rand, srand and rand_r
rand and rand_r both used FreeBSD's do_rand (Park and Miller on
state % 0x7ffffffe + 1, minus one), so rand returned values up to
0x7ffffffd and rand(), rand_r() and every seeded sequence differed
from the console. The libc.prx that titles ship (the same code in the
copies of PPSA13934, PPSA07923 and PPSA05916, read from disassembly)
uses two different generators:

- rand steps a 64-bit state, initially 1, as
  state * 0x5851F42D4C957F2D + 1 and returns (state >> 32) & 0x3FFFFFFF,
  so its results stay at or below 0x3FFFFFFF. srand stores the seed
  zero-extended as that state.
- rand_r is the minimal standard generator, state * 16807 modulo
  2^31 - 1 on the signed 32-bit state (1 gives 16807, 282475249,
  1622650073), and a zero state becomes 0x2AE1B767.

guest_math now expects those results: the rand_r chain from 1, the
zero and 0x7FFFFFFF states, rand after srand(1), srand(0) and
srand(0xFFFFFFFF), and rand's range over 1000 calls. Its previous
checks expected FreeBSD's values and rand matching rand_r.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 20:22:30 -04:00
MarcZX10 bcd99084b4 test(libc): cover signed tgammaf underflow 2026-10-26 22:18:30 +00:00
xXPBSXxandClaude Sonnet 5.5 c78810a2de test(libc): cover the first sinh argument past ln(DBL_MAX)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-26 21:14:53 +01:00
xXPBSXxandClaude Sonnet 5.5 e1979dffde test(libc): cover sinh from 22 up to the overflow threshold
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-26 21:04:47 +01:00
xXPBSXxandClaude Sonnet 5.5 0567c826e7 test(libc): pin sinh bits below 22 to FreeBSD msun's results
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-26 20:01:35 +01:00
Adrià c9a6013f4d Merge pull request #10468 from JJenkx/fix/libc-nextafter-fenv
fix(libc): preserve nextafter exception flags and denormal modes
2026-10-26 19:50:43 +01:00