Commit Graph

63 Commits

Author SHA1 Message Date
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
Dean 858f75dbee
Merge pull request #3725 from Recapi/carry/screamm-sinhf-asinl
feat(libc): implement sinhf and asinl (carried from #3519)
2026-10-13 03:07:47 +13:00
Dean 906ce3f20c
Merge pull request #3599 from CouchRiv/fix-libc-exp2-errno
fix(libc): exp2 leaves errno unchanged
2026-10-13 01:24:15 +13:00
screamm 5f3fb3dddd feat(libc): implement asinl
RetroArch 1.0.0-beta.1 (PPSA99169) stops on main 0f863c10 at

    FAIL: unresolved ELF import Nx-F5v0-qU8 from libSceLibcInternal.prx

Nx-F5v0-qU8 is asinl (tools/nid_names.py, aerolib).

The implementation follows the asinl of the libc.prx bundled with
PPSA28319, read from its disassembly: FreeBSD msun's e_asinl.c with
the ld80 invtrig.c coefficients (9f043204), which the binary holds as
the same 80-bit constants, computed in the x87 long double the guest
uses. +-1 returns +-pi/2 rounded to 64 bits and +-0 keeps its sign.
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),
so a NaN argument sets EDOM too.

20 million random arguments in (-1, 1) plus the branch edges give the
same bits as that code from the title's libc.prx run on a Windows
host. guest_math pins a set of those bits and checks the domain
errors' errno and FE_INVALID, and that errno is untouched otherwise.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-12 10:51:59 +02:00
screamm 2c6e3f53ff feat(libc): implement sinhf
Ruffle Flash 1.2.0 (PPSA68091) stops on main 0f863c10 at

    FAIL: unresolved ELF import 1t1-JoZ0sZQ from libSceLibcInternal.prx

1t1-JoZ0sZQ is sinhf (tools/nid_names.py, aerolib). RetroArch
1.0.0-beta.1 (PPSA99169) imports it as well.

The implementation follows the sinhf of the libc.prx bundled with
PPSA28319, read from its disassembly: FreeBSD msun's e_sinhf.c as of
5aa554c7 (before __ldexp_expf, so expf(|x| / 2) is squared between
logf(FLT_MAX) and the overflow threshold), calling msun stable/9
expm1f and expf (59bc2f09), whose paths for the arguments sinhf passes
are inlined. Past the threshold Sony's error helper sets errno to
ERANGE before returning x * 1e37; NaN and the infinities return x + x
and leave errno alone.

