Commit Graph
618 Commits
Author SHA1 Message Date
Adrià 439d03db38 Merge pull request #11663 from Danigamer05/feat/libc-stdc-count-ones
feat(libc): add C23 count-ones exports
2026-10-28 04:19:47 +01:00
Adrià f1f1737371 Merge pull request #11647 from B-Howell/codex/libc-strtoq
feat(libc): implement strtoq
2026-10-28 04:06:20 +01:00
Dean 4c6fcfcb5c Merge pull request #9763 from rooklz/fix/libc-freopen-closed-stream
fix(libc): reopen a closed stream in freopen instead of aborting
2026-10-28 13:48:50 +13:00
Dean 057de19313 Merge pull request #11556 from xXPBSXx/libm/sinh-msun
fix(libc): compute sinh with FreeBSD msun's algorithm
2026-10-28 13:03:47 +13:00
Dean 9f605c98d2 Merge pull request #10283 from JJenkx/windows/libc-cbrt-msun
fix(libc): compute cbrt with FreeBSD msun's algorithm, as titles' libc.prx does
2026-10-28 13:01:01 +13:00
Dean 46b9aa3768 Merge pull request #9648 from JJenkx/windows/libc-rand-console
fix(libc): follow the console's rand, srand and rand_r
2026-10-28 13:00:35 +13:00
Dean 6e9b9134f6 Merge pull request #11846 from heditrigui/feat/libc-reallocarray
feat(libc): implement reallocarray
2026-10-28 12:10:58 +13:00
Adrià e274546099 Merge pull request #11302 from Danigamer05/feat/libc-signed-max64
feat(libc): implement signed 64-bit maximum
2026-10-27 22:26:29 +01:00
Adrià 6d99bf4ccb Merge pull request #11300 from Danigamer05/feat/libc-signed-min64
feat(libc): implement signed 64-bit minimum
2026-10-27 22:16:40 +01:00
Adrià 4a6005955f Merge pull request #10898 from imellag/feat/libkernel-memory-protection-macos
feat(libkernel): guest memory protection and VirtualQuery on macOS hosts
2026-10-27 21:42:24 +01:00
Adrià 80b209d984 Merge pull request #11295 from Danigamer05/feat/libc-unsigned-min32
feat(libc): implement unsigned 32-bit minimum
2026-10-27 21:20:30 +01:00
Dean ab6a87a163 Merge pull request #10460 from Danigamer05/feat/libc-unsigned-max64
feat(libc): implement unsigned 64-bit maximum
2026-10-28 06:53:22 +13:00
Adrià 6a5950b5ce Merge pull request #10903 from imellag/test/libc-update-env-macos
test(libc): run the feupdateenv checks on macOS and under Rosetta 2
2026-10-27 12:00:19 +01:00
Hedi Trigui 3d17309724 feat(libc): implement reallocarray 2026-10-27 10:46:33 +01:00
JJenkxandClaude Opus 5.5 8f39bcc549 Merge main into PR #10283
Conflicts with main's newer libc changes resolved without changing either
side: the debt list keeps each side's entry changes (per entry, deletions
included), GuestMath.cpp keeps both sides' test functions and calls, and
Math.cpp differs from main by exactly this branch's own changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 05:06:27 -04:00
Dean 77f68f314b Merge pull request #11560 from Ragbie/fix/write-after-read-update-stream
fix(libc): set up streams for writing after a read as FreeBSD does on Windows
2026-10-27 21:27:48 +13:00
Dean f9b2db1d41 Merge pull request #11269 from Gruzzberry/fix/realpath-symlinks
fix(libc): realpath resolves symbolic links like FreeBSD
2026-10-27 21:22:09 +13:00
Dean d5f7d86ccc Merge pull request #11139 from JJenkx/fix/libc-modf-floating-environment
fix(libc): preserve modf decomposition and floating-point status
2026-10-27 21:20:33 +13:00
Dean d090e62841 Merge pull request #11074 from JJenkx/fix/libc-frexpf-floating-environment
fix(libc): preserve frexpf decomposition and exception behavior
2026-10-27 21:18:34 +13:00
Rookie 4c28647f0a fix(libc): answer EBADF to a null filename on a closed stream as the console does 2026-10-27 08:11:28 +00:00
Rookie 9618254977 fix(libc): reopen a closed stream in freopen instead of aborting 2026-10-27 08:11:28 +00:00
Dean 2aacb376ee Merge pull request #10346 from JJenkx/windows/libc-logb-msun
fix(libc): compute logb and logbf with FreeBSD msun's algorithm, as titles' libc.prx does
2026-10-27 21:09:12 +13:00
Dean 5a36b2df1e Merge pull request #9850 from JJenkx/windows/libc-powf-msun
fix(libc): compute powf like the libc.prx that titles ship
2026-10-27 21:07:00 +13:00
Dean 853b370f01 Merge pull request #9784 from JJenkx/windows/libc-atan2f-msun
fix(libc): compute atan2f with FreeBSD msun's algorithm, as titles' libc.prx does
2026-10-27 21:06:05 +13:00
Dean 619ac3c2b6 Merge pull request #10467 from MarcZX10/fix/libc-tgammaf-underflow-sign
fix(libc): preserve tgammaf underflow sign
2026-10-27 20:53:02 +13:00
Dean 2f0a0071f5 Merge pull request #10251 from orezraey/docs/libc-fopen-directory-measured-ps5
docs(libc): record fopen and freopen of directories as measured on a PS5
2026-10-27 20:52:15 +13:00
Adrià 8df2c3ed0e Merge pull request #11259 from orezraey/docs/libc-reallocalign-measured-ps5
docs(libc): record reallocalign to size 0 as measured on a PS5
2026-10-27 08:29:28 +01:00
Adrià 8787ae1bb3 Merge pull request #11245 from AlexFigas/docs/libc-isfinitel-bundled-code
docs(debt): close the __isfinitel entry with the bundled libc.prx code
2026-10-27 08:23:28 +01:00
Emanuele f7f88a4886 fix(libkernel): wire a remapped locked range again on macOS
- mlock on macOS skipped every page the locked ranges recorded, but a
  mapping that replaces a locked range in place leaves the record behind
  without wires, so a later mlock returned 0 and wired nothing. Within a
  recorded range it now wires again the host regions whose wire count is
  0. The mlock test locks, remaps the range fixed and locks again.
- munlock and munlockall on macOS hold the locked-range lock across the
  host unwire and the record update, so a concurrent mlock cannot see a
  range as wired while it is being unwired.
- sceKernelVirtualQuery limits the host region it reports to the write
  watch run that holds the address, so the permissions it reports hold
  for the whole extent.
- The libc debt entry says what the mapping paths do: they register the
  range again, and GuestWriteWatchProtectionChanged has no caller yet.
2026-10-27 08:16:36 +01:00
Emanuele f2e8d5a3eb fix(libkernel): address the macOS memory protection review
- mlock on macOS wires only the pages libkernel has not wired yet. XNU
  counts each wire of a page, and the locked ranges merge overlapping
  locks, so a page locked twice stayed wired after munlock and
  munlockall. The mlock test checks the wire count on macOS.
- mprotect changes a watched page through GuestWriteWatchProtect, which
  applies the host protection and records it under the write watch's
  lock, so a collection on another thread cannot run between the two.
  The write watch test covers it.
- sceKernelVirtualQuery takes a watched page's write permission from the
  write watch for memory outside the guest allocation registry.
- GuestAllocationsGuestPages counts an image segment up to the end of
  its last host page, as the image page collection does.
- The macOS includes stay in main's include block, so the host code
  other pull requests add there still sees them; the unused Mach-O
  headers and the end trim, which never changed the protected spans,
  are gone, and the guest page size is passed in.
