Skip to content

feat(libkernel): poll on file descriptors and Windows pipe read ends - #3649

Closed
pushkarreddyy wants to merge 2 commits into
boykopovar:mainfrom
pushkarreddyy:feat/libkernel-poll-files
Closed

pushkarreddyy wants to merge 2 commits into
boykopovar:mainfrom
pushkarreddyy:feat/libkernel-poll-files

Conversation

@pushkarreddyy

@pushkarreddyy pushkarreddyy commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What

libkernel's poll() previously threw for any descriptor below the socket range (0x10000000) with poll: descriptor X is not a socket.

This PR carries @screamm's fix from screamm:feat/libkernel-poll-files (commits c50ac7856 and e8d123804, authorship preserved) rebased cleanly onto current main:

  • Regular files, directories, and anonymous shared memory objects report requested POLLIN, POLLRDNORM, and POLLOUT immediately (following FreeBSD 11 vop_stdpoll and poll_no_poll).
  • Closed descriptors report POLLNVAL; POLLHUP clears POLLOUT (pollscan).
  • On Linux, pipes, terminals, and character devices use host poll.
  • On Windows, pipe() records descriptor ends (File/src/PipeEnd.cpp, tracked across dup, dup2, close, sceKernelClose); read ends answer via PeekNamedPipe (POLLIN/POLLRDNORM with buffered bytes, and POLLIN|POLLRDNORM|POLLHUP on ERROR_BROKEN_PIPE).
  • Mixed arrays containing both sockets and host descriptors check ready descriptors immediately and slice socket waits into 100 ms intervals.
  • Arrays exceeding 1024 descriptors throw.

Fixes #3521.

Tested

  • ProsperoTV (PPSA99003): Unblocks startup stop on descriptor 3; advances to menu ([TV] menu ready display=3840x2160) and runs past 60 s.
  • PSXS5 (PPSA97510 2.2.0): Directly resolves the 31-second runtime stop reported by @orishamir in feat(libkernel): implement pthread_attr_getscope, setscope, getinheritsched and getstackaddr #3494 (what(): poll: descriptor 6 is not a socket (#3521)).
  • Unit tests: guest_poll covers file POLLIN|POLLOUT, file + idle UDP socket returning 1 immediately, closed file POLLNVAL, >1024 descriptors throwing, empty pipe read end, pipe read end ready after write, POLLHUP after writer close, and write-end cases.
  • Tested on Windows 11 MinGW-w64 GCC 15.2.0 Release and verified with python tools/check_conventions.py --base origin/main (0 comments in source).

Checklist

@blawesom

Copy link
Copy Markdown
Contributor

Cross-linking for the review: this implements the fix tracked in #3521, which has an independent Linux verification on that issue — full suite 832/832 (CachyOS, kernel 7.2.9, GCC 16.2.1, including every Vulkan test on AMD RX 9070 XT / RADV), conventions check clean, rebased onto current main at the time. The Windows pipe read-end paths of this change are the part that could not be exercised there, so the report's Windows-side coverage complements it.

@blawesom blawesom mentioned this pull request Oct 11, 2026
9 tasks done
@screamm

screamm commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Windows validation of e8d12380 merged onto main a11c8f7f (Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON, full build including libs): the poll test passes 3/3 with --repeat until-fail:3; ctest -j8 -E "^agc_driver_|^video_out_flip" 531/536, the failures being the known windows_exceptions (#3411, fixed by #3415), guest_kernel_sys (#3510), guest_filesystem (#3518) and the load flakes agc_driver (#3171) and guest_ampr_markers (#3371). Same result as the original branch in #3521. Thanks for carrying it.

@pushkarreddyy

Copy link
Copy Markdown
Contributor Author

Calling on @adriadam10 for review when convenient:

Both platform verifications are complete for this carry of #3521:

  • Linux: full suite 832/832 verified by @blawesom (CachyOS / GCC / RADV).
  • Windows 11: verified 3/3 repeat poll passes and full libs suite 531/536 by original author @screamm.
  • All CI checks passing and conventions clean. Ready for merge!

@blawesom

Copy link
Copy Markdown
Contributor

Cross-reference: #3644 implements the same fix (poll on pipe descriptors, tracked in #3521).

CONTRIBUTING.md asks authors to "check that no open pull request already implements the same functions" before starting — both PRs are open, so flagging for the maintainers.

The limitation this creates: only one of the two can be merged; the other gets closed as duplicate, and both currently cost review time in a 340+ queue.

Evidence to help the choice (independent pre-review, Linux — CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON):

  • both pass the full local suite (832/832 each; fix(libkernel): poll pipe descriptors #3644 had one transient single-test flake that did not recur);
  • both are based on current main;
  • I see no functional difference from the diffs — both are legitimate implementations of the same fix.

If it helps, either author can rebase onto the other or close their own; the choice is the maintainers'.

@babyhuey

Copy link
Copy Markdown
Contributor

Verified this PR on both OSes with a title that needs it: ProsperoTV (PPSA99003, catalog 01.000.060).

Without this PR, but with openat from #3968 so the title loads, it opens its TV menu and then aborts in poll right after opening /dev/crypto:

  • Linux: poll: descriptor 6 is not a socket

With this PR stacked on #3968 (local merge of c50ac78/e8d12380, clean):

@screamm

screamm commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Heads-up from a Windows validation attempt: e8d12380 no longer merges onto main (bab7b328/bca7a29d). The only conflict is docs/dev/TechnicalDebt.md: #3592 (d694aac7) added a "Socket error numbers" bullet right after the poll bullet this PR rewrites; the code files merge cleanly, and the obvious resolution is to keep this PR's poll bullet followed by main's new bullet. #3644 has the same conflict. It now blocks more titles: with #3494 applied, PSXS5 (PPSA97510) also stops at what(): poll: descriptor 6 is not a socket, in addition to ProsperoTV (PPSA99003) and ProsperoRadio (PPSA99001) from the third catalog run.

@pushkarreddyy
pushkarreddyy force-pushed the feat/libkernel-poll-files branch from e8d1238 to 5bf2128 Compare October 12, 2026 02:06
@pushkarreddyy

Copy link
Copy Markdown
Contributor Author

Hi @screamm and @adriadam10,

Thank you for the heads-up and validation on Windows!

The requested rebase onto latest origin/main (d371ed3) is now complete on commit 5bf2128:

  • Cleanly resolved the docs/dev/TechnicalDebt.md conflict by placing this PR's poll bullet followed by main's fix(libkernel): map host socket errors to guest errno #3592 Socket error numbers bullet as suggested.
  • C++ source files apply cleanly with 0 comments and pass ools/check_conventions.py --base origin/main.
  • Unblocks PSXS5 (PPSA97510), ProsperoTV (PPSA99003), and ProsperoRadio (PPSA99001) from poll: descriptor N is not a socket.

Ready for review and merge. Thank you!

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@pushkarreddyy
pushkarreddyy force-pushed the feat/libkernel-poll-files branch from 5bf2128 to 5dbe363 Compare October 12, 2026 02:48
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@screamm

screamm commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Heads-up from a Windows validation attempt on the rebased head: 5dbe3637 (base 6253883d) no longer merges onto main 2ccbd376. The only conflict is Stdio.cpp in close_nid_postfix, with #3923 (merged as 5fe4bebe): this PR has File::ForgetPipeEnd(d); return _close(d); where main now has return WithoutParameterHandler([d] { return ::_close(d); });. The resolution is to keep File::ForgetPipeEnd(d); followed by main's WithoutParameterHandler return. Udp.cpp and TechnicalDebt.md merge cleanly. I'll rerun the Windows build, guest_poll 3/3, the suite and PSXS5/ProsperoTV/ProsperoRadio once it is rebased.

@pushkarreddyy
pushkarreddyy force-pushed the feat/libkernel-poll-files branch from 5dbe363 to b16820c Compare October 12, 2026 06:36
@pushkarreddyy

Copy link
Copy Markdown
Contributor Author

Calling on @adriadam10 and @MarcZX100 for review clearance / merge:

This carried branch for #3521 is fully rebased and verified on both platforms:

Ready for review clearance and merge! Thank you!

@babyhuey

Copy link
Copy Markdown
Contributor

Update after #4030 (provoking-vertex fix) merged: on plain main d592d54, Windows 11 (WinLibs GCC 15.2, Release), ProsperoTV (PPSA99003) no longer hits the AGC provoking-vertex throw. Its only stop now is the one this PR fixes:

[debug:0] [TV] menu open session=1
[libc] unhandled exception 'St13runtime_error' thrown from 00007ffebbdcc7cb
terminate called after throwing an instance of 'std::runtime_error'
  what():  poll: descriptor 4 is not a socket

Earlier I ran this branch stacked with openat (#3968, since merged), and ProsperoTV went past poll to Vulkan device ready on both systems, so on Windows this PR is now all that stands between ProsperoTV and rendering. Stremio Plus and PShare, which were also blocked by the provoking-vertex throw, now render until the timeout on main.

@pushkarreddyy
pushkarreddyy force-pushed the feat/libkernel-poll-files branch from 0d23a93 to c97c226 Compare October 12, 2026 16:23
@pushkarreddyy

Copy link
Copy Markdown
Contributor Author

@screamm @babyhuey Rebased cleanly on latest origin/main (2a5eca1):

Ready for review clearance and merge!

@pushkarreddyy

Copy link
Copy Markdown
Contributor Author

Calling on @oneandonlydean, @adriadam10, @MarcZX100, @babyhuey, and @screamm for final merge review:

This PR has been ready, fully rebased on latest origin/main (2a5eca11c), and passing all CI checks 100% green. It unblocks major progress across multiple titles:

  • Unblocks Rendering for ProsperoTV (PPSA99003): As confirmed by @babyhuey on Windows 11, following the merge of fix(recompiler): read P10 of a flat input as the provoking vertex #4030, ProsperoTV no longer hits the provoking-vertex throw and is solely halted on this PR (poll: descriptor 4 is not a socket). Merging this PR is all that stands between ProsperoTV and full rendering!
  • Dual-Platform Empirical Verification:
    • Windows 11: @screamm verified that all 4 titles (PSXS5 PPSA97510, SwanStation PPSA98510, ProsperoTV PPSA99003, ProsperoRadio PPSA99001) advance past the poll stop, with 604/606 tests passing.
    • Linux: @blawesom verified 832/832 full suite tests passing on CachyOS / GCC / RADV.
  • Clean Health: Rebased on 2a5eca11c, 0 merge conflicts, authorship attributed to screamm <davidrydgren@gmail.com>, 0 comments in C++, all CI checks passing green.

Ready for review clearance and merge! Thank you everyone for your assistance and testing!

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@pushkarreddyy
pushkarreddyy force-pushed the feat/libkernel-poll-files branch from c97c226 to 2ff6c77 Compare October 12, 2026 18:43
milescoviello pushed a commit to milescoviello/AnyPS5 that referenced this pull request Oct 12, 2026
ProsperoRadio (PPSA99001) stops at 33.7 s on Windows, with boykopovar#3649
applied so that it gets past poll, on the throw from boykopovar#3840:

    what():  fcntl: record locks are not implemented on Windows, command=12, fd=3

F_GETLK, F_SETLK, F_SETLKW and the F_OGETLK, F_OSETLK and F_OSETLKW
forms now follow FreeBSD 11.4's kern_fcntl and lf_advlockasync
(8c639945): an SEEK_CUR start is resolved against the descriptor offset
(EOVERFLOW past OFF_MAX), F_RDLCK needs read access and F_WRLCK write
access (EBADF), another type is EINVAL, and the range is checked against
the file size for SEEK_END (EINVAL for a negative start or an unknown
whence, EOVERFLOW past OFF_MAX). The guest is one process, and
lf_blocks never lets locks of one owner conflict, so whichever
descriptor or thread asks, F_SETLK and F_SETLKW succeed without waiting
and F_GETLK reports F_UNLCK, as on the console. Nothing is held on the
host: Windows byte-range locks are mandatory and would fail the guest's
own reads and writes through other descriptors. A lock from the end of
a directory throws.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@oneandonlydean oneandonlydean self-assigned this Oct 12, 2026
screamm and others added 2 commits October 13, 2026 00:19
ProsperoTV (PPSA99003) stops in poll on current main; its log
download0/profiles/10000000/logs/app.log ends with:

    terminate called after throwing an instance of 'std::runtime_error'
      what():  poll: descriptor 3 is not a socket

Descriptors below the socket range are now answered on the host through
the descriptor helper of the select work (File/src/DescriptorPoll.cpp,
copied unchanged from screamm:feat/libkernel-select-files 73418c7), so
poll and select agree. Regular files, directories and anonymous shared
memory report the requested POLLIN, POLLRDNORM and POLLOUT at once
(FreeBSD 11 vop_stdpoll and poll_no_poll); pipes, terminals and other
character devices are polled on the host on Linux and throw naming the
kind on Windows. A closed descriptor reports POLLNVAL and POLLHUP
clears POLLOUT (pollscan). An array with sockets and host descriptors
does not wait once a host descriptor is ready and otherwise waits on
its sockets in 100 ms slices within the one timeout. More than 1024
descriptors throw, since FreeBSD's EINVAL also depends on the unknown
maxfilesperproc (kern_poll). Sources: freebsd-src release/11.4.0
8c639945a44588f6cfdddfb057bb5aad88735da0, sys/kern/sys_generic.c,
vfs_default.c, kern_descrip.c and uipc_shm.c.

Descriptor 3 is a pipe, so on Windows the title still stops at that
call, now with "poll on descriptor 3 (Windows pipe) not implemented";
on Linux the pipe is polled on the host.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ProsperoTV (PPSA99003) polls a pipe made by pipe() as descriptor 3.
After the previous commit it stopped there on Windows with:

    terminate called after throwing an instance of 'std::runtime_error'
      what():  poll on descriptor 3 (Windows pipe) not implemented

pipe() now records which end each Windows descriptor is, and dup,
dup2, close and sceKernelClose keep the record. The descriptor helper
answers a recorded read end from PeekNamedPipe: POLLIN and POLLRDNORM
while bytes are buffered, and POLLIN, POLLRDNORM and POLLHUP once
the writer is gone (ERROR_BROKEN_PIPE), as FreeBSD 11's pipe_poll
reports at end of file. A write end reports nothing for read events,
as pipe_poll does for an end without FREAD, and throws for POLLOUT,
since the host does not report the free space. Pipes not made by
pipe() still throw. Pipes join the 100 ms slice loop, so timeouts
are honoured. Source: freebsd-src release/11.4.0
8c639945a44588f6cfdddfb057bb5aad88735da0, sys/kern/sys_pipe.c.

With this change PPSA99003 reaches its menu ("menu ready
display=3840x2160") and is still running after 60 s; its log ends with:

    [videoout] presentation failed: AGC graphics: last provoking vertex with explicit per-vertex flat interpolation is unsupported

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@pushkarreddyy
pushkarreddyy force-pushed the feat/libkernel-poll-files branch from 2ff6c77 to d1274c3 Compare October 12, 2026 18:50
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@babyhuey babyhuey mentioned this pull request Oct 12, 2026
9 tasks done
Lorkydey pushed a commit to Lorkydey/AnyPS5 that referenced this pull request Oct 12, 2026
Three catalog titles stop on Windows when they poll a guest socket for
POLLPRI|POLLOUT to see whether a non-blocking connect has completed:

- PPSA97510 PSXS5 (socket 0x10000002, thread gamedb, 13 s):
  what():  poll: POLLPRI is not supported by WSAPoll
- PPSA98510 SwanStation (sockets 0x10000003/0x10000002, threads gamedb
  and update): what():  poll: POLLPRI is not supported by WSAPoll
- PPSA99003 ProsperoTV ({0x10000001, POLLPRI|POLLOUT} at 5.3 s):
  what():  poll: POLLPRI is not supported by WSAPoll

FreeBSD's sopoll_generic (sys/kern/uipc_socket.c, freebsd-src 8c639945)
reports POLLPRI and POLLRDBAND alike, only while out-of-band data is
pending (so_oobmark or SBS_RCVATMARK). WSAPoll rejects POLLPRI in events
with WSAEINVAL but reports pending urgent data as POLLRDBAND, so on
Windows the guest POLLPRI is now asked of WSAPoll as POLLRDBAND and
POLLIN as POLLRDNORM (Winsock's POLLIN includes POLLRDBAND, which would
report urgent data as readable). Measured on this host: WSAPoll reports
POLLRDBAND after a peer's send(MSG_OOB), waits for it, and clears it once
the byte is read with MSG_OOB. Linux keeps polling POLLPRI on the host.

select needs no change: libkernel's select passes exceptfds as Urgent to
the libSceNet poller, which already asks WSAPoll for POLLRDBAND, and it
does not take libkernel guest sockets on either host.

The guest send and recv refuse MSG_OOB, so urgent data only comes from a
peer outside the guest's sockets; guest_poll now sends it from a host
socket and checks that a connected pair and a non-blocking connect
report POLLOUT and not POLLPRI. TechnicalDebt records where Winsock's
answer differs from FreeBSD's once the stream passes the mark.

Depends on boykopovar#3649 (poll on file descriptors), whose two commits this
branch carries, since the titles reach this stop only with it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@MarcZX10

Copy link
Copy Markdown
Contributor

One review dependency changed since the earlier duplicate check: #4391 is now the low-descriptor socket change, and it edits Udp.cpp where this PR also adds mixed socket/file polling. Before I can clear this carry, please coordinate the merge order or stack one branch on the other and validate the combined result. The existing #3644 duplicate also still needs a maintainer choice; both are currently presented as equivalent fixes for #3521.

renzipego-cpu pushed a commit to renzipego-cpu/AnyPS5 that referenced this pull request Oct 12, 2026
ProsperoRadio (PPSA99001) stops at 33.7 s on Windows, with boykopovar#3649
applied so that it gets past poll, on the throw from boykopovar#3840:

    what():  fcntl: record locks are not implemented on Windows, command=12, fd=3

F_GETLK, F_SETLK, F_SETLKW and the F_OGETLK, F_OSETLK and F_OSETLKW
forms now follow FreeBSD 11.4's kern_fcntl and lf_advlockasync
(8c639945): an SEEK_CUR start is resolved against the descriptor offset
(EOVERFLOW past OFF_MAX), F_RDLCK needs read access and F_WRLCK write
access (EBADF), another type is EINVAL, and the range is checked against
the file size for SEEK_END (EINVAL for a negative start or an unknown
whence, EOVERFLOW past OFF_MAX). The guest is one process, and
lf_blocks never lets locks of one owner conflict, so whichever
descriptor or thread asks, F_SETLK and F_SETLKW succeed without waiting
and F_GETLK reports F_UNLCK, as on the console. Nothing is held on the
host: Windows byte-range locks are mandatory and would fail the guest's
own reads and writes through other descriptors. A lock from the end of
a directory throws.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@oneandonlydean

Copy link
Copy Markdown
Collaborator

#3644 is merged for #3521, so this one doesn't go in as it is. The titles here poll a pipe next to their sockets. #3644 puts that pipe into the same host poll as the sockets on Linux and checks it every 1 ms on Windows; this one checks it between 100 ms socket waits on both hosts (HostPollSliceMilliseconds, Udp.cpp), and on Windows throws for POLLOUT on a write end. It also hands back the host's answer for descriptors it doesn't know: a kqueue descriptor is /dev/null on the host, so on Linux poll reports it readable at once.

What is left here is regular files, directories and shared memory, and the 1024 limit. Which title polls one of those? With the ID and the log line, open that part as its own PR on main; otherwise I'll close this.

@screamm could you run the four titles on main now? Only PPSA99003 and PPSA99288 had a run on #3644.

@pushkarreddyy

Copy link
Copy Markdown
Contributor Author

@oneandonlydean @MarcZX100 Understood — all four catalog titles (PPSA97510, PPSA99288, PPSA99004, PPSA99003) as well as PPSA99902 in #3521 were polling their wakeup pipe (Curl_wait_ms / event pipe) alongside sockets, which is now covered on main by #3644 (4430780bd, verified by @babyhuey in #4525).

No title on main currently stops on poll: descriptor <N> is neither a socket nor a pipe for a regular file, directory, or shared memory descriptor. Closing this PR in favor of #3644; if a title reaches poll on a regular file or directory descriptor on main, we will open a dedicated PR with its runtime log line.

oneandonlydean pushed a commit that referenced this pull request Oct 13, 2026
Three catalog titles stop on Windows when they poll a guest socket for
POLLPRI|POLLOUT to see whether a non-blocking connect has completed:

- PPSA97510 PSXS5 (socket 0x10000002, thread gamedb, 13 s):
  what():  poll: POLLPRI is not supported by WSAPoll
- PPSA98510 SwanStation (sockets 0x10000003/0x10000002, threads gamedb
  and update): what():  poll: POLLPRI is not supported by WSAPoll
- PPSA99003 ProsperoTV ({0x10000001, POLLPRI|POLLOUT} at 5.3 s):
  what():  poll: POLLPRI is not supported by WSAPoll

FreeBSD's sopoll_generic (sys/kern/uipc_socket.c, freebsd-src 8c639945)
reports POLLPRI and POLLRDBAND alike, only while out-of-band data is
pending (so_oobmark or SBS_RCVATMARK). WSAPoll rejects POLLPRI in events
with WSAEINVAL but reports pending urgent data as POLLRDBAND, so on
Windows the guest POLLPRI is now asked of WSAPoll as POLLRDBAND and
POLLIN as POLLRDNORM (Winsock's POLLIN includes POLLRDBAND, which would
report urgent data as readable). Measured on this host: WSAPoll reports
POLLRDBAND after a peer's send(MSG_OOB), waits for it, and clears it once
the byte is read with MSG_OOB. Linux keeps polling POLLPRI on the host.

select needs no change: libkernel's select passes exceptfds as Urgent to
the libSceNet poller, which already asks WSAPoll for POLLRDBAND, and it
does not take libkernel guest sockets on either host.

The guest send and recv refuse MSG_OOB, so urgent data only comes from a
peer outside the guest's sockets; guest_poll now sends it from a host
socket and checks that a connected pair and a non-blocking connect
report POLLOUT and not POLLPRI. TechnicalDebt records where Winsock's
answer differs from FreeBSD's once the stream passes the mark.

Depends on #3649 (poll on file descriptors), whose two commits this
branch carries, since the titles reach this stop only with it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
RINNECODER added a commit to RINNECODER/AnyPS5 that referenced this pull request Oct 13, 2026
#467)

* fix(libc): return the default quiet NaN from the strtod family

C17 7.22.1.3 and 7.29.4.1.1 interpret NAN(n-char-sequence) as a quiet
NaN. With MinGW-w64, std::strtod, strtof and strtold are mingw-w64's
gdtoa functions, which copy the hex digits into the significand
without the quiet bit, and for long double without the x87 integer
bit: strtod("nan(0x123)") returned the signaling NaN
0x7ff0000000000123 and strtold a pseudo-NaN. A payload whose only set
bit is the implicit or x87 integer bit gave infinity:
strtof("nan(0x800000)"), strtod("nan(0x10000000000000)") and
strtold("nan(0x8000000000000000)") returned +inf. glibc returns quiet
NaNs that keep the payload.

C17 7.12.11.2p2 makes nan("n-char-sequence") equivalent to
strtod("NAN(n-char-sequence)", NULL), and nan and nanf already return
the console's fixed quiet NaNs, ignoring the tag. ParseFloat, which
strtod, strtof, strtold, atof and the wide variants share, now returns
the same values, 0x7ff8000000000000 and 0x7fc00000, negated after a
minus sign, on Windows and Linux. strtold returns the x87 default
quiet NaN, since no console nanl was observed.

(cherry picked from commit aa4a9b4)

* fix(libc): clear exhausted strtok continuation state

(cherry picked from commit 3cb4347)

* test(libc): cover exhausted tokenizer state

(cherry picked from commit 0950b19)

* fix(libc): terminate truncated wcsxfrm results

(cherry picked from commit 22d03d4)

* refactor(libc): place the NaN helpers and test includes apart from neighbouring changes

(cherry picked from commit c55f377)

* fix(libkernel): fail lseek on a pipe with ESPIPE on Windows

(cherry picked from commit 61fbec8)

* fix(libc): append through a descriptor opened by fdopen in an append mode on Windows

(cherry picked from commit dbbd6d5)

* fix(libkernel): throw for unsupported directory entry names

(cherry picked from commit d31e283)

* fix(libc): keep the host standard handles when a guest replaces descriptor 0, 1 or 2 on Windows

(cherry picked from commit c226541)

* feat(libc): implement floor

(cherry picked from commit f8e2c64)

* fix(libc): keep host diagnostics on stderr when a guest redirects it on Linux

On Linux a guest stderr redirect also moves the host's: guest
descriptors are host descriptors, and the guest stderr stream wraps the
host stderr FILE. After dup2(fd, 2), or freopen(path, mode, stderr) with
full buffering, the libc terminate report, the host fprintf(stderr)
diagnostics and libstdc++'s terminate message go into the title's pipe
or file, and abort() discards what is still buffered. RetroArch
(PPSA99169) reopens stderr onto app0/trace.txt with full buffering, so
its stop on main left no message anywhere.

Before the first guest redirect of descriptor 2 (libkernel dup2, libc
freopen of a stream on descriptor 2), keep a close-on-exec duplicate of
the host descriptor 2 and point the host stderr at an unbuffered stream
on it. The guest stream keeps its own FILE and follows the redirect.
The libc terminate report writes to the kept descriptor with write()
instead of the stderr stream, and libkernel's sceKernelDebugOutText uses
the same kept descriptor.

(cherry picked from commit 438d410)

* feat(libkernel): implement sceCoredumpGetStopInfoCpu

PPSA34063 (NHL 27) calls it with a 16-byte buffer outside a coredump
handler and expects 0x81180003 there. The registered handler is never
invoked, so every call is outside one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit d04f5d6)
(cherry picked from commit 02ed289)

* fix(libc): replace an open or read-only destination in rename on Windows

(cherry picked from commit 69b9d18)

* fix(libc): fail fseek and ftell on a pipe with ESPIPE on Windows

(cherry picked from commit 7aabb90)

* fix(libc): check for a pipe on every stream seek on Windows

The pipe check cached its first answer in the FileStream, so a stream
first used on a regular file stayed classified as a file after its
descriptor was replaced with a pipe (dup2 onto fileno(stream)), and a
later fseek reached the C runtime again and dropped buffered bytes.
fseeko and ftello now ask GetFileType on each call, as lseek on a pipe
does since boykopovar#4670, and FileStream no longer keeps the state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 0dda76b)

* fix(libkernel): getsockname on an unbound socket returns the zero address on Windows

FreeBSD's in_getsockaddr and in6_getsockaddr succeed for a socket that has no
local address and return the wildcard address with port 0. Winsock fails
getsockname with WSAEINVAL until the socket is bound, which the guest saw as
EINVAL. Return the zero address of the socket's family for that error.

(cherry picked from commit 0438621)

* feat(libc): implement _Mtx_init_with_name

(cherry picked from commit ab4ccad)

* feat(libc): implement wcsftime

PS5MC (PPSA99420) imports wcsftime (XbVXpf5WF28, aerolib) as the last
absent libSceLibcInternal import in its registry order (index 481), so
its predicted stop is:

    FAIL: unresolved ELF import XbVXpf5WF28 from libSceLibcInternal.prx

The stop is predicted from the import order, not observed in a run.

wcsftime follows FreeBSD 11.4 lib/libc/locale/wcsftime.c (8c639945):
the wide format is converted with wcsrtombs, strftime fills a buffer of
maxsize * MB_CUR_MAX bytes limited to maxsize, and mbsrtowcs converts
the result back. A format unit that the single-byte C locale of
lib/libc/locale/none.c cannot encode returns 0 with EILSEQ, a maxsize
whose product with MB_CUR_MAX overflows returns 0 with EINVAL, and an
empty or overflowing result or a null buffer returns 0 with errno
unchanged; the ERANGE or EINVAL set by the Windows CRT's strftime is
discarded. A null format or tm throws, as FreeBSD dereferences it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 78ffdf0)

* fix(libc): hand out the unwind cursor table through a _nid_no_patch export

_Unwind_Context took its cursor table from LibcUnwind::CursorSlots, a C++
data symbol of libc. On Windows LibcUnwind::Frame holds an _Unwind_Context,
so libSceAgcDriver, which builds frames for its worker sampler, imported
_ZN10LibcUnwind11CursorSlotsE from libc.prx. The NID patcher renames that
export in the patched libc and leaves the import alone, so the patched
libSceAgcDriver, libSceAgc and libSceVideoOut failed to load with error 127
and patched_libraries failed. The table is now file-local and the context
reads it through UnwindCursorSlots_nid_no_patch, which keeps its name on
both sides.

(cherry picked from commit 3a9cc63)

* fix(libc): print NaN without a sign in the guest printf formatter

The guest formatter handed NaN to the host's snprintf, which prints
-nan for a negative NaN and +nan or " nan" with the + and space flags.
FreeBSD 11's vfprintf clears the sign of every NaN and prints nan (NAN
for the upper-case conversions), keeping the width and the - flag and
ignoring 0. The formatter now does the same for a, e, f and g and
their long double forms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VZWLdTjf1S57iLgn2rcaFb
(cherry picked from commit 13444c8)

* feat(libc): implement atanhf

Dusklight (PPSA99305) imports atanhf (cPGyc5FGjy0) from
libSceLibcInternal.prx; the libc.prx it bundles only has a zero-return
stub for it.

The implementation follows the atanhf of the libc.prx bundled with
PPSA28319 (0x438a0), read from its disassembly: FreeBSD msun's
e_atanhf.c calling msun's s_log1pf.c, both as of 59bc2f09 (stable/9,
the revision the sinhf port took expm1f and expf from). The log1pf
paths for the positive arguments atanhf passes are inlined, as the
exported log1pf is still the host's. For |x| > 1, the infinities and
NaN, Sony's error helper raises FE_INVALID and sets errno to EDOM
before returning (x - x) / (x - x); for |x| = 1 it sets errno to
ERANGE before returning x / 0. Other arguments leave errno alone.