Running that code from the title's libc.prx on a Windows host gives
the same bits as this implementation for every finite argument up to
the threshold, both signs (2,238,032,378 inputs). guest_math pins a
set of those bits, the overflow errno and FE_OVERFLOW, and checks that
errno is untouched otherwise.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-12 10:51:00 +02:00
Dean 4e6ef9077a
Merge pull request #3648 from hamb3r/fix/unity-libc-stubs
fix(libc): add missing Unity engine static imports
2026-10-12 20:53:14 +13:00
Dean f9984863e6
Merge pull request #3600 from CouchRiv/fix-libc-fmod-errno
fix(libc): fmod leaves errno unchanged
2026-10-12 18:20:20 +13:00
Dean d146ec1b66
Merge pull request #3640 from MarcZX100/feat/libc-math-predicate-exports-3624
feat(libc): export isnanf and __signbitl
2026-10-12 16:12:58 +13:00
Adrià c059590d8e
Merge pull request #3598 from Recapi/feat/libc-asinl
feat(libc): implement the remaining long double math functions RetroArch imports
2026-10-12 00:22:48 +02:00
Alex c63294027b fix(libc): exp2 leaves errno unchanged
exp2 set errno (34) for 1024.0. FreeBSD msun never sets errno and
reports errors through floating-point exceptions only, so errno is now
saved and restored around the host call.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-11 18:15:15 -04:00
hamb3r b8a1cbe42b fix(libc): add missing Unity engine static imports 2026-10-12 01:04:39 +03:00
Adrià 0694c57998
Merge pull request #3693 from CouchRiv/fix-libc-asinf-errno
fix(libc): match FreeBSD asinf errno
2026-10-12 00:03:54 +02:00
Renan Pires a36b9092d1 feat(libc): implement the long double math functions RetroArch imports 2026-10-11 23:49:38 +02:00
Adrià e2ea125926
Merge pull request #3605 from CouchRiv/fix-libc-asin-nan-sign
fix(libc): asin(|x| > 1) returns the x86 default NaN and leaves errno unchanged
2026-10-11 23:43:44 +02:00
Alex fba96d6422 fix(libc): asin(|x| > 1) returns the x86 default NaN and leaves errno unchanged
On main asin(2.0) returns 0x7ff8000000000000 and sets errno to 33;
FreeBSD msun (lib/msun/src/e_asin.c) returns 0xfff8000000000000 and
never sets errno. asin now handles |x| > 1 itself with quiet
comparisons, so a NaN input still raises no exception. For |x| <= 1
and for NaN the host function is still called.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-11 12:46:30 -04:00
Adrià Franch 86da3e9d74 fix(libc): include cerrno in Math.cpp 2026-10-11 17:34:21 +02:00
Alex 1a6f6a9f13 fix(libc): match FreeBSD asinf errno
asinf 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-11 11:22:51 -04:00
MarcZX100 e7c20b3033 feat(libc): export isnanf and __signbitl 2026-10-11 14:35:01 +00:00
Alex 632338cd65 fix(libc): fmod leaves errno unchanged
fmod set errno (33) for 1.0, 0.0. FreeBSD msun never sets errno and
reports errors through floating-point exceptions only, so errno is now
saved and restored around the host call.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-11 10:07:19 -04:00
ivica00 9b439b30e9 feat(libc): implement __powisf2
PPSA02456's FMOD plugin imports this float integer-power helper, which libc does not export.
2026-10-11 15:25:25 +02:00
Alex fc0994876d fix(libc): hypot returns +inf when one operand is infinite
hypot(inf, NaN) returned a NaN on main. C Annex F returns +inf when
either operand is infinite, even if the other is a NaN, and FreeBSD
msun (lib/msun/src/e_hypot.c) does so for a signalling NaN too. The
infinite case is now checked before std::hypot; other inputs do not
change.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-11 06:17:21 -04:00
Adrià a4d5d3ce53
Merge pull request #545 from Pouare514/feat/ampr-c-runtime
feat(libs): implement C runtime re-exports for libSceAmpr
2026-10-11 12:06:18 +02:00
Pouare514 5290f92876 fix(libs): share Sony CRT semantics between libc and libSceAmpr with tests 2026-10-11 11:42:31 +02:00
Feuris e2b11c2dd8 feat(libc): implement abs 2026-10-11 06:41:00 -03:00
pushkarreddyy 31906bf9b0 feat(libc): implement nan and nanf
Add standard quiet NaN generators nanf (DZU+K1wozGI) and nan (zck+6bVj5pA) to libc.

Resolves startup failure in VLC for PS5 (PPSA85300) where execution halts at nanf on Linux once strsep is available.
2026-10-11 14:12:36 +05:30
Adrià bd06925906
Merge pull request #3314 from AchrafReyani/feat/libc-fabs-trunc-fma
feat(libc): implement fabs, trunc and fma
2026-10-11 09:28:25 +02:00
Adrià 386cf26fc7
Merge pull request #3066 from MarcZX100/codex/libc-lround-range-3045
fix(libc): match FreeBSD lround errors on Windows
2026-10-11 09:21:54 +02:00
Adrià d508b44a20
Merge pull request #3259 from AchrafReyani/feat/libc-log1p-expm1
feat(libc): implement log1p, log1pf and expm1
2026-10-11 09:17:07 +02:00
Achraf Reyani ffeb263654 feat(libc): implement fabs, trunc and fma
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 15:54:23 +09:00
Dean 043aac6a4d
Merge pull request #3191 from AchrafReyani/feat/libc-rand-r
feat(libc): implement rand_r
2026-10-11 19:05:27 +13:00
Dean 7be5ce3de8
Merge pull request #3190 from AchrafReyani/feat/libc-hyperbolic
feat(libc): implement the hyperbolic functions
2026-10-11 19:05:17 +13:00
MarcZX100 fcc3145abf fix(libc): apply range handling to llroundf
The original fix predates llroundf, which was added in #2933. Use the same guest range and exception behavior for the fourth wrapper and include it in the edge-case checks.
2026-10-11 05:11:23 +00:00
Hussein Kadhim 03dde075c9 fix(libc): raise FE_INVALID explicitly and leave errno untouched in lround family
(cherry picked from commit a56de63b8ae0e4bef888ec24ed7f737ab9cab9f7)
2026-10-11 05:11:23 +00:00
Hussein Kadhim 6c87593a16 fix(libc): return LONG_MIN from lround, lroundf and llround out of range
FreeBSD amd64 converts the rounded value with a plain cast, so NaN, infinities and values outside the 64-bit range give 0x8000000000000000 with FE_INVALID raised. The Windows host llround returns 0 for them.

