Skip to content

feat(libkernel): implement pthread_getthreadid_np - #3442

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
babyhuey:feat/libkernel-pthread-getthreadid-np
Oct 11, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
babyhuey:feat/libkernel-pthread-getthreadid-np

Conversation

@babyhuey

@babyhuey babyhuey commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What

Exports pthread_getthreadid_np (3eqs37G74-s) from libkernel. It returns scePthreadGetthreadid(), the calling thread's ID, which #2184 already made match FreeBSD's pthread_getthreadid_np (TID(curthread) in libthr).

PS5MC (PPSA99420) stops at it on main 99c1c26, now that setcontext (#3421) is in (catalog build, eboot.bin and sce_module/libc.prx unwrapped as #2605 requires; tracked in #1578):

  • Linux: app.elf: symbol lookup error: app.elf: undefined symbol: 3eqs37G74-s
  • with this PR, Linux: app.elf: symbol lookup error: app.elf: undefined symbol: YA0r4LCkfeY (sendfile)
  • with this PR, Windows: FAIL: unresolved ELF import YA0r4LCkfeY (sendfile) from libkernel.prx

@AchrafReyani had a branch for the same function and withdrew it in favour of this one on #1578.

Tested

Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release: guest_thread_self passes 5/5 (--repeat until-fail:5) on both, with no warnings in Thread.cpp or GuestThreadSelf.cpp. The new checks call it on the main thread and on a worker, and require each result to equal that thread's ID from scePthreadGetthreadid and the worker's to differ from the main thread's. check_conventions.py passes.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes

@github-actions

Copy link
Copy Markdown

Progress report (03a84d0 → 2741e96)

➖ System libraries: 85.74% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel pthread_getthreadid_np_nid_postfix

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked on Linux: build and guest_thread_self pass on the PR merged onto main; without the change the test doesn't link. 3eqs37G74-s is pthread_getthreadid_np, it returns the same id as scePthreadGetthreadid (FreeBSD TID(curthread)), and no other open PR touches it. Merging.

@adriadam10
adriadam10 merged commit 22b1782 into boykopovar:main Oct 11, 2026
14 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.

2 participants