Running that code from the title's libc.prx on a Windows host gives
the same bits, errno and floating-point exceptions as the built
libc.prx for all 2^32 arguments, and msun's own e_atanhf.c and
s_log1pf.c built with the host compiler give the same bits. With the
host log1pf instead of the msun one, 4.7% of the arguments in [0, 1)
differ. guest_math pins bits for every branch reachable from atanhf,
both signs, and the errno and exception behaviour.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 3fe04d4)

* feat(libc): implement _Cnd_timedwait

(cherry picked from commit 572d330)

* fix(libc): match FreeBSD acosf errno

acosf returned 0xffc00000 (errno 33) for 2.0 (0x40000000), where FreeBSD
lib/msun/src/math.h returns 0xffc00000 (errno 0).

It now returns the FreeBSD result for that case. A guest test covers it
and fails on main.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
(cherry picked from commit 64e244e)

* fix(libc): keep the acosf result and leave errno unchanged

The previous commit replaced the out-of-range result with the default
quiet NaN 0x7fc00000, but main and FreeBSD e_acosf.c return 0xffc00000.

acosf now calls the host and restores errno, so only errno differs from
main. The guest test pins the result bits for 2.0f and -2.0f and keeps
the in-range case acosf(0.5f).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
(cherry picked from commit 988d304)

