Commit Graph

69 Commits

Author SHA1 Message Date
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
milescoviello 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
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 3b83f71e0f
Merge pull request #3905 from aureau/aureau/carry-libc-strtod-no-conversion-zero
fix(libc): return positive zero when float parsing consumes no input
2026-10-13 02:34:59 +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
mir 89b4b2475e
Merge branch 'main' into aureau/carry-libc-strtod-no-conversion-zero 2026-10-12 01:34:06 -04: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
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
Hussein Kadhim d4f1303d47 test(libc): cover the strtod sign cases for every variant and atof 2026-10-11 21:51:31 +05:30
Hussein Kadhim 216ced6c27 fix(libc): return positive zero when strtod, strtof, strtold and wide variants perform no conversion 2026-10-11 21:51:20 +05:30
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
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
Adrià ecafb64f28
Merge pull request #3083 from MarcZX100/codex/carry-3077-wide-conversions
feat(libc): implement Dinkumware wide conversion exports
2026-10-11 00:01:31 +02:00
Adrià bdfcf3d75d
Merge pull request #2932 from AchrafReyani/feat/libc-atol-atoll
feat(libc): implement atol and atoll
2026-10-10 23:53:28 +02:00
David 63cce467e7 fix(libc): stop strtol at a 0x prefix without hex digits on Windows
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-10 23:40:19 +02: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