Commit Graph
156 Commits
Author SHA1 Message Date
JJenkx 2fc4ca2fd0 test(libc): reject host log fallback in large acoshf inputs 2026-10-25 07:53:43 -04:00
JJenkx 0e895b55be test(libc): cover acoshf positive results across rounding modes 2026-10-25 07:53:11 -04:00
JJenkxandClaude Opus 5.5 185098a39d fix(libc): compute log1p with FreeBSD msun's algorithm, as titles' libc.prx does
log1p returned the host's log1p, whose last bit differs from the titles'
copy on Windows on 24,477,433 of 320 million random arguments. The titles'
copy is FreeBSD msun's s_log1p.c, and it sets EDOM at msun's NaN return,
for arguments below -1, -inf and negative NaNs, but not for log1p(-1).
log1p now computes that algorithm and sets EDOM there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 02:56:59 -04:00
Dean Galvin 83b63bfbb5 Merge main into windows/libc-exp2f-msun 2026-10-25 12:09:10 +13:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
Dean 9018bc438a Merge pull request #10003 from MarcZX10/codex/libc-acoshf-msun
fix(libc): follow msun for acoshf
2026-10-25 00:24:44 +13:00
Dean e9a551d6f4 Merge pull request #9857 from JJenkx/windows/libc-trigf-msun
fix(libc): compute sinf, cosf, tanf and sincosf with FreeBSD msun's algorithms, as titles' libc.prx does
2026-10-24 22:12:11 +13:00
JJenkxandClaude Opus 5.5 7488308bb9 Merge main into PR #9844
Additive conflicts with main's newer libc math changes: the debt list keeps
both sides' entries (per entry), the GuestMath.cpp test functions and calls
from both sides are kept, and Math.cpp keeps both sides' independent changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 03:19:24 -04:00
Dean Galvin c3a9a613c7 Merge main into codex/libc-acoshf-msun 2026-10-24 20:00:35 +13:00
JJenkxandClaude Opus 5.5 99abd2604d fix(libc): compute expm1 with FreeBSD msun's algorithm, as titles' libc.prx does
expm1 returned the host's expm1, whose last bit differs from the titles'
copy on Windows on 35,152,346 of 320 million random arguments. The titles'
copy is FreeBSD msun's s_expm1.c, and it sets ERANGE only when a finite
argument overflows to infinity. expm1 now computes that algorithm and sets
ERANGE there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 00:43:08 -04:00
Dean d7f0c005a9 Merge pull request #9862 from JJenkx/windows/libc-cbrtf-msun
fix(libc): compute cbrtf with FreeBSD msun's algorithm, as titles' libc.prx does
2026-10-24 15:23:06 +13:00
Dean 72641c92f6 Merge pull request #9841 from JJenkx/windows/libc-logf-msun
fix(libc): compute logf with FreeBSD msun's algorithm, as titles' libc.prx does
2026-10-24 14:19:40 +13:00
JJenkxandClaude Opus 5.5 8b83c68aad fix(libc): compute exp2f with FreeBSD msun's algorithm, as titles' libc.prx does
exp2f returned the host exp2, so its last bit and errno depended on the
host: on Windows the bits differ from the libc.prx that titles ship on
213,306,266 of the 2^32 floats. That libc.prx is msun's s_exp2f.c, setting
ERANGE only in its overflow and underflow branches. The port gives the same
bits and errno as PPSA07923's, PPSA05916's and PPSA13934's copies for every
argument.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 20:16:32 -04:00
Dean d284c98b2e Merge pull request #10001 from MarcZX10/codex/libc-coshf-msun
fix(libc): follow msun for coshf
2026-10-24 12:52:24 +13:00
Dean 097a9514a0 Merge pull request #8865 from hypermoist/fix/libc-strtof-sign-hex-range
fix(libc): keep the sign of a failed strtof and match libc.prx strtof ERANGE
2026-10-24 11:56:01 +13:00
Dean 2e5a125982 Merge pull request #9777 from JJenkx/windows/libc-atanf-msun
fix(libc): compute atanf with FreeBSD msun's algorithm, as titles' libc.prx does
2026-10-24 07:27:14 +13:00
MarcZX10 116aff1d80 test(libc): cover acoshf range boundaries 2026-10-23 03:45:26 +00:00
MarcZX10 af343b1601 test(libc): cover coshf range boundaries 2026-10-23 03:35:47 +00:00
hypermistandClaude Opus 5.5 d2927e0ec1 fix(libc): follow libc.prx for strtof signs and hexadecimal round-up ERANGE
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SNqSvnFwRBz3D76n476yw6
2026-10-23 14:19:46 +13:00
hypermist bda7105405 Merge remote-tracking branch 'upstream/main' into fix/libc-strtof-sign-hex-range 2026-10-23 14:15:39 +13:00
JJenkxandClaude Opus 5.5 ac92cc6281 fix(libc): compute cbrtf with FreeBSD msun's algorithm, as titles' libc.prx does
cbrtf returned the host cbrt, so its result depended on the host: on
Windows it differs from the libc.prx that titles ship on 1,303,357,444 of
the 2^32 floats. That libc.prx is msun's s_cbrtf.c, which gives the same
bits as PPSA07923's, PPSA05916's and PPSA13934's copies for every argument.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 16:22:49 -04:00
JJenkxandClaude Opus 5.5 e601dbd7a4 fix(libc): compute sinf, cosf, tanf and sincosf with FreeBSD msun's algorithms, as titles' libc.prx does
They returned the host sin, cos and tan, so their last bit and errno
depended on the host: on Windows sinf differs from the libc.prx that titles
ship on 3,349,410 of the 2^32 floats, cosf on 3,382,210 and tanf on
303,874,018. That libc.prx is msun's s_sinf.c, s_cosf.c and s_tanf.c over
the double-precision kernels and e_rem_pio2f.c with k_rem_pio2.c; its
sincosf returns the same pair, and only an infinite argument sets EDOM.
The ports give the same bits and errno as PPSA07923's, PPSA05916's and
PPSA13934's copies for every argument.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 16:22:31 -04:00
JJenkxandClaude Opus 5.5 a22e959cd8 fix(libc): compute logf with FreeBSD msun's algorithm, as titles' libc.prx does
logf returned the host log, so its last bit and errno depended on the host:
on Windows the bits differ from the libc.prx that titles ship on 13,225,175
of the 2^32 floats. That libc.prx is msun's e_logf.c, setting ERANGE for
+-0 and EDOM for every argument with the sign bit set. The port gives the
same bits and errno as PPSA07923's and PPSA05916's copies for every
argument; the FMA-contracted copy of PPSA13934 differs by 1 ulp on 961,881.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 16:21:35 -04:00
JJenkxandClaude Opus 5.5 5e03230c28 fix(libc): compute atanf with FreeBSD msun's algorithm, as titles' libc.prx does
atanf returned the host atan, so its last bit depended on the host: on
Windows it differs from the libc.prx that titles ship on 6,481,820 of the
2^32 floats. That libc.prx is msun's s_atanf.c, which gives the same bits
as PPSA07923's, PPSA05916's and PPSA13934's copies for every argument.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 16:20:38 -04:00
Braxton Atkinson ee057ea155 fix(libc): preserve errno across fmodf domain errors 2026-10-22 14:59:20 -05:00
hypermistandClaude Opus 5.5 d811e7abf0 fix(libc): set strtof ERANGE as the titles' libc.prx does
strtof and wcstof now set ERANGE for a decimal input whose nonzero
subnormal result is inexact, never for a hexadecimal nonzero subnormal,
and keep it for underflow to zero and overflow. This is what the libc.prx
bundled with PPSA08427 (J03547016) and PPSA03671 (J03848509) do when run
side by side with this libc. The earlier commit followed
libSceLibcInternal's _Stof, which leaves errno alone for hexadecimal under-
and overflow, but titles import these NIDs from their own libc.prx.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
2026-10-23 02:15:34 +13:00
hypermist 0139f95bd8 Merge remote-tracking branch 'upstream/main' into fix/libc-strtof-sign-hex-range 2026-10-23 02:04:52 +13:00
MarcZX10 72316ad618 fix(libc): scale large finite cosh inputs 2026-10-21 22:59:10 +00:00
MarcZX10 c9b80f0304 feat(libc): implement _Cosh 2026-10-21 22:58:44 +00:00
hypermistandClaude Opus 5.5 34a729529a fix(libc): keep the sign of a failed strtof and drop hex ERANGE like the console
- strtof, strtold, wcstof and wcstold return -0.0 when nothing converts
  after a minus sign, unless the next character starts an inf or nan
  spelling; strtod, wcstod and atof keep +0.0.