* fix(libc): honor openlog identity and facility

(cherry picked from commit 653c544)

* docs(libc): record syslog tag fallback gap

(cherry picked from commit 7313cf5)

* test(libc): match syslog PID formatting

(cherry picked from commit 81f727c)

* fix(libkernel): harden DirectMemory pool bounds and rollback

(cherry picked from commit 4f87ac0)

* feat(libc): implement wcscat

(cherry picked from commit cd0e9dc)

* feat(libc): implement generic error category messages

(cherry picked from commit e3cef33)

* fix(libc): reject invalid setlocale categories

(cherry picked from commit 099fa80)
(cherry picked from commit 5eb99f8)

* fix(libc): validate guest setlocale categories

(cherry picked from commit 2ec20db)

* fix(libc): drop unused clocale include

Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 1a0de9e)

* feat(libc): implement __powidf2

The H+8UBOwfScI import was a throwing stub (libcCyberUnknown08). It is
the NID of "__powidf2", the double-precision integer-power helper that
complements __powisf2.

(cherry picked from commit b4e2ee0)

* fix(libc): export __cxa_thread_atexit

(cherry picked from commit 90c64af)

* fix(libc): ignore the guest DSO of thread atexit on Windows in the shared bridge

MinGW's __cxa_thread_atexit asserts dso is null or its own __dso_handle, so every guest export that forwards a guest module pointer needs the null rule, not only LibcInternalExtCxaThreadAtexit. The test now passes a non-host DSO on Windows too.

Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 9c383e3)

* test(libc): allow the __cxa_thread_atexit export to call the MinGW registration

Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 1ab578a)

* fix(libkernel): place guest thread stacks inside the application area

On Linux, glibc maps the stack of every guest thread near the top of the
host address space (around 0x7fff00000000). On the console, application
stacks lie inside the application area below 0xFC00000000, and guest code
relies on that: ChakraCore's garbage collector indexes a 4 MiB table with
address >> 18, so it only covers addresses below 1 TiB and reports
Js::OutOfMemoryException for a stack above it.

Map each guest thread's stack with DoMapAnon, which allocates from the
guest arena, behind a PROT_NONE guard page, and pass it to pthread_attr_setstack.
The stack is freed after a join; the stack of a detached thread is freed once its
host thread is gone from /proc/self/task.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 7637cac)

* fix(libkernel): protect host-only guest stack pages

(cherry picked from commit 9b6e7f6)

* test(libkernel): check the host-only stack guard on Linux only

Windows guest threads keep their normal stacks, so there is no host-only guard page below the guest stack to query.

(cherry picked from commit 7458574)

* feat(libc): record traced import calls on Windows

TraceImport_nid_no_patch wraps a function of a library named in
APS5_TRACE_CALLS in a thunk that records the import, the thread and
the caller in a ring and counts the call, then jumps to the function.
One target keeps one thunk, so function pointers compare equal. The
crash and abort reports print the last 64 calls and the 32 most called
imports. Nothing calls TraceImport_nid_no_patch yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 3953a8d)

