feat(libkernel): implement sem_setname #11267
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11267"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by kallmek3nny on 2026-10-25T23:07:54Z.
What
Implements
sem_setname(sem, name)in libkernel and removes itsNotImplemented_nid_no_patchstub and declaration from libkernel_sys. The call copiesnameinto a newPosixSemaphore::nameunder the semaphore's lock and returns 0. A null or destroyed semaphore returns -1 withEINVALinerrno, as the othersem_*calls do. A nullnamethrows, because the console's result was not measured. FreeBSD has nosem_setname, so the signature follows the libthr*_setname_npcalls and is not confirmed on a console or a title. This is recorded indocs/dev/debt/libkernel.md. Nothing reads the name back yet.Tested
Tested on Windows with an Intel Core i5-14400F. On current
mainI rebuiltlibkernel,libkernel_sys,guest_posix_sem_testsandguest_kernel_sys_tests. Then I ranctest --test-dir build -R "^guest_kernel_sys$|^guest_posix_sem", and all 3 tests passed:guest_kernel_sys,guest_posix_sem_initandguest_posix_sem_post. The extended semaphore test covers renaming, an empty name, a nullname, a null semaphore and a destroyed semaphore. It also checks that renaming keeps the count and leaves the semaphore usable. Not tested on Linux or with a title.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T23:13:04Z.
Review: CHANGES_REQUESTED
The exact-head diff-check and conventions checker pass. I found two points that need clarification before I can approve:
This moves
sem_setname_nid_postfixfromlibkernel_sys(where the existing export stub is registered) intolibkernel, while changing the prototype from parameterless to(void* sem, const char* name). The PR says the signature has not been confirmed on a console or title. Since imports are resolved against a particular PRX/library, a correct implementation under a different library name would not satisfy existing imports, and a guessed arity can mis-handle the call. Please provide evidence for the PS5 library ownership and prototype (for example, the import/export metadata or a checked SDK declaration), or preserve the existing module mapping until verified.The Tested section says the tests were rebuilt on current
main, but the extendedGuestPosixSemtest callssem_setname, which this PR adds and currentmaindoes not declare. Please clarify the exact commit that was built and tested and provide the focused test output. The hosted product-build jobs are skipped, so that evidence is not available from CI.I have not found a duplicate implementation. The progress/conventions/intake checks pass, but these ABI and test-evidence gaps prevent a confident review of the exported behavior.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-27T07:36:40Z.
Review: CHANGES_REQUESTED
Thanks for the PR. @BunnyFl's firmware 13.42 data answers the ABI question and shows the behaviour differs from this implementation:
sem_setname(NID-wUggz2S5yk) is exported bylibkernel, and takes(sem, const char* name). Moving the export and the signature are right.sem_initthe module's first dword is0xffff736d;sem_setnamecallsnamedobj_create(name, sem, 0x206)and stores(id << 16) | 0x736dthere. A secondsem_setnameon the same semaphore returns -1 witherrno35 (EAGAIN) and makes no syscall.Sem.cpp:186-193returns 0 and renames, andGuestPosixSem.cpp:121-122pins that ("semaphore"then""both succeed). The semaphore should be nameable once; later calls should fail withEAGAIN, with a test for it.sem+2, it does not returnEINVAL. Please throw for a nullsem(and keep throwing for a nullname, which the module passes to the kernel unchecked), and drop the null-semaphoreEINVALrow atGuestPosixSem.cpp:133. A destroyed semaphore was not measured: keep it throwing or note it in the debt entry.docs/dev/debt/libkernel.md: update thesem_setnameline to say the name is registered once throughnamedobj_create, that the kernel side is not modelled here, and cite BunnyFl's measurements instead of "not confirmed".docs/dev/debt/libkernel.md) and #10838 (libkernel_sys/include/Api.hpp) conflict; list them on theDepends online or rebase after they land.