Commit Graph

43 Commits

Author SHA1 Message Date
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
Achraf Reyani 909158503d feat(libc): implement atol and atoll
Both parse like strtol and strtoll in base 10. The guest long is 64
bits wide on every host, so atol uses strtoll rather than the host
atol, whose long is 32 bits on Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 03:25:22 +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à 787239eca5
Merge pull request #1459 from nauroth/claude/strtol-c17-prefix
fix(libc): stop the strtol family at a binary prefix on Linux
2026-10-10 01:31:16 +02:00
Adrià 593001d8fd
Merge pull request #1818 from journaltraces/feat/libc-ldiv
feat(libc): implement ldiv
2026-10-10 00:02:42 +02:00
Claude 2243e17f34
fix(libc): return a 64-bit unsigned long from _Stoul on Windows
The guest's unsigned long is 64 bits. _Stoul was declared with the
host's unsigned long and returned std::strtoul, which are 32 bits on
Windows (LLP64): "4294967296" clamped to 4294967295 with ERANGE and
"-1" gave 0xffffffff, so a guest std::stoul threw out_of_range on values
the console accepts. It now returns std::uint64_t from std::strtoull,
as strtoul_nid_postfix and _Stoull already do; on Linux nothing changes.
The binary-prefix check stays in front of the host call.

Reported in #2424 by AchrafReyani; the same change was proposed in #2442
by SurajKhanna, whose two guest_math cases are taken here. Folded in at
MarcZX100's suggestion on #1459.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-09 21:33:08 +00:00
Claude b5c9945e1f
fix(libc): stop the strtol family at a binary prefix on Linux
C17 has no binary prefix: with base 0 or 2, strtol("0b101", &end, base)
reads the subject "0", returns 0 and leaves end at the 'b'. With glibc
2.38 or later, g++ (which defines _GNU_SOURCE) binds std::strtoll,
strtoull, strtoul, strtoimax and strtoumax to the C23 __isoc23_*
functions, which accept 0b/0B: the Linux exports returned 5 and
consumed the whole string. The Windows UCRT already follows C17, so the
same guest call gave different results on the two hosts.

strtol, strtoul, strtoll, strtoull, _Stoull, strtoimax, strtoumax and
_Stoul now return 0 with the end pointer after the '0' when, after
white space and an optional sign, the text starts with 0b or 0B and a
binary digit, in base 0 or 2. Everything else still goes to the host
function. The scanf family's %i has the same glibc behaviour; it is
recorded in TechnicalDebt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 21:26:13 +00: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
Dean 66db1930c7
Merge pull request #729 from adriadam10/feat/libc-fdtest-finf-fnan
feat(libc): implement _FDtest, _FInf and _FNan
2026-10-06 08:02:17 +13:00
Dean 7c0528a8f3
Merge pull request #718 from adriadam10/feat/libc-div
feat(libc): implement div
2026-10-06 08:00:09 +13:00
Adrià Franch 68b71c971a feat(libc): implement _FDtest, _FInf and _FNan
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 20:10:34 +02:00
Adrià Franch afe2b14a84 feat(libc): implement div
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 19:53:39 +02:00
Adrià Franch ce4bdbf2eb feat(libc): strtoimax and logbf
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 19:22:12 +02:00
Nicolas Abosch aa08977a59 fix(libc): preserve 64-bit long integer conversions 2026-10-04 23:27:17 -03:00
SamG-Coder 7d07187ac8 feat(libc): add floating-point string conversions 2026-09-25 06:55:31 +10:00
SamG-Coder c7d26dda5e feat(libc): add missing guest math exports and 64-bit rounding 2026-09-25 06:54:49 +10:00