- The libc and libkernel debt entries describe what is wired now.
2026-10-27 08:16:36 +01:00
xXPBSXx 9dc6ed12c2 Merge main (81267b2204) into libm/sinh-msun 2026-10-27 08:09:31 +01:00
xXPBSXxandClaude Sonnet 5.5 a695743b3d fix(libc): set ERANGE when sinh overflows
The host sinh set errno to ERANGE on overflow and sinhf does, but the msun port
returned the overflowed value with errno untouched. The overflow path of
sinh_nid_postfix sets ERANGE again; msun itself sets no errno.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-27 07:59:34 +01:00
Adrià b806f1a7a0 Merge pull request #11217 from AlexFigas/docs/libc-dinkumware-division-evidence
docs(debt): cut the long-double Dinkumware entry to _LLog with the bundled libc.prx code
2026-10-27 07:58:44 +01:00
xXPBSXx fccdc6d687 Merge main (951e5963a4) into libm/sinh-msun 2026-10-27 07:58:16 +01:00
Dean 1a13c2969f Merge pull request #9833 from MarcZX10/codex/libc-strtod-decimal-subnormal-erange
fix(libc): set ERANGE for decimal strtod subnormals
2026-10-27 18:21:37 +13:00
Dean 940c298d51 Merge pull request #9698 from mazen320/feat/libc-num-put-vtable-size
fix(libc): size the num_put facet vtable to 112 bytes
2026-10-27 18:20:54 +13:00
Dean 8aa1f9ef7f Merge pull request #9344 from MarcZX10/codex/macos-backtrace-support
feat(libc): restore macOS guest backtraces
2026-10-27 18:20:03 +13:00
Adrià 60bb466419 Merge pull request #10505 from maximilianfv/fix/libkernel-macos-itimer-terminate
fix(libkernel): reach the guest terminate handler from an ITIMER_REAL expiry on macOS
2026-10-27 04:51:54 +01:00
Adrià 71a20013cd Merge pull request #11164 from orezraey/docs/libc-hardware-concurrency-measured-ps5
docs(libc): record std::thread::hardware_concurrency as measured on a PS5
2026-10-27 04:51:40 +01:00
Adrià 1d667d5f52 Merge pull request #11121 from orezraey/docs/libc-fenv-setlocale-strcasecmp-measured-ps5
docs(libc): record feholdexcept, fegetexcept, setlocale and strcasecmp as measured on a PS5
2026-10-27 04:51:24 +01:00
Dean defd713929 Merge pull request #10788 from 00xDisaster/feat/libc-thread-gaps
feat(libc): implement _Thrd_lt
2026-10-27 14:59:56 +13:00
Dean 304bea47ca Merge pull request #9771 from JJenkx/windows/libc-asinf-msun
fix(libc): compute asinf with FreeBSD msun's algorithm, as titles' libc.prx does
2026-10-27 14:58:25 +13:00
Danigamer05 218e9c7e4e feat(libc): add standard count-ones functions 2026-10-27 02:38:24 +01:00
Danigamer05 4b911d7bae feat(libc): implement signed 64-bit maximum 2026-10-27 01:58:46 +01:00
Danigamer05 80bc31bb6c feat(libc): implement signed 64-bit minimum 2026-10-27 01:58:45 +01:00
Danigamer05 be750a1f38 feat(libc): implement unsigned 32-bit minimum 2026-10-27 01:58:44 +01:00
Danigamer05 7792cff8ef feat(libc): implement unsigned 64-bit maximum 2026-10-27 01:58:43 +01:00
JJenkxandClaude Opus 5.5 1add0a5859 fix(libc): follow the console's rand, srand and rand_r
rand and rand_r both used FreeBSD's do_rand (Park and Miller on
state % 0x7ffffffe + 1, minus one), so rand returned values up to
0x7ffffffd and rand(), rand_r() and every seeded sequence differed
from the console. The libc.prx that titles ship (the same code in the
copies of PPSA13934, PPSA07923 and PPSA05916, read from disassembly)
uses two different generators:

- rand steps a 64-bit state, initially 1, as
  state * 0x5851F42D4C957F2D + 1 and returns (state >> 32) & 0x3FFFFFFF,
  so its results stay at or below 0x3FFFFFFF. srand stores the seed
  zero-extended as that state.
- rand_r is the minimal standard generator, state * 16807 modulo
  2^31 - 1 on the signed 32-bit state (1 gives 16807, 282475249,
  1622650073), and a zero state becomes 0x2AE1B767.

guest_math now expects those results: the rand_r chain from 1, the
zero and 0x7FFFFFFF states, rand after srand(1), srand(0) and
srand(0xFFFFFFFF), and rand's range over 1000 calls. Its previous
checks expected FreeBSD's values and rand matching rand_r.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 20:22:30 -04:00
B-HowellandClaude Opus 4.7 a2b59db71a feat(libc): implement strtoq
Add the BSD "quad" `strtoq` export for the libc PRX as a thin wrapper
around `strtoll`, as FreeBSD 11.4 lib/libc/stdlib/strtoq.c does.  The
unsigned sibling `strtouq` is already here as the same alias of
`strtoull`.  Extend the guest wide strings test to probe the signed
path on an under/overflow run and a short positive run with a trailing
non-digit.  Document the export in docs/dev/debt/libc.md with the
registry NID `yUUOxgk8Dmc`; console behavior is unverified beyond the
existing `strtoll` contract.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
2026-10-26 20:19:37 -04:00
Emanuele 5556444f2b test(libc): run the feupdateenv checks on macOS and under Rosetta 2
Two host differences failed all 19 feupdateenv tests on macOS:

- Apple's libc++ looks up /usr/lib/libstdc++.6.dylib with a no-load
  dlopen the first time a process builds a std::logic_error, and that
  failed lookup leaves errno at ENOENT. The null check builds the first
  one, so it saw errno change although feupdateenv never touched it. The
  test now builds one std::invalid_argument on macOS before the checks.
- Rosetta 2 keeps the six MXCSR exception masks set and raises no
  floating-point trap, x87 included. The mask check now expects the SSE
  masks the host keeps, and the pending-trap tests are skipped (exit 77)
  on a host that does not keep an unmasked MXCSR exception. A libc debt
  entry for feupdateenv records it.
2026-10-27 00:08:54 +01:00