- strtof, strtold, wcstof and wcstold leave errno alone for hexadecimal
  text that overflows or underflows.
- strtod and wcstod set ERANGE for hexadecimal text whose value lies
  below the smallest subnormal and rounds up to it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
2026-10-21 16:40:09 +13:00
hypermistandClaude Opus 5.5 8e46144d48 fix(libc): follow the console for integer bases and 0x prefixes
- strtol, strtoul, strtoll, strtoull and strtouq return 0 for a base
  outside 0 and 2 to 36, leave the end at the start and set EINVAL;
  strtoimax, strtoumax, _Stoull, _Stoul and the wide forms do the same
  without errno.
- A 0x prefix with no hexadecimal digit after it (base 0 or 16) is no
  conversion: the end stays at the start of the string.
- wcstol, wcstoll and wcstoimax take one sign, convert the rest with
  wcstoull and clamp to the signed range with ERANGE, so "- 1" is -1
  and "+\t-1" overflows.
- atoi, atol and atoll truncate strtoull's result.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
2026-10-21 16:05:00 +13:00
Dean 1ffe979127 Merge pull request #8576 from priyanshrv-netizen/feat/libc-float-characteristics
feat(libc): export the Dinkumware float characteristic tables
2026-10-21 14:06:48 +13:00
Dean 21a57ff5c0 Merge pull request #8570 from priyanshrv-netizen/feat/libc-dinkumware-constants
feat(libc): export the remaining Dinkumware floating-point constants
2026-10-21 13:29:16 +13:00
Dean 5b59fbc553 Merge pull request #8389 from SwetabhSingh17/feat/libc-math-significand
feat(libc): implement significand
2026-10-21 12:40:42 +13:00
Dean 1bf237cc33 Merge pull request #8379 from hypermoist/fix/libc-strtod-subnormal-errno
fix(libc): leave errno alone for subnormal strtod results
2026-10-21 12:14:17 +13:00
Dean 542c65d74c Merge pull request #8023 from Ondra97/codex/fix-scaled-hyperbolic
fix(libc): avoid premature scaled hyperbolic overflow
2026-10-21 06:26:06 +13:00
priyanshrv-netizenandClaude Opus 5.5 97d587f730 feat(libc): export the Dinkumware float characteristic tables
Add _Flt, _Dbl and _Ldbl, the 80-byte tables behind Dinkumware's
float.h macros, with the values the console's libc.prx exports.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-20 22:28:18 +05:30
priyanshrv-netizenandClaude Opus 5.5 91c401db5e feat(libc): export the remaining Dinkumware floating-point constants
Add _Denorm, _Hugeval, _Nan, _Snan, _FDenorm, _FSnan, _LDenorm, _LInf,
_LNan and _LSnan with the 16 bytes the console's libc.prx exports.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-20 22:15:51 +05:30
Adrià d073fe6a1d Merge pull request #7524 from jotitadev/fix/macos-guest-math-bessel-reference
fix(tests): compare the Bessel exports with fixed reference values
2026-10-20 17:16:08 +02:00
Swetabh Singh dbd849d3c1 feat(libc): implement significand 2026-10-20 17:25:00 +05:30
hypermistandClaude Opus 5.5 b455c751bb fix(libc): leave errno alone for subnormal strtod results
The console's strtof, strtod and strtold set ERANGE only when a
conversion underflows to zero; a non-zero subnormal result leaves errno
unchanged, while the host's sets it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
2026-10-21 00:48:05 +13:00
Adrià 6bd02dd915 Merge pull request #7545 from ionut27001/fix/libc-strtod-nan-payload
fix(libc): parse NaN payloads in strtod as measured on a PS5
2026-10-20 12:25:58 +02:00
Dean a569f47cb7 Merge pull request #7876 from ErenYeager1836/feat/libc-export-tgammaf
feat(libc): export tgammaf float math function
2026-10-20 13:52:11 +13:00
Jota f8545e961e fix(tests): compare the Bessel exports with fixed reference values
libc++ does not provide std::cyl_bessel_j or std::cyl_neumann, so
GuestMath.cpp stopped compiling on macOS after the Bessel exports were
added. The three checks now compare against the values of J0(2.5),
J3(4.0) and Y2(3.0), which glibc and macOS libm agree on to 1e-16.
2026-10-19 15:24:58 -03:00
Ondra97 ce81a77d1a fix(libc): avoid premature scaled hyperbolic overflow 2026-10-19 19:47:19 +02:00
Dean a39411c67a Merge pull request #7906 from Rajkamalcode/fix/libc-bessel-zero
fix(libc): return -inf from y0f, y1f and ynf at zero
2026-10-20 05:52:35 +13:00
Rajkamalcode cea6fabfae fix(libc): return -inf from y0f, y1f and ynf at zero
The guest's second-kind Bessel functions return -inf and raise the divide-by-zero exception for x = +-0 (see e_jn.c), but the UCRT returns NaN for y1 and yn. Route x == +-0 through a shared helper, cover ynf(2, 0) in the guest math test, and note the special case in the libc technical debt.
2026-10-19 18:31:00 +05:30
Nithishvelan M 0f34160a49 feat(libc): export tgammaf float math function
PPSA26578 (issue #7624) imports tgammaf (NID B2ZbqV9geCM) from libc,
and its bundled libc.prx does not export it, causing the process to
exit with 0xC0000139 (GetLastError: 127).

Export tgammaf_nid_postfix in core/libs/prx/libc/src/Math.cpp delegating
to std::tgamma(float), and add unit test coverage in GuestMath
verifying factorials, half-integers, poles, and negative values.
2026-10-19 17:27:50 +05:30
Nithishvelan M 6487d5e2c5 feat(libc): export nextafter double math function
PPSA26578 (issue #7624) imports nextafter (NID h+J60RRlfnk) from libc,
and its bundled libc.prx does not export it, causing the process to
exit with 0xC0000139 (GetLastError: 127).

Export nextafter_nid_postfix in core/libs/prx/libc/src/Math.cpp delegating
to std::nextafter(double, double), and add unit test coverage in
GuestMath verifying denormals, infinities, NaNs, and negative zero.
2026-10-19 17:25:31 +05:30
ionut27001andClaude Opus 5.5 ae662c873d fix(libc): parse NaN payloads in strtod as measured on a PS5
In a payload process on a PS5 (firmware 12.70), the strtod and wcstod
of libSceLibcInternal.sprx keep the payload of a NAN(...) sequence,
read as FreeBSD 11's gdtoa hexnan reads it, under the quiet bit and
with the sign. strtof, wcstof, strtold and wcstold return the positive
default quiet NaN whatever the sign and the sequence, and consume a
sequence of letters, digits and underscores up to its closing
parenthesis. Here every NaN lost its payload, and strtof and strtold
kept the sign.

The model reproduces the 64 NaN inputs that p11, p14, p27 and p33
measured, including blanks and other characters inside the parentheses
and unterminated sequences, and the test now pins them. It also pins
two p71 cases measured through strtod: nan(1 2), and "nan( " followed
by NUL and ")". In hexnan, a blank after a payload digit, while a
32-bit word of the payload is still free, starts a blank skip that has
no NUL check, so when only blanks follow up to the terminating NUL the
console reads past it (p71); that case throws here. A blank right after
"nan(" is skipped with a NUL check, and the console stopped at the NUL
there.

AI-assisted: yes

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-19 09:20:41 +03:00