(cherry picked from commit 0ee2741534bdfcc9d818b1d93f2eb793a68f111e)
2026-10-11 05:11:23 +00:00
Achraf Reyani 1f94d93d06 feat(libc): implement log1p, log1pf and expm1
Export them forwarding to the C++ standard library, like log and exp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 12:42:00 +09:00
Adrià Franch 660abec2d3 feat(libc): implement sqrt and sqrtf
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-11 04:44:39 +02:00
Adrià Franch 3cd36b0135 feat(libc): implement acosl and frexpl
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-11 03:58:47 +02:00
Achraf Reyani 86db61ca30 feat(libc): implement rand_r
Share rand's generator step with rand_r, which advances the caller's
state instead of the global one, as FreeBSD's rand and rand_r share
do_rand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 09:48:07 +09:00
Achraf Reyani 1191ed3eaa feat(libc): implement the hyperbolic functions
Export sinh, cosh, coshf, asinh, asinhf, acosh, acoshf and atanh,
forwarding to the C++ standard library like tanh and tanhf.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 09:38:33 +09:00
Dean ea6661cce8
Merge pull request #2934 from AchrafReyani/feat/libc-nextafterf
feat(libc): implement nextafterf
2026-10-11 09:09:09 +13:00
Dean 230ce25b97
Merge pull request #2933 from AchrafReyani/feat/libc-llroundf
feat(libc): implement llroundf
2026-10-11 09:09:00 +13:00
Achraf Reyani fc828e19e7 feat(libc): implement nextafterf
Export it next to remainderf, stepping to the adjacent float in the
direction of the second argument.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 03:25:24 +09:00
Achraf Reyani 3c43198943 feat(libc): implement llroundf
Export it next to lroundf and llround, rounding halfway cases away
from zero into the 64-bit guest long long.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 03:25:23 +09:00
Achraf Reyani e7311656c9 feat(libc): implement __isinf
Export the double version next to __isnan and __isfinite, returning
1 for either infinity like __isinff.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 03:25:21 +09:00
Adrià 593001d8fd
Merge pull request #1818 from journaltraces/feat/libc-ldiv
feat(libc): implement ldiv
2026-10-10 00:02:42 +02:00
Hannah Lyons eb20ba1aaa feat(libc): implement __fpclassifyf 2026-10-09 15:30:00 -04:00
journaltraces 668a1e6f72 feat(libc): implement ldiv
RetroArch (PPSA99169) imports ldiv from libSceLibcInternal, one of the
absent imports #1578 lists for it. The guest long is 64-bit, so the
export takes std::int64_t and returns lldiv_t, which has the guest
ldiv_t layout; std::ldiv would truncate on Windows, where long is 32-bit.
2026-10-09 00:22:57 +03:00
Claude 2a253b376b
fix(libc): raise FE_INVALID from hypotf for a signaling NaN with infinity
hypotf now widens both arguments to double and calls the double hypot.
The float-to-double conversion raises FE_INVALID for a signaling NaN and
quiets it, so hypotf(sNaN, inf) returns +inf with the invalid flag set in
either argument order, matching the PS5 libc routine. Before, MinGW UCRT's
hypotf returned +inf without the flag and glibc's returned NaN.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Scr6DkuJDqiUcJHr9mJv6T
2026-10-08 02:27:31 +00:00
MathiasDevelopes e84f43aceb feat(libc): implement hypot and hypotf
Both forward to std::hypot, which computes without intermediate
overflow and returns infinity when either argument is infinite, even
if the other is NaN. The math test checks those cases.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 19:10:07 +02:00
Nicolas Abosch 7789c0a57b feat(libs): implement homebrew libc and kernel runtime exports 2026-10-05 22:40:16 -03:00