AnyPS5/core/libs/prx/libkernel
David 9ef4aa2c40 feat(libkernel): implement kqueue and kevent over the event queue
Cloudberry Kingdom (PPSA23827, #3177) calls kqueue right after start-up
and stopped on the throwing declarations merged with #3337; Palworld's
Discord module (PPSA23126, #2648) imports kevent.

kqueue reserves a host null-device descriptor in the file descriptor
space and registers it as an event queue that reports each ready event
once per call and moves level-triggered ones behind the others, as
kqueue_scan does. close and sceKernelClose close the queue and drop the
descriptor's events from every queue, dup2 drops them for the target,
and dup/dup2 of a kqueue throw, so a reused descriptor number is never
read as a stale kqueue.

kevent follows FreeBSD 11 kern_event.c (release/11.0.1 34bd3475):
kqueue_kevent for the changelist (filter 0 skipped, EV_SYSFLAGS
cleared, EV_ERROR receipts with the errno in data, EV_RECEIPT, the
early return when nevents is exhausted), kqueue_register for EV_ADD,
EV_DELETE, EV_ENABLE, EBADF, ENOENT and EINVAL, kqueue_scan for the
timeout (EINVAL for a bad timespec, zero polls, above INT32_MAX waits
forever) and filt_timerattach, filt_usertouch for the timer and user
filters. Read and write events reuse the guest socket poll of
sceKernelAddReadEvent/WriteEvent.

Throws: other filters, EV_DISABLE, EV_DISPATCH, EV_FORCEONESHOT,
NOTE_LOWAT, EV_CLEAR on a socket, read/write events on non-socket
descriptors or another kqueue, changes to an existing timer (11.0 and
11.4 differ), a NOTE_NSECONDS fraction above one second and a negative
nevents. Recorded in TechnicalDebt.

Test guest_kqueue covers creation and close, timers, a user event
triggered from another thread, read and write events on a socket pair,
EV_ERROR receipts, the timeout and the error cases.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-12 22:36:59 +02:00
..
Aio/src fix(aio): use precise polling sleep 2026-10-11 18:48:18 -04:00
AppMetadata Merge branch 'main' into fix/videoout-high-frame-rate 2026-10-12 11:15:48 -05:00
Apr fix(libkernel): report the target size of symbolic links on Windows 2026-10-12 13:48:56 +05:30
DirectMemory fix(libkernel): create the JIT shared memory backing in one call 2026-10-12 21:59:19 +02:00
Equeue feat(libkernel): implement kqueue and kevent over the event queue 2026-10-12 22:36:59 +02:00
EventFlag/src feat(runtime): timed waits, sync primitive fixes, heap and RTC fixes, unattended-run switches 2026-09-26 19:00:39 -07:00
File feat(libkernel): implement kqueue and kevent over the event queue 2026-10-12 22:36:59 +02:00
Module Merge pull request #4544 from poonasor/feat/libkernel-module-info2 2026-10-13 07:33:08 +13:00
Pthread Merge pull request #4350 from milescoviello/fix/once-reset-on-exit 2026-10-13 04:53:46 +13:00
Semaphore fix(libkernel): report the remaining time from sceKernelWaitSema 2026-10-11 20:09:33 +00:00
Socket Merge pull request #4373 from milescoviello/fix/recvmsg-seqpacket-trunc 2026-10-13 07:22:38 +13:00
SyncOnAddress/src feat(libkernel): wake each listed address in _umtx_op UMTX_OP_NWAKE_PRIVATE 2026-10-11 17:48:06 +00:00
System Merge pull request #3821 from semirkabir/feat/coredump-attach-outside-handler 2026-10-12 22:19:52 +02:00
Time Merge pull request #4466 from babyhuey/feat/libkernel-socid-cpumode 2026-10-13 07:27:28 +13:00
CMakeLists.txt feat(libkernel): implement kqueue and kevent over the event queue 2026-10-12 22:36:59 +02:00
KernelErrors.hpp refactor(kernel): share SCE kernel error codes through KernelErrors.hpp 2026-09-27 13:32:28 +07:00
Unimplemented.cpp feat(libkernel): implement sceKernelGetCpuTemperature 2026-10-12 07:37:44 +02:00