Commit Graph
652 Commits
Author SHA1 Message Date
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
xXPBSXxandClaude Sonnet 5.5 b265a0d8c1 fix(libc): compute asinh with FreeBSD msun's algorithm
asinh_nid_postfix called the host libm's asinh. It now follows the branches and
thresholds of FreeBSD msun's s_asinh.c (release/11.4.0): below 2^-28 it returns x,
up to |x| = 2 it uses log1p, up to 2^28 log(2|x| + 1/(sqrt(x*x+1)+|x|)) and above
that log(|x|) + ln2. Up to |x| = 2 the results are bit-identical to msun; above 2
they depend on the host log this file still uses.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-27 07:10:31 +01:00
iAbdulrrahman 9f77f256a9 feat(libc): implement 64-bit atomic fetch helpers 2026-10-27 09:05:24 +03: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
UnhealthyKraken 92effeb9d3 chore(libc): merge main and preserve prefix debt 2026-10-27 02:42:31 +00: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 762556eb2d feat(libc): implement signed 32-bit minimum value helper 2026-10-27 01:58:48 +01:00
Danigamer05 5f08cbf1b3 feat(libc): implement unsigned 32-bit maximum 2026-10-27 01:58:47 +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
orezraeyandClaude Opus 5.5 34ee59f12b Merge main into docs/libc-fenv-setlocale-strcasecmp-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 19:30:20 -03:00
MarcZX10 bcd99084b4 test(libc): cover signed tgammaf underflow 2026-10-26 22:18:30 +00:00
Dean c739a47136 Merge pull request #11289 from Danigamer05/feat/libc-unsigned-min64
feat(libc): implement unsigned 64-bit minimum
2026-10-27 11:06:32 +13:00
Dean b8265bf2bc Merge pull request #11241 from edubox/feat/libc-future-category
feat(libc): export the error_category members and std::future_error
2026-10-27 11:04:49 +13:00
Dean bf38c3bc34 Merge pull request #11208 from orezraey/fix/libc-random-state-measured-ps5
fix(libc): save the random state on a short initstate and take any setstate rear as measured on a PS5
2026-10-27 11:03:11 +13:00
Dean fc2594c7ac Merge pull request #11177 from orezraey/feat/libc-fe-dfl-env-measured-ps5
feat(libc): export __fe_dfl_env as measured on a PS5
2026-10-27 11:02:06 +13:00
Dean d6ac53ba34 Merge pull request #11054 from verusferro/feat/libc-num-put-do-put
feat(libc): format num_put<char>::do_put as the console's libc does
2026-10-27 11:00:12 +13:00
Dean c980e6ef33 Merge pull request #11004 from verusferro/fix/libc-strftime-iso-week
fix(libc): compute strftime week numbers as the console's libc does
2026-10-27 10:58:48 +13:00
Dean 806a573b0b Merge pull request #10139 from dotaku22/feat/libc-fpurge
feat(libc): implement buffered stream purge
2026-10-27 10:53:27 +13:00
Dean c74530e615 Merge pull request #8903 from UnhealthyKraken/feat/libc-feraiseexcept
feat(libc): implement feraiseexcept
2026-10-27 10:52:51 +13:00
Dean ed8fd06177 Merge pull request #11166 from 00xDisaster/feat/libc-collate-vtable-wire
feat(libc): wire the collate<char> facet vtable
2026-10-27 10:38:27 +13:00
xXPBSXx dd44db30b0 Merge remote-tracking branch 'upstream/main' into libm/sinh-msun 2026-10-26 21:04:52 +01:00
Dean 265c36523c Merge pull request #10175 from orezraey/fix/libc-fetestexcept-measured-ps5
fix(libc): return fetestexcept's unmasked status bits as measured on a PS5
2026-10-27 08:57:53 +13:00
xXPBSXxandClaude Sonnet 5.5 905b15f25c fix(libc): compute sinh with FreeBSD msun's algorithm
sinh_nid_postfix called the host libm's sinh. It now follows the branches and
thresholds of FreeBSD msun's e_sinh.c (release/11.4.0): below 22 through expm1,
between 22 and ln(DBL_MAX) through exp, and up to the overflow threshold through
exp scaled as in k_exp.c's __ldexp_exp. Below 22 the results are bit-identical to
msun; from 22 on they depend on the exp this file provides.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-26 20:01:35 +01:00
Evrim Cicek a7b52084ec fix(libc): set up streams for writing after a read as FreeBSD does on Windows
On Windows the UCRT drops a write that directly follows a read on an r+,
w+ or a+ stream: fputc and fprintf report success, fwrite returns 0 and
fputs returns EOF, all without the error indicator, and the file is left
unchanged, also after an fflush. On a stream open only for reading, fputc
after a read reports success as well.

Writes now first do what FreeBSD 11.4's __swsetup does: a stream open only
for reading fails with EBADF and sets the error indicator, and an update
stream that is reading drops its read buffer and ungetc data, clears end
of file and writes at the descriptor's offset. This covers fwrite, fputs,
fputc, putc_unlocked, fprintf, fprintf_s, fputwc, fputws, fwprintf,
fwprintf_s, puts and wprintf, and printf, vprintf and printf_s, which
write to standard output through PrintWindows and now return -1 there
instead of throwing.

Linux is unchanged: glibc writes at the stream position, which the libc
technical debt now records.
2026-10-26 21:53:56 +03:00
Adrià c9a6013f4d Merge pull request #10468 from JJenkx/fix/libc-nextafter-fenv
fix(libc): preserve nextafter exception flags and denormal modes
2026-10-26 19:50:43 +01:00
Dean 3a1c60898a Merge pull request #11156 from orezraey/fix/libc-fdopen-measured-ps5
fix(libc): check the fdopen mode before the descriptor and skip the access check as measured on a PS5
2026-10-27 05:43:39 +13:00
Dean 4971b380b3 Merge pull request #11127 from orezraey/fix/libc-strerror-r-texts-measured-ps5
fix(libc): give strerror_r, perror and strerror_s the strerror texts as measured on a PS5
2026-10-27 05:42:18 +13:00