Commit Graph
112 Commits
Author SHA1 Message Date
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
Nithishvelan M 64fa4c277d fix(libc): compute tgammaf in double to match FreeBSD msun and avoid host float rounding 2026-10-19 23:05:15 +05:30
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
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
Adrià Franch d5eeed0b34 fix(libc): use std::fabs overload for fabsl 2026-10-18 20:02:58 +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
Dean df92748a30 Merge pull request #6318 from hypermoist/fix/libc-lgamma-signgam
fix(libc): store the sign of gamma in an exported signgam from lgamma
2026-10-18 00:32:04 +13:00
Adrià 1cdaed073d Merge pull request #6016 from akkadbakkad89/feat/missing-lib-exports
feat(libc): export the fmin and fmax family
2026-10-17 04:14:54 +02: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
akkadbakkad89 bf4945eabd feat(libc): export the fmin and fmax family
Adds fmin, fminf, fminl, fmax, fmaxf and fmaxl, the remaining
missing members of the C99 minimum/maximum family, with the NaN
propagation and signed-zero handling guest_fminf pins down (host
std::fmin does not guarantee the sign of a zero result). The
previous libSceLibcInternal copy of fminf is removed so the export
stays single-owner. PPSA28319 imports fmaxf from libc.prx; the
other five names were exported by nothing.
2026-10-14 19:25:39 +00: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 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à FranchandClaude 0265f33636 fix(libc): choose the acosf NaN bits instead of the host libm
FreeBSD msun e_acosf.c returns (x-x)/(x-x) for |x| > 1 and NaN inputs: the
x86 default NaN 0xffc00000, or the quieted input NaN. std::acos left it to the
host libm, and guest_math failed on the runner's glibc 2.39.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-13 17:46:18 +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 f745a00a5d fix(libc): accept the full llroundl integer range 2026-10-13 07:46:49 +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
Nixitov f1810c89ea feat(libc): implement nearbyintl
OutRun2006 (PPSA99106) imports nearbyintl and stops at start-up on main. Add the long double round-to-nearest-integer export next to nearbyintf; std::nearbyint rounds under the current direction and raises no inexact exception.
2026-10-12 17:29:41 +02:00