* fix(libc): choose the acosf NaN bits instead of the host libm

FreeBSD msun e_acosf.c returns (x-x)/(x-x) for |x| > 1 and NaN inputs: the
x86 default NaN 0xffc00000, or the quieted input NaN. std::acos left it to the
host libm, and guest_math failed on the runner's glibc 2.39.

Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 0265f33)

* test(libc): cover wide transform output bounds

(cherry picked from commit 79d88af)

* feat(libkernel): implement fcntl record locks on Windows

ProsperoRadio (PPSA99001) stops at 33.7 s on Windows, with boykopovar#3649
applied so that it gets past poll, on the throw from boykopovar#3840:

    what():  fcntl: record locks are not implemented on Windows, command=12, fd=3

F_GETLK, F_SETLK, F_SETLKW and the F_OGETLK, F_OSETLK and F_OSETLKW
forms now follow FreeBSD 11.4's kern_fcntl and lf_advlockasync
(8c639945): an SEEK_CUR start is resolved against the descriptor offset
(EOVERFLOW past OFF_MAX), F_RDLCK needs read access and F_WRLCK write
access (EBADF), another type is EINVAL, and the range is checked against
the file size for SEEK_END (EINVAL for a negative start or an unknown
whence, EOVERFLOW past OFF_MAX). The guest is one process, and
lf_blocks never lets locks of one owner conflict, so whichever
descriptor or thread asks, F_SETLK and F_SETLKW succeed without waiting
and F_GETLK reports F_UNLCK, as on the console. Nothing is held on the
host: Windows byte-range locks are mandatory and would fail the guest's
own reads and writes through other descriptors. A lock from the end of
a directory throws.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 43ffba8)

* feat(libkernel): accept MADV_PROTECT advisory hint in madvise

(cherry picked from commit 59bd0c1)

* feat(libkernel): implement lutimes

(cherry picked from commit 8d08caa)

* fix(libkernel): validate CPU stop-info buffers and cover handler state

(cherry picked from commit c18daed)

* feat(libkernel): implement pthread_atfork

pthread_atfork (U9t5kJAWPnA, aerolib) appends the prepare, parent and
child handlers to a process-wide list under a lock and returns 0, or
ENOMEM when the entry cannot be allocated, as FreeBSD 11.4's
_pthread_atfork does (lib/libthr/thread/thr_fork.c:78-100, freebsd-src
8c639945a44588f6cfdddfb057bb5aad88735da0). Null handlers are accepted;
FreeBSD's fork skips them. The handlers never run: fork
(libkernel_sys) throws and vfork is absent, so no child process is
created. The list is kept, in registration order, for a later fork
(PthreadAtforkHandlers_nid_no_patch); recorded in TechnicalDebt.

XPSemu (PPSA97358) calls it from a constructor, before main
(ZiZc3/XPSemu 8eec07b4, util/rcu.c:488-495):

    static void __attribute__((__constructor__)) rcu_init(void)
    {
        smp_mb_global_init();
    #ifdef CONFIG_POSIX
        pthread_atfork(rcu_init_lock, rcu_init_unlock, rcu_init_child);
    #endif
        rcu_init_complete();
    }

so a throwing export would stop the title before main. Predicted stop
removed (registry index 255, not run):
FAIL: unresolved ELF import U9t5kJAWPnA from libkernel.prx

guest_pthread_atfork checks registration order, null handlers,
concurrent registration from four threads and that no handler runs.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit f37bccf)
(cherry picked from commit e8fd542)

* feat(libkernel): add mlockall

mlockall (x7g7Ebeo8-U, aerolib) follows FreeBSD 11.4's sys_mlockall
(sys/vm/vm_mmap.c:1067-1131, freebsd-src
8c639945a44588f6cfdddfb057bb5aad88735da0) for the flag check: 0 or
bits outside MCL_CURRENT (1) and MCL_FUTURE (2) fail with EINVAL. The
title process is taken to pass priv_check(PRIV_VM_MLOCK), as mlock
already does.

Valid flags throw. MCL_FUTURE would need every later guest and host
mapping to be locked; nothing in the mapping paths does that, and
passing it to the host would make later host allocations fail above
the host RLIMIT_MEMLOCK. MCL_CURRENT would have to lock the whole
process, which on AnyPS5 also holds host stacks, heaps, modules and
driver mappings (sceKernelVirtualQuery reports them as guest memory),
with ENOMEM above a guest RLIMIT_MEMLOCK that is not known (getrlimit
throws for it). mlock pins host pages (VirtualLock, mlock) range by
range and keeps no record, so there is no state to extend. Recorded
in TechnicalDebt.

XPSemu (PPSA97358) calls it only with -overcommit mem-lock=on
(ZiZc3/XPSemu 8eec07b4, os-posix.c:330-355, reached from
system/vl.c:831-835):

    int flags = MCL_CURRENT | MCL_FUTURE;
    ...
    ret = mlockall(flags);
    if (ret < 0) {
        error_report("mlockall: %s", strerror(errno));
    }

and exits on failure, so that option ends in the throw; without it
the title is not affected. Predicted stop removed (registry index 201,
not run):
FAIL: unresolved ELF import x7g7Ebeo8-U from libkernel.prx

guest_mlock checks EINVAL for 0, 4, 5 and -1 and the throw for 1, 2
and 3.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 87f4aa3)
(cherry picked from commit a7ea2bd)

* fix(libc): format strftime and asctime as FreeBSD 11 does

strftime handed most conversions to the host's strftime, which differs
from FreeBSD 11's for E and O modifiers on conversions glibc does not
pair with them (%Ea was printed literally), padding flags on %+ and %v,
years outside 1000 to 9999 (%Y printed 899 and -1 where FreeBSD prints
0899 and -001), and out-of-range fields (%I of hour 100, %u of weekday
8). On Windows the padding flags printed nothing. strftime now follows
FreeBSD 11 strftime.c with the C locale on every host, and asctime
follows FreeBSD 11 asctime.c, padding years to four digits and setting
longer years apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VZWLdTjf1S57iLgn2rcaFb
(cherry picked from commit d0df62b)

* feat(libkernel): return ESRCH and EINVAL for unsupported cpuset affinity targets

Allow calling threads to query and set affinity using their own thread ID in addition to -1. Return ESRCH for non-matching thread or process IDs and EINVAL for invalid level/which arguments instead of throwing NotImplemented, matching FreeBSD cpuset semantics.

(cherry picked from commit 9efabff)

* fix(libkernel): check and keep the scheduling policy of a thread

On a PS5 (firmware 13.60) pthread_setschedparam and
scePthreadSetschedparam accept only SCHED_FIFO and SCHED_RR with a
priority of 256 to 767 or 896 to 959, return EINVAL otherwise, and
keep the policy for pthread_getschedparam. A created thread takes the
policy of explicit scheduling attributes, or its creator's when it
inherits. Here any policy and priority were accepted and SCHED_FIFO
was always reported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5c6a9d2)

* feat(libkernel): implement execv and execve as throwing exports

XPSemu PPSA97358 imports both from libkernel.prx; with the imports ahead
of them covered, its predicted next stops (relink registry order, not an
observed run) are:

  FAIL: unresolved ELF import KaK52lYTBIs from libkernel.prx  (execv, 7 call sites)
  FAIL: unresolved ELF import kdguLiAheLI from libkernel.prx  (execve, 4 call sites)

Today the title stops earlier at the observed
  FAIL: unresolved ELF import aRo9AhFUXcM from libkernel.prx  (sigsetjmp, merged in boykopovar#3486)

As for execvp (boykopovar#2827), the process image cannot be replaced here, so both
throw with the execvp message pattern once FreeBSD 11's execve would start
loading the image (freebsd-src 8c639945, sys/kern/kern_exec.c
exec_copyin_args, do_execve, exec_check_permissions; lib/libc/gen/exec.c
execv passes environ). Before that they fail as FreeBSD does: EFAULT for a
null argument vector or path, ENOENT and ENOTDIR from the lookup as stat
reports it, EACCES for a path that is not a regular file. Paths of
PATH_MAX bytes or more and strings over ARG_MAX throw instead of guessing
the console's limits. The execv calls in XPSemu's sources run in a fork
child (net/tap.c), and its fork fails with ENOSYS (ZiZc3/XPSemu 8eec07b4,
ps5/compat/libc_missing.c, ps5/build-title.sh --defsym).

NIDs computed with tools/nid_names.py and confirmed in aerolib.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 57f0fa3)
(cherry picked from commit 4f1ae1c)

* fix(libkernel): limit execve to unsupported behavior

(cherry picked from commit 77016ca)

* fix(libkernel): keep the execv export and its debt line

The rename to execve dropped execv, which PPSA97358 imports.

Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit cdf4b17)

* feat(libkernel): add clock_settime with FreeBSD argument checks

PS5MC (PPSA99420, Kodi 22) imports clock_settime (d7nUj1LOdDU) from
libkernel.prx, one reference, after sigwaitinfo in its import order.
Predicted stop once the imports ahead of it are covered (not a run):

  FAIL: unresolved ELF import d7nUj1LOdDU from libkernel.prx

The NID is computed with tools/nid_names.py and matches aerolib.

Follows FreeBSD 11.4 sys/kern/kern_time.c sys_clock_settime and
kern_clock_settime (8c639945a44588f6cfdddfb057bb5aad88735da0) for a
root caller: EFAULT for a null time (copyin), EINVAL for any clock but
CLOCK_REALTIME and for a negative tv_sec or a tv_nsec outside 0 to
999999999. A valid CLOCK_REALTIME request throws with the requested
time named, since the host clock must not be set and no guest clock
offset is kept.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

