Commit Graph
114 Commits
Author SHA1 Message Date
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 <noreply@anthropic.com>
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
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 <noreply@anthropic.com>
2026-10-19 09:20:41 +03:00
BIGFERRY999 b28a84d421 feat(libc): implement ceill and floorl 2026-10-19 01:14:40 +02:00
BIGFERRY999 6e3ae1c02e feat(libc): implement fmaf 2026-10-19 00:46:38 +02:00
BIGFERRY999 994fd66bf4 feat(libc): implement remquo and remquof 2026-10-19 00:10:02 +02:00
BIGFERRY999 f7dce6e2d4 feat(libc): implement copysign and copysignf 2026-10-18 22:23:40 +02:00
Adrià f3059421f3 Merge pull request #6166 from freshstart2066-create/feat/libc-fabsf-fabsl
feat(libc): implement fabsf and fabsl
2026-10-18 22:09:51 +02:00
Adrià c73787f443 Merge pull request #6157 from freshstart2066-create/feat/libc-erf-erfc
feat(libc): implement erf, erfc, and erfcf
2026-10-18 20:49:50 +02:00
Adrià 023106ae4b Merge pull request #6159 from freshstart2066-create/feat/libc-ilogb
feat(libc): implement ilogb and ilogbf
2026-10-18 20:23:00 +02:00
BIGFERRY999 831ecb05f7 feat(libc): implement fabsf and fabsl 2026-10-18 20:02:41 +02:00
Adrià FranchandClaude Sonnet 5.5 3b5c41b20f fix(libc): ilogb special cases match PS5 libc.prx (0 -> INT_MIN, inf/NaN -> INT_MAX)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 18:49:34 +02:00
BIGFERRY999 0edfefaf18 feat(libc): implement ilogb and ilogbf 2026-10-18 18:49:25 +02:00
BIGFERRY999 5509b6c701 feat(libc): implement erf, erfc, and erfcf 2026-10-18 18:43:58 +02:00
BIGFERRY999 c33cf11f06 feat(libc): implement fdim and fdimf 2026-10-18 18:42:52 +02:00
T3cm0andClaude Opus 5.5 24a999c499 feat(libc): implement long double, Bessel and integer math exports
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 20:43:13 -05:00
hypermistandClaude Opus 5.5 20edd079e4 fix(libc): store the sign of gamma in an exported signgam from lgamma
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 16:11:02 +13:00
Adrià ec1193dc39 Merge pull request #5775 from wachi35676/fix/libc-lgamma-tiny-arguments
fix(libc): keep lgamma finite for subnormal arguments on Windows
2026-10-15 18:36:22 +02:00
Adrià 08290338aa Merge pull request #5599 from JJenkx/feat/libc-isfinitel
feat(libc): implement x87 long-double finite classification
2026-10-15 17:03:18 +02:00
Karim IbrahimandClaude Opus 5.5 f49c54243f refactor(libc): move fegetenv and its test out of the lines #5495 changes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 14:02:31 +02:00
Karim IbrahimandClaude Opus 5.5 34cf0e223f test(libc): cover fegetenv with a null environment and pending x87 flags
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 14:02:31 +02:00
Karim IbrahimandClaude Opus 5.5 74b93adb6c feat(libc): implement fegetenv
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 14:02:31 +02:00
Muhammad Wasif Ali WasifandClaude Opus 5.5 e671332d2e fix(libc): keep lgamma finite for subnormal arguments on Windows
The MinGW-w64 lgamma overflows to infinity for nonzero |x| at or below 2^-1024. FreeBSD msun e_lgamma_r.c returns -log(|x|) for every nonzero |x| below 2^-56, so take that branch before the host function.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 15:03:50 +05:00
JJenkx 2f9d04fb77 chore: resolve current upstream integration conflicts 2026-10-13 23:13:49 -04:00
Dean 34355eeeac Merge pull request #4942 from QRMOE/fix-libc-llroundl-upper-bound
fix(libc): accept the full llroundl integer range
2026-10-14 14:29:14 +13:00
JJenkx aa16bfc632 Merge commit '30f961266ade83b41d5c9de7dec1393e7fcecfb7' into feat/libc-isfinitel 2026-10-13 18:59:59 -04:00
hamb3r 8652dbe35b feat(libc): add missing Unity IL2CPP runtime imports and Dinkumware helpers
Add missing libc.prx symbols required by Unity IL2CPP runtime:
- Implement _Dtest double classification in Math.cpp
- Implement _Inf double constant in Math.cpp
- Implement sceLibcBacktraceGetBufferSize and sceLibcBacktraceSelf in Backtrace.cpp
- Implement _Cnd_signal in Threads.cpp
- Implement _ZNSt8ios_base7_AddstdEPS_ in RuntimeSupport.cpp
- Implement __pointer_type_info and __function_type_info vtables in TypeInfo.cpp
- Remove duplicate stubs from libSceAmpr/Export.cpp
- Add unit tests in GuestMath.cpp and GuestLibcThreads.cpp
- Document unverified behaviors in docs/dev/debt/libc.md
2026-10-13 19:01:30 +03:00
Adrià 091c136ba6 Merge pull request #5223 from Nixitov/feat/libc-float-math
feat(libc): implement the missing float rounding and classification exports
2026-10-13 17:43:06 +02:00
Adrià 7e4edf509a Merge pull request #4616 from EagleBearerYS/fix/libc-strtod-quiet-nan-windows
fix(libc): return the default quiet NaN from the strtod family
2026-10-13 17:11:55 +02:00
Nixitov 00f0589101 feat(libc): implement the float rounding and classification exports
PPSA99611 imports ceilf, floorf, truncf, isnan and isinf from libc.prx and stops at start-up on main. Implement them next to the existing double forms: the rounding results delegate to the standard library like the other float exports, and isnan/isinf reuse the __isnan/__isinf helpers isnanf already uses.
2026-10-13 17:09:47 +02:00
Akul Tyagi b4e2ee0a13 feat(libc): implement __powidf2
The H+8UBOwfScI import was a throwing stub (libcCyberUnknown08). It is
the NID of "__powidf2", the double-precision integer-power helper that
complements __powisf2.
2026-10-13 19:00:24 +05:30
AlexandClaude Sonnet 5.5 988d304c5c fix(libc): keep the acosf result and leave errno unchanged
The previous commit replaced the out-of-range result with the default
quiet NaN 0x7fc00000, but main and FreeBSD e_acosf.c return 0xffc00000.

acosf now calls the host and restores errno, so only errno differs from
main. The guest test pins the result bits for 2.0f and -2.0f and keeps
the in-range case acosf(0.5f).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-13 11:49:14 +02:00
AlexandClaude Haiku 5.5 64e244eb70 fix(libc): match FreeBSD acosf errno
acosf returned 0xffc00000 (errno 33) for 2.0 (0x40000000), where FreeBSD
lib/msun/src/math.h returns 0xffc00000 (errno 0).

It now returns the FreeBSD result for that case. A guest test covers it
and fails on main.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-13 11:49:14 +02:00
RickandClaude Opus 5.5 3fe04d4b72 feat(libc): implement atanhf
Dusklight (PPSA99305) imports atanhf (cPGyc5FGjy0) from
libSceLibcInternal.prx; the libc.prx it bundles only has a zero-return
stub for it.

The implementation follows the atanhf of the libc.prx bundled with
PPSA28319 (0x438a0), read from its disassembly: FreeBSD msun's
e_atanhf.c calling msun's s_log1pf.c, both as of 59bc2f09 (stable/9,
the revision the sinhf port took expm1f and expf from). The log1pf
paths for the positive arguments atanhf passes are inlined, as the
exported log1pf is still the host's. For |x| > 1, the infinities and
NaN, Sony's error helper raises FE_INVALID and sets errno to EDOM
before returning (x - x) / (x - x); for |x| = 1 it sets errno to
ERANGE before returning x / 0. Other arguments leave errno alone.

Running that code from the title's libc.prx on a Windows host gives
the same bits, errno and floating-point exceptions as the built
libc.prx for all 2^32 arguments, and msun's own e_atanhf.c and
s_log1pf.c built with the host compiler give the same bits. With the
host log1pf instead of the msun one, 4.7% of the arguments in [0, 1)
differ. guest_math pins bits for every branch reachable from atanhf,
both signs, and the errno and exception behaviour.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 10:48:06 +02:00
Adrià 4834930ea6 Merge pull request #4784 from freshstart2066-create/feat/libc-floor
feat(libc): implement floor
2026-10-13 09:59:40 +02:00
QRMOE 2c23ced70e test(libc): cover llroundl boundaries in every rounding mode 2026-10-13 07:47:45 +02:00
AlexandClaude Haiku 5.5 a3b8c054f3 fix(libc): powf(1, y) returns 1 for any y
powf(1.0, nan) returned 0x7fc00001; FreeBSD msun (lib/msun/src/e_powf.c)
returns 0x3f800000. That case now follows FreeBSD; other inputs are
unchanged.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-12 20:32:48 -04:00
JJenkx 64e5a2c119 feat(libc): implement x87 long-double finite classification 2026-10-12 19:52:22 -04:00
BIGFERRY999 f8e2c6497b feat(libc): implement floor 2026-10-12 22:43:46 +01:00
ivica00 5883c25552 feat(libc): implement nearbyint
The float helper is already on main. The double helper rounds with the current mode and does not raise the inexact flag.
2026-10-12 23:11:50 +02:00
Adrià 7940cacd83 Merge pull request #4655 from milescoviello/feat/libc-ceil
feat(libc): implement ceil
2026-10-12 23:10:14 +02:00
Dean d3f275a0e6 Merge pull request #4429 from babyhuey/feat/libc-prosperoai-math
feat(libc): implement expm1f, erff, lgamma and llroundl
2026-10-13 10:01:12 +13:00
Hannah Lyons 057a7317d1 feat(libc): implement expm1f, erff, lgamma and llroundl 2026-10-12 15:19:24 -04:00
milescovielloandClaude Opus 5.5 11bda1c6a8 feat(libc): implement ceil
Kart PS5 (PPSA99611) stops on gacfOmO8hNs (ceil, per tools/nid_names.py)
from libc.prx once __umodti3 resolves (title run on #4519). ceil rounds
toward positive infinity whatever the rounding mode, keeps the sign of
zero and of results that round to zero, and returns infinities and NaNs
unchanged, as std::ceil does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 17:27:00 +00:00
Yunus Shaikh aa4a9b4faf fix(libc): return the default quiet NaN from the strtod family
C17 7.22.1.3 and 7.29.4.1.1 interpret NAN(n-char-sequence) as a quiet
NaN. With MinGW-w64, std::strtod, strtof and strtold are mingw-w64's
gdtoa functions, which copy the hex digits into the significand
without the quiet bit, and for long double without the x87 integer
bit: strtod("nan(0x123)") returned the signaling NaN
0x7ff0000000000123 and strtold a pseudo-NaN. A payload whose only set
bit is the implicit or x87 integer bit gave infinity:
strtof("nan(0x800000)"), strtod("nan(0x10000000000000)") and
strtold("nan(0x8000000000000000)") returned +inf. glibc returns quiet
NaNs that keep the payload.

C17 7.12.11.2p2 makes nan("n-char-sequence") equivalent to
strtod("NAN(n-char-sequence)", NULL), and nan and nanf already return
the console's fixed quiet NaNs, ignoring the tag. ParseFloat, which
strtod, strtof, strtold, atof and the wide variants share, now returns
the same values, 0x7ff8000000000000 and 0x7fc00000, negated after a
minus sign, on Windows and Linux. strtold returns the x87 default
quiet NaN, since no console nanl was observed.
2026-10-12 09:04:31 -07:00