Skip to content

feat(libkernel): implement pthread_rwlock_reltimedrdlock_np and pthread_rwlock_reltimedwrlock_np - #9265

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
HQasper:claude/project-thread-6o4na3
Oct 23, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
HQasper:claude/project-thread-6o4na3

Conversation

@HQasper

@HQasper HQasper commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

What

pthread_rwlock_reltimedrdlock_np (dYv-+If2GPk) and pthread_rwlock_reltimedwrlock_np (RRnSj8h8VR4) were missing from libkernel.prx, so a title importing either stopped at load with FAIL: unresolved ELF import ... from libkernel.prx.

  • In libkernel they sit next to the absolute-time pthread_rwlock_timed*lock calls: a zero lock is initialized as by pthread_rwlock_rdlock, then scePthreadRwlockTimedrdlock / scePthreadRwlockTimedwrlock run with the microsecond count and the SCE error is turned into a POSIX error number, the same way pthread_cond_reltimedwait_np maps onto scePthreadCondTimedwait.
  • The throwing copies in libkernel_sys/Export.Discovery.cpp are removed, since check_conventions allows an export in one library only (duplicate-export). An import of these two from libkernel_sys now no longer resolves, as for the other libkernel pthread calls.
  • The signature (rwlock, u32 usec) comes only from shadPS4, which registers one function for each of these NIDs and for its scePthreadRwlockTimed* twin (rwlock.cpp); FreeBSD 11.4 libthr has no such functions. This is recorded in the libkernel debt file.

Tested

Linux (Ubuntu container, GCC, Release, BUILD_TESTING=ON):

  • guest_pthread_rwlock with a new relative-timeout case: passed. It checks a zero lock initialized by both calls, EINVAL after destroy, a shared read beside another reader, ETIMEDOUT after at least 15 ms for a 20 ms timeout and at once for 0 against a reader and a writer, and that a long timeout succeeds once the holder lets go. Breaking the write call (timeout forced to 0) makes it fail.
  • guest_cond_timedwait and guest_kernel_sys (unchanged): passed.
  • After nid_patcher, the patched libkernel.prx exports dYv-+If2GPk and RRnSj8h8VR4 (nm -D).
  • python3 tools/check_conventions.py --base upstream/main: passed.
    Windows 10 (MinGW-w64 GCC 15.2.0 WinLibs x86_64-ucrt-posix-seh r7, Release, BUILD_TESTING=ON), on 923eb03, which has the same implementation; the later commit only drops two test lines and moves the debt entry:
  • guest_pthread_rwlock, guest_cond_timedwait and guest_kernel_sys: 3 of 3 passed.

Not tested: any title. None of the titles checked here import the two NIDs.

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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

Duplicate and overlap check

Checked on 2026-10-21 against upstream main cecb540 and the heads of all 918 open pull requests:

…ad_rwlock_reltimedwrlock_np

Both were missing from libkernel.prx, so a title importing either
(dYv-+If2GPk, RRnSj8h8VR4) failed to load. They take a relative timeout
in microseconds and are scePthreadRwlockTimedrdlock and
scePthreadRwlockTimedwrlock with POSIX error numbers; a zero lock is
initialized as by pthread_rwlock_rdlock. The signature comes from
shadPS4, which registers one function for each NID and its
scePthreadRwlockTimed* twin; FreeBSD 11.4 has no such calls. The throwing
libkernel_sys copies are removed, as an export may live in one library
only. Recorded in the libkernel debt file.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Progress report (d34da5d → 8f13fe7)

📈 System libraries: 42.12% (+0.02%, +2 implemented, -2 removed functions)

✅ 2 implemented
Library Name
libkernel pthread_rwlock_reltimedrdlock_np_nid_postfix
libkernel pthread_rwlock_reltimedwrlock_np_nid_postfix
🗑️ 2 removed
Library Name
libkernel_sys pthread_rwlock_reltimedrdlock_np_nid_postfix
libkernel_sys pthread_rwlock_reltimedwrlock_np_nid_postfix

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 docs/dev/debt/libkernel.md
PR 6044 core/libs/tests/GuestPthreadRwlock.cpp
PR 6149 docs/dev/debt/libkernel.md
PR 6469 docs/dev/debt/libkernel.md
PR 6740 docs/dev/debt/libkernel.md
PR 6830 docs/dev/debt/libkernel.md
PR 6879 docs/dev/debt/libkernel.md
PR 6936 docs/dev/debt/libkernel.md
PR 7049 docs/dev/debt/libkernel.md
PR 7088 docs/dev/debt/libkernel.md
PR 7105 docs/dev/debt/libkernel.md
PR 7121 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7509 docs/dev/debt/libkernel.md
PR 7565 docs/dev/debt/libkernel.md
PR 7653 docs/dev/debt/libkernel.md
PR 8010 docs/dev/debt/libkernel.md
PR 8344 docs/dev/debt/libkernel.md
PR 8373 core/libs/prx/libkernel/Pthread/Posix/Rwlock.cpp
core/libs/tests/GuestPthreadRwlock.cpp
docs/dev/debt/libkernel.md
PR 8520 docs/dev/debt/libkernel.md
PR 8537 docs/dev/debt/libkernel.md
PR 8553 docs/dev/debt/libkernel.md
PR 8658 docs/dev/debt/libkernel.md
PR 9019 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9060 docs/dev/debt/libkernel.md
PR 9109 docs/dev/debt/libkernel.md
PR 9133 docs/dev/debt/libkernel.md
PR 9161 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9322 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9382 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9442 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9561 docs/dev/debt/libkernel.md
PR 9573 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9669 docs/dev/debt/libkernel.md
PR 9693 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md

@harisibrar1 harisibrar1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked against main a6646f8 and shadPS4 rwlock.cpp @3a9f57265d:

  • The NIDs check out: dYv-+If2GPk and RRnSj8h8VR4 hash from the two names.
  • shadPS4 registers the same (rwlock, u32 usec) function for these NIDs and, via ORBIS(...), for scePthreadRwlockTimedrdlock/Timedwrlock. Forwarding to main's scePthreadRwlockTimed*lock(rwlock, KernelUseconds) is therefore consistent, and the error mapping (ETIMEDOUT, EINVAL for a destroyed lock, EDEADLK when the caller holds the write lock) is the same one main's absolute pthread_rwlock_timed*lock already uses.
  • The branch still merges cleanly into current main, and main hasn't touched the rwlock sources or the test since your base. Looks good to me.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

@oneandonlydean oneandonlydean self-assigned this Oct 22, 2026
@oneandonlydean
oneandonlydean merged commit ee8a734 into boykopovar:main Oct 23, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants