Skip to content

feat(libkernel_sys): implement kmq_notify registration - #95

Open
Thimo188 wants to merge 20 commits into
mainfrom
upstream-pr/9302
Open

Thimo188 wants to merge 20 commits into
mainfrom
upstream-pr/9302

Conversation

@Thimo188

@Thimo188 Thimo188 commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Imported from boykopovar/AnyPS5#9302, originally opened by DavidSamir.

Source commit: c045c1e91fe983f7e3e513692110e15b16470953. The import branch preserves this fetched upstream PR snapshot. The description and validation below are copied from upstream; no new code changes or test runs were made for this import. Original reviews, discussions, and attachments remain at the linked upstream PR.


What

Builds on boykopovar#9297 and implements kmq_notify registration in libkernel_sys/Mqueue.cpp, following FreeBSD 11 sys/kern/uipc_mqueue.c (kern_kmq_notify, mqueue_send_notification). Until boykopovar#9297 (and boykopovar#9284 under it) merges, this PR's diff also shows their commits. This PR's own change is the last three commits.

  • Validation, before the descriptor is checked: a sigev_notify other than SIGEV_NONE, SIGEV_SIGNAL or SIGEV_THREAD_ID gives EINVAL, and for the two signal forms a sigev_signo outside 1..128 gives EINVAL.
  • The descriptor: one that isn't a queue gives EBADF, for a NULL sigevent as well.
  • A NULL sigevent: removes only the calling descriptor's own registration; from another descriptor it does nothing and returns 0.
  • Registering: any existing registration on the queue gives EBUSY, even from the same descriptor.
  • When a registration is consumed:
    • at once, on registering, when the queue already holds messages and no receiver waits;
    • by a send that finds no waiting receiver;
    • by a receive that leaves messages behind with no receiver waiting.
  • Closing the owner descriptor removes its registration, through feat(libkernel): implement the unnamed ksem semaphores boykopovar/AnyPS5#9284's close observer.
  • Waiting receivers: the queue now counts them, so a send either wakes a waiting receiver or consumes the notification, as mqueue_send does.

SIGEV_NONE is fully implemented. SIGEV_SIGNAL and SIGEV_THREAD_ID registrations throw, because delivering a guest signal with its sigev_value is not modelled. A debt line records that.

Tested

Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release. This is a CPU-side export, so no GPU is involved.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: feat(libkernel_sys): implement POSIX message queues boykopovar/AnyPS5#9297
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

…elative name

An absolute host temp path is not mapped by the Linux guest resolver.
Found by xXPBSXx on boykopovar#9097.
…lative name

An absolute host temp path is not mapped by the Linux guest resolver.
Found by xXPBSXx on boykopovar#9097.
The PS5 3.20 export lists have ksem_* in libkernel as well as
libkernel_sys, and on Windows a libkernel import never reaches
libkernel_sys, so titles importing them from libkernel did not find
them. Following pipe1os's review on boykopovar#9284, also: ENOSPC from
ksem_init when no descriptor is left, the SEM_MAX limit of 30 with
ENOSPC, and dup/dup2 from a ksem id throwing as for a kqueue.
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 93 core/libs/prx/libkernel/Semaphore/include/Ksem.hpp
core/libs/prx/libkernel/Semaphore/src/Ksem.cpp
core/libs/tests/GuestKernelSysKsem.cpp
PR 94 core/libs/prx/libkernel/Semaphore/include/Ksem.hpp
core/libs/prx/libkernel/Semaphore/src/Ksem.cpp
core/libs/prx/libkernel_sys/Mqueue.cpp
core/libs/tests/GuestKernelSysKsem.cpp
core/libs/tests/GuestKernelSysMqueue.cpp

Exports with a name or library/NID already present in main:

  • ksem_destroy (same library/NID already present: core/libs/prx/libkernel (asSKL30+heA))
  • ksem_getvalue (same library/NID already present: core/libs/prx/libkernel (rOT0UMvtCCA))
  • ksem_init (same library/NID already present: core/libs/prx/libkernel (TEwqtzAmezo))
  • ksem_post (same library/NID already present: core/libs/prx/libkernel (s8gWJrY1W-k))
  • ksem_timedwait (same library/NID already present: core/libs/prx/libkernel (vE+WlomLSh4))
  • ksem_trywait (same library/NID already present: core/libs/prx/libkernel (gVaofuRvLdU))
  • ksem_wait (same library/NID already present: core/libs/prx/libkernel (rQvMIxmFD6A))

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with main, rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants