Commit Graph
366 Commits
Author SHA1 Message Date
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
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
emirplus 2824bf21eb fix(libc): check size limits, overlap, and invoke handler in wcscpy_s 2026-10-22 18:33:56 +03: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
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
Dean 1d2f8cfe0e Merge pull request #8859 from hypermoist/feat/libc-c11-thread-forwards
feat(libc): forward the C11 thread and TSS calls to libkernel
2026-10-22 01:54:23 +13:00
Retr0 36226741f5 fix(libc): open a directory with fopen in a read mode on Windows
FreeBSD 11 fopen opens the path with _open, and vn_open_vnode refuses a
directory only for FWRITE or O_TRUNC, so fopen of a directory in a read
mode succeeds; Linux hosts already open it. On Windows CreateFileW
without FILE_FLAG_BACKUP_SEMANTICS refused it with EACCES.

fopen now opens such a path as a libkernel directory descriptor, which
libkernel registers in libc when it loads, and fclose and freopen remove
it from libkernel's table. Reads on the stream fail with EISDIR and set
the error indicator, as on a Linux host and FreeBSD's tmpfs: the Windows
CRT fails them already but reports EINVAL. Writes fail with EBADF, and
fseek, ftell and ungetc work, as on any read-only stream.
2026-10-21 14:48:37 +03:00
Adrià eb4a7fee4e Merge pull request #7525 from AlexOfTheForest/feat/scanf-wide-linux
feat(libc): scan 16-bit wide conversions in the sscanf family on Linux
2026-10-21 13:09:54 +02:00
Adrià 0a5080477f Merge pull request #6655 from al3w0f205/perf/hybrid-cpu-topology-worker-pinning
feat(libc): support multi-tier hybrid cpu topology in LayoutFromClasses
2026-10-21 13:01:57 +02:00
Dean a1f95a523f Merge pull request #8849 from hypermoist/fix/libc-integer-base
fix(libc): follow the console for integer bases and 0x prefixes
2026-10-21 23:46:18 +13:00
Dean e6ebe8a8b7 Merge pull request #8857 from Dripl1x/perf/direct-memory-section-pool
perf(libkernel): reuse released direct-memory sections that never held data
2026-10-21 22:20:39 +13:00
Dean b77bd58806 Merge pull request #8226 from dantdmdarealguy/fix/libc-update-stream-read-windows
fix(libc): switch update streams to reading as FreeBSD does
2026-10-21 19:57:35 +13:00
xXPBSXxandClaude Sonnet 5.5 9e6a3f9127 style(libc): drop the comment above TrimTrailingSeparators
Comments are only allowed for technical debt in this repository.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-21 08:18:49 +02:00
xXPBSXxandClaude Sonnet 5.5 7d87767137 fix(libc): keep the root when trimming the parent of a dot component
Trimming every trailing separator turned the Windows drive root "C:\" into
the drive-relative "C:". Trim only while the parent is longer than its
root_path(), and cover "/", "C:\" and "C:/" in guest_filesystem.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-21 08:16:59 +02:00
xXPBSXxandClaude Sonnet 5.5 288bd35d0d fix(libc): resolve the parent of a dot component without its trailing separator
RenameDotError_nid_no_patch resolved the parent with the separator kept
("file/"). On Linux std::filesystem::exists("file/") is false for a regular
file, so unlink, rmdir and rename of "file/." answered ENOENT instead of
ENOTDIR. Trim the trailing separators first (a lone "/" stays) and cover
rename of "file/." and "file/.." in guest_filesystem.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-21 08:01:50 +02:00
Dean 1ff5c8ac5c Merge pull request #8217 from xXPBSXx/fix/rename-dot-component-fb
fix(libc): report a status error of the rename parent directory instead of ENOENT or ENOTDIR
2026-10-21 18:00:40 +13:00
hypermistandClaude Opus 5.5 8bddc39245 feat(libc): forward the C11 thread and TSS calls to libkernel
_Call_once, _Tss_create, _Tss_delete, _Tss_get, _Tss_set, _Thrd_equal,
_Thrd_current and _Thrd_exit call scePthreadOnce, scePthreadKeyCreate,
scePthreadKeyDelete, scePthreadGetspecific, scePthreadSetspecific,
scePthreadEqual, scePthreadSelf and scePthreadExit and return their
results unchanged, as the console's libSceLibcInternal does.
_Mtx_current_owns returns 1 there. libkernel registers the calls with
libc at load, next to the pthread_create registration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
2026-10-21 16:31:00 +13:00
hypermistandClaude Opus 5.5 8e46144d48 fix(libc): follow the console for integer bases and 0x prefixes
- strtol, strtoul, strtoll, strtoull and strtouq return 0 for a base
  outside 0 and 2 to 36, leave the end at the start and set EINVAL;
  strtoimax, strtoumax, _Stoull, _Stoul and the wide forms do the same
  without errno.
- A 0x prefix with no hexadecimal digit after it (base 0 or 16) is no
  conversion: the end stays at the start of the string.
- wcstol, wcstoll and wcstoimax take one sign, convert the rest with
  wcstoull and clamp to the signed range with ERANGE, so "- 1" is -1
  and "+\t-1" overflows.
- atoi, atol and atoll truncate strtoull's result.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RbLgECLQ2bpDM7oe2urGZK
2026-10-21 16:05:00 +13:00
Dean 5d10ea9ea0 Merge pull request #8791 from JJenkx/windows/calltrace-faulting-thread
feat(libc): list the reporting thread's own calls in the call trace report
2026-10-21 15:40:39 +13:00
Evgeniy KazarinandClaude Opus 5.5 69f843c910 perf(libkernel): reuse released direct-memory sections that never held data
The title allocates, maps and releases about 48 direct-memory blocks per frame.
Each allocation created a pagefile-backed section and each release closed it.
A released section whose pages were never stored to (resident pages keep their
data in private memory and saved buffers, not in the section) is still blank,
so up to 256 such sections of at most 16 MiB, 256 MiB in total, are kept by
size and handed to the next allocation of that size instead of a new
CreateFileMappingW. APS5_NO_DIRECT_MEMORY_SECTION_POOL keeps the old behaviour.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 10:32:44 +08:00
Dean b13183e59e Merge pull request #7473 from Dripl1x/codex/skip-clean-resident-write-watch
perf(libc): skip write-watch queries for proven clean resident ranges
2026-10-21 14:55:09 +13:00
Dean 6c12024f7d Merge pull request #8741 from Queuse/fix/libc-freopen-share-delete
fix(libc): share delete on standard stream reopen
2026-10-21 14:47:29 +13:00
Dean 67f25e4681 Merge pull request #7470 from Dripl1x/codex/exact-resident-release
perf(libc): release exact resident mappings without repeated queries
2026-10-21 14:07:25 +13:00
al3w0f205 80780f2899 feat(libc): support multi-tier hybrid cpu topology in LayoutFromClasses 2026-10-20 19:32:31 -05:00
JJenkxandClaude Opus 5.5 3316ca3b24 feat(libc): list the reporting thread's own calls in the call trace report
The crash and abort reports printed the last 64 traced calls of the whole
process, so a thread that loops on a traced import (a mutex lock/unlock
pair, a profiler marker) pushes the calls of the faulting thread out of the
report. The ring already keeps the last 65536 calls with their thread.

CopyThreadCallTrace_nid_no_patch returns the most recent calls of one
thread from that ring, oldest first, and both reports (Windows crash and
abort, Linux abort) list up to 32 of them for the reporting thread after
the process-wide list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 20:25:31 -04:00
Dean c82867c77c Merge pull request #7472 from Dripl1x/codex/reuse-unreferenced-saved-memory
perf(libc): reuse saved direct-memory buffers when unreferenced
2026-10-21 13:25:04 +13:00
Dean 70c497739e Merge pull request #8636 from cadenasynyster/fix/libc-thrd-detach
feat(libc): implement _Thrd_detach
2026-10-21 13:11:55 +13:00
Queuze 3916eeaf6f fix(libc): share delete on standard stream reopen 2026-10-20 20:07:16 -03:00
Dean e25333e39a Merge pull request #8600 from ebarr24/ws/libc-fopen-streams
fix(libc): share delete access when freopen reopens a stream onto a file on Windows
2026-10-21 11:24:47 +13:00
Dean 466ce3ac45 Merge pull request #7474 from Dripl1x/codex/ui-lab-immediate-exit-cache
fix(agc): preserve pipeline caches on immediate guest exit
2026-10-21 11:23:40 +13:00
Ethan Barr 4f6a37d790 fix(libc): share delete access when freopen reopens a stream onto a file on Windows
On Windows, freopen reopened a stream through _wfreopen, which opens the file without FILE_SHARE_DELETE, so remove or rename of the file failed while the stream was open, unlike fopen streams and POSIX unlink/rename of an open file. freopen now closes the previous stream and opens the new file through the same CreateFileW path fopen uses, so the reopened stream shares delete access. Host standard streams and an empty filename keep the _wfreopen path. Reference: FreeBSD 11 unlink(2) and rename(2) succeed on a file that is open.
2026-10-20 17:07:21 -04:00
Evgeniy Kazarin 7898b5bd3a fix(libc): avoid repeated resident write faults 2026-10-21 03:55:51 +08:00
Evgeniy Kazarin a627328cfa perf(libc): skip write-watch queries for proven clean resident ranges 2026-10-21 03:53:50 +08:00
Evgeniy Kazarin 9d5f8326bf perf(libc): collect resident writes directly into the output buffer 2026-10-21 03:52:09 +08:00
cadenasynysterandClaude Sonnet 5.5 a8b6d1c411 feat(libc): implement _Thrd_detach
Animal Well (PPSA22520) imports _Thrd_detach (L7f7zYwBvZA) from libc.prx and nothing exports it, so the Windows loader stops at startup. Register libkernel's pthread_detach with libc like pthread_create and pthread_join, and return _Thrd_error (4) when it fails.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

Claude-Session: https://claude.ai/code/session_01GtXavMkgCTCdmRpweviHcQ
2026-10-20 21:31:16 +02:00
Dean 0b1d678fe5 Merge pull request #8148 from hamb3r/feat/libc-dinkumware-threads
feat(libc): export Dinkumware thread primitives from libc.prx
2026-10-21 06:21:49 +13:00
dantdmdarealguy a7e6e597d3 fix(libc): switch update streams to reading as FreeBSD does
On Windows the UCRT does not switch an r+, w+ or a+ stream from writing
to reading without fflush or fseek: fread after fwrite returned bytes of
the write buffer and the next flush wrote them over the file, and ungetc
failed on an update stream that was not already reading. On Linux glibc
does not switch either for ungetc, which pushes the byte back over the
pending write, drops the write and can corrupt the heap on the next read,
or for an fread of at least the buffer size, which drops the write and
reads from the old offset.

fread, fgetc, getc_unlocked, fgets, ungetc, ungetwc and fscanf now flush
pending output and mark the stream as reading first, as FreeBSD 11.4's
__srefill and __ungetc do, through _IO_switch_to_get_mode on glibc.
Writes directly after reads still go through the UCRT on Windows; the
gap is recorded in the libc technical debt.
2026-10-20 11:28:19 -05:00
Dean 77e31219c8 Merge pull request #8116 from dantdmdarealguy/fix/libc-readdir-fileno-windows
fix(libc): report the file number of each readdir entry on Windows
2026-10-21 04:55:57 +13:00
Adrià 286908f918 Merge pull request #7615 from XD3V3LOP3RX/codex/windows-remap-write-watch
fix(windows): restore write tracking after resident direct remaps
2026-10-20 17:06:48 +02:00
xXPBSXxandClaude Sonnet 5.5 1da2c0ff58 fix(libc): report a status error of the rename parent directory instead of classifying it
RenameDotError looked at the parent of a dot component with exists() and
is_directory(), so a stat failure other than a missing path, such as
permission denied, answered ENOENT or ENOTDIR. The parent is now read with
status(): a missing path is ENOENT (ENOTDIR when a component is a file), any
other error is mapped through FilesystemError, and only a successful status
decides between a directory (EINVAL) and a non-directory (ENOTDIR).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-20 14:09:41 +02:00
AnyPS5 Contributors aea2ca9b78 fix(windows): restore write tracking for resident direct remaps 2026-10-20 13:16:49 +02:00
Maz e1095000cc fix(libc): keep MinGW ANSI stdio when forcing host stdout/stderr
The Windows -include of HostStandardStreams.hpp pulled in stdio.h before
libstdc++ could set __USE_MINGW_ANSI_STDIO, so long double formatting
bound to UCRT. Define the MinGW flag and include cstdio for C++.
2026-10-20 13:39:19 +04:00
mazen c03168fb47 fix(libc): keep guest stdio on a dup2 of descriptors 1 and 2
Host logging opens its own FILE on the saved descriptor. The guest FILE stays on the replaced descriptor, so guest printf, puts and fprintf still reach the pipe.
2026-10-20 13:38:07 +04:00
mazen 715fe9ca26 fix(libkernel): keep host stdout off a guest dup2 onto descriptor 1
The same guest dup2 that fills the stderr pipe also replaces descriptor 1, so host stdout was still writing into the guest pipe.
2026-10-20 13:38:07 +04:00
dantdmdarealguy 251ca1c100 fix(libc): report the file number of each readdir entry on Windows
readdir and readdir_r returned d_fileno 0 for every entry on Windows,
because MinGW's _wreaddir reports no inode. FreeBSD 11.4's
_readdir_unlocked (lib/libc/gen/readdir.c) never returns an entry whose
d_ino is 0, and d_fileno is the number lstat reports as st_ino.

The Windows directory stream now reads the listing from the directory
handle with GetFileInformationByHandleEx(FileIdBothDirectoryInfo), so
each entry carries the file ID of the entry itself, symbolic links
included, without opening it. The ID is folded as stat and lstat fold
nFileIndexHigh:nFileIndexLow; the fold moves to WindowsDescriptor.hpp so
both libraries use it. rewinddir restarts the scan, telldir and seekdir
count entries as _wtelldir and _wseekdir did, and opendir fails with the
open error of the directory. A file system that lists no file ID gets a
nonzero number hashed from the name. Linux truncates the host inode to
32 bits as stat does instead of reporting 0 above 2^32.

guest_directory checks that every entry has a nonzero file number, that
the numbers of a file, a subdirectory and symbolic links to both equal
lstat's st_ino, that an entry created or removed while the directory is
open shows up after rewinddir, that a delete-pending entry no lstat can
open is still listed, and that seekdir returns the same number.
2026-10-20 03:52:39 -05:00
Dean d0ac490cb0 Merge pull request #8195 from xXPBSXx/fix/enotdir-through-file-fb
fix(libkernel): fail open, stat, lstat, access and unlink through a regular file with ENOTDIR on Windows
2026-10-20 18:07:05 +13:00
Dean 04ffb07ed8 Merge pull request #7982 from emirplus/fix/libc-asctime-s-constraints
fix(libc): validate time ranges and null-terminate in asctime_s and ctime_s
2026-10-20 17:47:00 +13:00