Commit Graph
414 Commits
Author SHA1 Message Date
boykopovar 2db4bb590b fix(sdk): restore linux and libc++ header compatibility 2026-10-25 00:02:51 +03:00
boykopovar 2a99f02f25 fix(sdk): reconcile declarations after main rebase 2026-10-24 23:17:50 +03:00
boykopovar 53a65ec210 fix(sdk): sync declarations with latest main 2026-10-24 23:17:48 +03:00
boykopovar fdf9ca7574 fix(sdk): reconcile public headers after rebase 2026-10-24 23:17:47 +03:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
Dean 82443ce914 Merge pull request #10223 from orezraey/fix/libc-printf-measured-ps5
fix(libc): format sizes, NaN signs, UTF-16 units, positions and unknown conversions as a PS5 does
2026-10-25 07:34:56 +13:00
Adrià 6b23aaf129 Merge pull request #9159 from EagleBearerYS/fix/agc-rewatched-imports-compared-when-shared
fix(agc): keep a rewatched import's memory compared once it is shared
2026-10-24 20:26:38 +02:00
Dean 845e081537 Merge pull request #9038 from akkadbakkad89/feat/libc-facet-getcat
feat(libc): cover the codecvt, numpunct, num_put and time_put facets, their ids and std::clog
2026-10-25 06:39:27 +13:00
Dean ebdfb92528 Merge pull request #8872 from ycbuzi/feat/libc-siginterrupt
feat(libc): implement siginterrupt through the sigaction libkernel registers
2026-10-25 06:39:00 +13:00
Yunus Shaikh df89dd1041 Merge main into fix/agc-rewatched-imports-compared-when-shared 2026-10-24 09:51:13 -07:00
orezraeyandClaude Opus 5.5 2f99b411af Merge main into fix/libc-printf-measured-ps5
Keep #3987's q, D, O, U, width, '-' and trailing '%' handling for
unknown conversions and fold it into this branch's measured path:
'#' and precision are ignored as measured, '+', space, apostrophe
and '0' with a width still throw.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 13:33:52 -03:00
akkadbakkad89 22957f173e refactor(libc): order codecvt vtable slots like the Dinkumware declaration
alwaysNoconv, maxLength, encoding, in, out, unshift, length matches the MSVC/Dinkumware xlocale declaration order at 0x20-0x50; the generated layout is unchanged because each swapped pair shares one function pointer.
2026-10-24 22:00:40 +05:30
Adrià dca72a82da Merge pull request #3987 from MarcZX10/codex/carry-windows-format-freebsd-3975
fix(libc): match title printf behavior on Windows
2026-10-24 17:59:27 +02:00
akkadbakkad89andDevin 88f209ff93 feat(libc): cover the codecvt, numpunct, num_put and time_put facets, their ids and std::clog
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-24 19:14:58 +05:30
Dean 3eebf30c2e Merge pull request #9945 from p3n1cillin/claude/windows-missing-standard-handles
fix(libc): open NUL on standard descriptors without a stream on Windows
2026-10-24 23:40:27 +13:00
bluandClaude Opus 5.5 e040d1191b Merge branch 'boykopovar:main' into feat/libc-siginterrupt
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 02:49:01 -07:00
MarcZX10 a3e41499be fix(libc): match title printf conversions on Windows 2026-10-24 10:22:15 +02:00
Hussein Kadhim b331e3a86d fix(libc): keep throwing for printf conversions FreeBSD supports but Windows does not
The unknown-conversion branch printed %m, positional arguments, the grouping
flag and modifiers in an unusual order as literal characters. Only characters
FreeBSD's vfprintf prints as themselves are now printed.

(cherry picked from commit 0106858d3d39f83eb2234a5f581d5bf5260521a0)
2026-10-24 10:22:15 +02:00
Hussein Kadhim 621a487bdf fix(libc): print the FreeBSD printf extensions and stray percent signs on Windows
The Windows printf family threw on the q length modifier, the D, O and U
conversions, an unknown conversion character and a format ending in a percent
sign, where FreeBSD's vfprintf formats the first three and prints the unknown
character itself or stops at the end of the format.

(cherry picked from commit 0e3b2896d228c601cefc992b2895723188ebf0fa)
2026-10-24 10:22:15 +02:00
Dean aeeaefad98 Merge pull request #8885 from hypermoist/feat/libc-sce-v2-thread-sync
feat(libc): add the std::__sce_v2 mutex, condition and thread calls
2026-10-24 21:09:55 +13:00
Yunus Shaikh 719a048a1f Merge main into fix/agc-rewatched-imports-compared-when-shared 2026-10-23 23:58:11 -07:00
Dean 376d175996 Merge pull request #10070 from thuanquang/perf/anon-map-commit
perf(libc): carve fresh private guest pages out of their placeholder
2026-10-24 19:54:03 +13:00
Dean Galvin 18b13fbe64 Merge main into 9945 2026-10-24 15:49:35 +13:00
Dean 88d4f1662c Merge pull request #10020 from Queuse/codex/keep-host-diagnostics-unbuffered
fix(libc): isolate host diagnostics from guest buffering
2026-10-24 15:22:01 +13:00
Dean d1d67190a8 Merge pull request #8720 from orezraey/fix/libc-heap-measured-ps5
fix(libc): follow the default heap's alignment, errno and realloc to zero as measured on a PS5
2026-10-24 14:34:38 +13:00
Queuze 897bf2ef6c fix(libc): attach missing standard streams to NUL 2026-10-24 00:51:42 +01:00
Queuze d43043b6e5 chore: sync contribution #10020 with main 2026-10-23 20:02:15 -03:00
Dean 999e612599 Merge pull request #4627 from mugurc/fix/libc-macos-host
fix(libc): build the host-facing libc code on macOS
2026-10-24 11:50:45 +13:00
hypermistandClaude Opus 5.5 e813b210bc Merge remote-tracking branch 'upstream/main' into feat/libc-sce-v2-thread-sync
Kept both sides of GuestLibcThreads.cpp: main's ThreadHelpers test and this PR's VersionedSync test, both called from main().

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 07:59:37 +13:00
orezraeyandClaude Opus 5.5 4756ead5d7 fix(libc): cap argument positions and share the known conversion list
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 11:26:07 -03:00
orezraeyandClaude Opus 5.5 33f1d7ec43 fix(libc): format sizes, NaN signs, UTF-16 units, positions and unknown conversions as a PS5 does
Measured through libSceLibcInternal.sprx's snprintf in a payload process on a PS5 (firmware 13.60): any size is accepted, a NaN keeps its sign and the + and space flags, each UTF-16 unit of %ls and %lc is encoded alone, positions above 99 work, and an unknown conversion such as %m prints % and its letter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 11:20:47 -03:00
Yunus Shaikh 37a5d9495d fix(libc): report each compared shared page once after it stops being collected
A page marked to be compared when shared is refused by every collect once a
second mapping demotes it, so the writes made to it since its last collect
were never reported. Each view of such a page now carries an unreported mask:
set when the view is demoted, when the page is first marked while the view is
already shared, and when a new view of a marked page is mapped. ComparedPages
lists the compared shared pages of a range, or takes the unreported ones.
2026-10-23 11:21:23 +00:00
Adrià e5ca7307cf Merge pull request #6292 from meh7an/perf/agc-draw-path-locks
perf(agc): replace winpthreads locks and TLS on the draw path
2026-10-23 11:53:59 +02:00
Mehran 2659ec333e perf(agc): replace winpthreads locks and TLS on the draw path 2026-10-23 11:32:03 +03:00
alfalfa-starandClaude Opus 5.5 5d3c0d741a perf(agc): memoize host import run bounds per lease snapshot
Every import lookup walked the lease out from the containing range to find
the run of continuing registry ranges, which is linear in the run length.
That walk depends only on the lease snapshot, the containing range and the
import window block, so its first and last index are now memoized per
thread under a weak reference to the snapshot, the range index, the window
and the window's low end. APS5_NO_RUN_MEMO walks every time.

Everything that depends on other state runs on each call as before: the
largest size, the budget, the failed blocks, the remembered refusals and
the halving block search. importRunBounds returns the chosen indices, so
sameRange, runCovers and the whole-run lookup in importAllocation compare
against the lease without copying the run's range pointers.

importRunFailureShrinkTests records a failed 8 MiB block between two
lookups on an unchanged registry and requires the run to shrink to its
4 MiB blocks. importRunGrowthTests and importRunReplacedTests check that a
run grows and shrinks when its ranges are registered or replaced.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 10:04:37 +02:00
thuanquangandClaude 73f9b5d9fb perf(libc): carve fresh private guest pages out of their placeholder
A private guest commit on Windows (every anonymous kernel map commits
with a 16 KiB granule) ran reset() on each page before replacing it:
10 VirtualQuery calls, a placeholder split and the VirtualAlloc2, so
12 calls per page. At the arena's first-fit frontier the placeholder is
the arena's free tail, hundreds of GiB.

Commit now queries a placeholder once, cuts the range out of it (one
split where the range starts inside the placeholder, one where the
placeholder extends past the range), and carves the pages from that
bounded placeholder: one split and one VirtualAlloc2 per page, and no
split for the last page. Each page is still its own allocation with the
same protection, write watch and created ranges, so munmap, MAP_FIXED
remaps, views and collects see the same layout as before. A piece that
would cross the end of its placeholder (a whole-range granule over
several placeholders) still takes the coalescing path through reset(),
and committed memory in the range still only changes its protection. A
zero granule now throws std::invalid_argument before touching the
address space.

windows_write_watch counts the queries with a compile-time counter that
only that test defines (APS5_COUNT_MAPPING_QUERIES, copied from #9505)
and checks: 256 fresh pages one page into a 1 GiB placeholder take one
query (main's loop makes 2,561), each page is its own allocation and
the placeholders around them are intact; the release and recommit of
one page; a protection-only commit; the write watch of carved pages; a
whole-range granule inside one placeholder and across two; committed
pieces and adjacent placeholders inside the range; a partial release
and a fixed remap that keep their neighbours; a granule that would
cross the end of the placeholder being carved, which takes the
coalescing path; a short last piece; a commit that runs to the end of
its placeholder; an unwatched commit; and the zero-granule throw.

PPSA14363 boot on an RX 6700 XT, idle PC, 4 runs on main and 3 with
this change: the first 10 s after the first present go from 546-552
presents with a 578-704 ms frame to 588-594 presents with a 97-117 ms
frame.

Co-Authored-By: Claude <[email protected]>
2026-10-23 14:52:45 +07:00
Queuze 7358bec9ff fix(libc): isolate host stream buffering 2026-10-23 01:22:23 -03:00
Yunus Shaikh 1ad5f29e20 fix(libc): compare the resident runs an import's alias demotes once they are shared
An import over a range that is not all writable private memory maps a
read-write alias first, and MapAlias demotes every resident run in the
range to shared views before ImportWatched runs. ImportWatched then
marks only the views that are still resident, so the pages the alias
itself demoted stayed unmarked: the import's own walk and every later
clearing collect armed them, and a guest store into one faulted.

demote now records that MapAlias demoted a view, and the resident-only
mark ImportWatched applies to the spans it kept watched also marks those
views. A second guest mapping of the page clears the record, so memory
the guest shares keeps today's tracking. agc_import_alias_shared checks
both, with single pages at 64 KiB boundaries.

Grand Theft Auto V (PPSA04264) still faults in its HDD streamer with
#9181 and #9159; one of those faults is a resumed store into a 16 KiB
MEM_MAPPED view
(https://github.com/boykopovar/AnyPS5/issues/9136#issuecomment-6356302049).
This closes one path that arms such views; it does not claim to remove
those faults.
2026-10-23 03:22:50 +00:00
Yunus Shaikh 47c8df4950 fix(libc): keep a compared shared page's mark across a full unmap and remap
#9159 marks memory that a rewatch or an import kept watched while it was
resident with SharedPage::comparedWhenShared, so its shared views stay
compared instead of armed. The mark lived only on the SharedPage, which
a physical slot holds weakly: once every view of that physical page was
unmapped, Map's pageOf made a fresh, unmarked SharedPage for the next
mapping, and the next clearing collect armed its aliases again.

The mark is now also kept on the physical slot. CompareWhenShared sets
it through each view's slot, and pageOf copies it into a SharedPage it
creates. ForgetSection still drops the slot and the mark with it, so a
reused section handle starts unmarked, and memory shared before it was
ever marked keeps its tracking. MapAlias and its runs create no
SharedPage, so they need no change.

The test maps one page resident, marks it, unmaps it, maps it into two
views, and requires a clearing collect over either view to refuse and
neither to be made read-only; after ForgetSection the same mapping is
collected and armed again.

Grand Theft Auto V (PPSA04264): tibzejoker's remaining resumed write
faults in zlib's inflate_fast with #9181 and #9159
(https://github.com/boykopovar/AnyPS5/pull/9159#issuecomment-6355849767)
may come from memory remapped this way. This change does not claim to
remove them.
2026-10-23 02:35:16 +00:00
Adrià a6fc8a467d Merge pull request #8797 from xXPBSXx/fix/unlink-rmdir-dot-component
fix(libkernel): fail unlink and rmdir of a path that ends in a dot component with EINVAL
2026-10-22 20:40:44 +02:00
Adrià d969e4bd60 Merge pull request #9223 from xXPBSXx/fix/file-stream-status-sync-race
fix(libc): publish the guest FILE status of a stream with atomic accesses
2026-10-22 20:24:20 +02:00
bluandClaude Opus 5.5 0017ed2660 Merge branch 'boykopovar:main' into feat/libc-siginterrupt
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 10:56:17 -07:00
emirplus 2824bf21eb fix(libc): check size limits, overlap, and invoke handler in wcscpy_s 2026-10-22 18:33:56 +03:00
mugurc c27787a7db fix(libc): build the host-facing libc code on macOS
feof_unlocked, ferror_unlocked, getc_unlocked and putc_unlocked are macros
on macOS, so they are called without the global scope qualifier. The
remaining differences are the ones Darwin's headers and libSystem have:

- CLOCK_REALTIME_COARSE and st_mtim do not exist; the write mark uses
  CLOCK_REALTIME and st_mtimespec.
- tm_zone is a non-const char*.
- __cxa_thread_atexit returns void, so the wrapper reports success.
- Darwin's stack protector reads __stack_chk_guard from libSystem; the
  guard of the guest libc has the postfixed name, which receives the NID
  of the original.
- APS5_EXPORT spells the symbols with the leading underscore of Mach-O.
- GuestArenaSetProtection and PosixProtection are built on macOS as on Linux.
- The fclose failure test fills /dev/full, which exists on Linux only.

exception_runtime relies on the Itanium unwinder of libc, which is not
registered on macOS (the host libc++abi is used), so its test is only
registered elsewhere.
2026-10-22 12:25:14 +03:00
hypermist a2d22219b4 Merge remote-tracking branch 'upstream/main' into feat/libc-sce-v2-thread-sync 2026-10-22 21:57:46 +13:00
Dean 746bdd8041 Merge pull request #8550 from Retr0G28/fix/fopen-directory-read-windows
fix(libc): open a directory with fopen in a read mode on Windows
2026-10-22 17:22:22 +13:00
blu b440d11cbb Merge branch 'boykopovar:main' into feat/libc-siginterrupt 2026-10-21 19:03:47 -07:00
xXPBSXxandClaude Sonnet 5.5 f65a3f3341 fix(libc): publish the guest FILE status of a stream with atomic accesses
Two threads writing to the same stream each ran FileStream::SyncStatus
after their stdio call, outside the FILE lock, with plain writes to the
read and write counters and a read-modify-write of the flag word, so the
flags of one thread could be lost. Publish the counters with atomic
stores and the flags with a compare-exchange loop; the values stay the
same.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-21 17:29:16 +02:00
Yunus Shaikh 81aec58343 fix(agc): keep an import's resident memory compared once it is shared
Since #8172, a host import that stays in the write watch keeps each of
its watched runs in the watch instead of taking the whole import out
when part of it was unwatched. Grand Theft Auto V (PPSA04264) imports
resident direct memory that way, and later maps the same memory at a
second address, which turns it into shared views. From then on the write
watch arms them, and the game's own stores fault and are resumed, the
red zone hazard of #361 (#9136, eboot 0x162b9e4 and 0x28f413a).

ImportWatched now marks the resident pages of each run it keeps in the
watch with GuestArenaCompareResidentWhenShared. They stay write-watched
while they are private, as #8172 needs for resident DCC targets. Once
they are shared, their collects fail and they are compared, as before
#8172, instead of being armed. Memory that is already shared when it is
imported is not marked and stays tracked as before.

agc_rewatched_direct_shared gains the imported case: resident direct
memory imported with the watch kept, then mapped a second time, must
collect as 0 through either mapping, stay writable and show a store
through both, while unimported shared direct memory is still collected.
windows_write_watch gains CheckResidentOnlyComparedWhenShared: a
resident-only mark leaves a shared view armed and collected, and still
keeps a resident page compared once a second mapping makes it shared.
2026-10-21 07:48:41 -07:00
hypermist 8e08acba70 Merge remote-tracking branch 'upstream/main' into feat/libc-sce-v2-thread-sync
# Conflicts:
#	core/libs/tests/GuestLibcThreads.cpp
2026-10-22 02:52:08 +13:00