Co-authored-by: David <david@example.com>
(cherry picked from commit ae9978a)

* feat(libkernel): report the host SoC and CPU temperature

PPSA99058 and PPSA99420 import sceKernelGetCpuTemperature and sceKernelGetSocSensorTemperature and stop at start-up on main. Read the host CPU/package, board and NVMe sensors (hwmon/thermal on Linux, the ACPI thermal zones and the storage temperature property on Windows) and report an unsupported sensor with EINVAL.

(cherry picked from commit 0f73f5f)

* feat(libkernel): answer the coredump user-file attach calls

sceCoredumpAttachUserFile (5nc2gdLNsok) and
sceCoredumpAttachMemoryRegionAsUserFile (MEJ7tc7ThwM) get the
signatures of Orbital's db_types.json (cc408367) and SharpProspero's
KernelSystem.cs (5dfdb4b0): (uint32_t userValue, const char* path) and
(uint32_t userValue, const void* mem, size_t size, const char* name).

The handler is never invoked here, so both return
SCE_COREDUMP_ERROR_NOT_IN_COREDUMP_HANDLER (0x81180003, shadPS4
coredump_error.h e0a46675) and attach nothing; a null path or name and
a null, empty or wrapping region throw because the order of the
console's checks is unknown.

Carried from @screamm with author attribution preserved.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

(cherry picked from commit 204355c)

* feat(libkernel_sys): implement mkdirat, unlinkat, renameat, fchmodat and chroot

Hand-merged from upstream: ec0d61e 55ddffe 2a8e745 9ceb6d1 dc0d316
41b0ca5 e3c1d01 603d94a 7e5bec0 f8a269e. The fork's libkernel_sys
Export.cpp and its test were an older shape of the file, so the upstream
versions were taken whole, together with the RenameGuestPath export in libc
Rename.cpp/General.hpp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(libc): call __dynamic_cast and __cxa_init_primary_exception with the guest ABI

Every other export of the C++ runtime is declared APS5_VABI, but these two
were not. On Windows a title calls them with the System V convention while
they read the Microsoft one, so __dynamic_cast took its fourth argument, the
src2dst hint, as the source pointer: an ordinary downcast (hint 0) returned
null, and the negative hints made it read through an invalid pointer.

guest_dynamic_cast calls both through APS5_VABI declarations, as a title
does, and checks a single-inheritance downcast, a failed cross cast, a cast
of a base object and the header __cxa_init_primary_exception fills in.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit f4be036)

* test(libc): register guest_dynamic_cast beside guest_array_callbacks

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 7154138)

* fix(libc): keep the caller errno when localtime cannot represent a time

Adapted from upstream b1cf014 (POSIX and Windows localtime failure paths;
the Windows year-range handling and its test are not ported).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(libc): implement the float rounding and classification exports

PPSA99611 imports ceilf, floorf, truncf, isnan and isinf from libc.prx and stops at start-up on main. Implement them next to the existing double forms: the rounding results delegate to the standard library like the other float exports, and isnan/isinf reuse the __isnan/__isinf helpers isnanf already uses.

(cherry picked from commit 00f0589)

* fix(libc): build the guest category test and the dynamic_cast registration on macOS

Cast away const on the category vtable entries (Apple clang rejects the
reinterpret_cast), register guest_dynamic_cast once, use duration_cast for the
_Cnd_timedwait deadline (libc++ system_clock is microsecond based), include
unistd.h for the libkernel_sys at-calls, and stub GuestThreadStackHostRangeOverlaps
in the direct memory test harness.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(libs): find the executable directory on macOS

libSceFont and libSceNpEntitlementAccess located the executable
through /proc/self/exe, which macOS does not have, so finding the
system fonts and the entitlements file threw there. Use
_NSGetExecutablePath and resolve the path with
std::filesystem::canonical on macOS. Linux and Windows are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit f30f3e8)

* fix(libSceFont): include vector for the macOS executable lookup

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Yunus Shaikh <75296019+yunusshaikh7@users.noreply.github.com>
Co-authored-by: QRMOE <mohandmahdi44@gmail.com>
Co-authored-by: David <David.Samir.WD@gmail.com>
Co-authored-by: ArjenS-LA <arjensingh@outlook.com>
Co-authored-by: BIGFERRY999 <bigferry24@gmail.com>
Co-authored-by: marshmll <renandasilvaoliveiraandrade@gmail.com>
Co-authored-by: poonasor <rickypoon89@icloud.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: milescoviello <kitslayer29@gmail.com>
Co-authored-by: Hussein Kadhim <husseinkad.dev@gmail.com>
Co-authored-by: Feuris <sebastian6@live.com.ar>
Co-authored-by: David <david@example.com>
Co-authored-by: Dean Galvin <dean.galvin@live.com>
Co-authored-by: Rick <99503318+0xRickx@users.noreply.github.com>
Co-authored-by: Alex <270190108+CouchRiv@users.noreply.github.com>
Co-authored-by: MarcZX100 <marczxrr@gmail.com>
Co-authored-by: Yaash Singhh <YASHVSINGH27+git@GMAIL.COM>
Co-authored-by: Evgeniy Kazarin <evgkaz0@gmail.com>
Co-authored-by: Adrià Franch <adriadam10@gmail.com>
Co-authored-by: Akul Tyagi <69496404+AkulTyagi11@users.noreply.github.com>
Co-authored-by: Cesar Rodriguez <11452991+Tamalero@users.noreply.github.com>
Co-authored-by: codingreapermaps <233954859+codingreapermaps@users.noreply.github.com>
Co-authored-by: screamm <davidrydgren@gmail.com>
Co-authored-by: jagrat Singh <jagratsingh9899@gmail.com>
Co-authored-by: lorkydey <lorky.contact@gmail.com>
Co-authored-by: hugodearaujo <hugoaraujocamara@gmail.com>
Co-authored-by: nabilfp <nabillgithub@gmail.com>
Co-authored-by: Nixitov <Nixitov@users.noreply.github.com>
Co-authored-by: Ahir Barman Maji <191682168+ahir061@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build docs libkernel needs rebase Conflicts with main, rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libkernel: poll throws for non-socket descriptors, first stop of ProsperoTV on main; fix branch ready (files and Windows pipe read ends)

6 participants