Skip to content

feat(libkernel): implement pthread_set_name_np - #1872

Closed
TheAggie wants to merge 1 commit into
boykopovar:mainfrom
TheAggie:feat/libkernel-pthread-set-name-np
Closed

TheAggie wants to merge 1 commit into
boykopovar:mainfrom
TheAggie:feat/libkernel-pthread-set-name-np

Conversation

@TheAggie

@TheAggie TheAggie commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

What

pthread_set_name_np was not exported. Quake II (PPSA99007, the homebrew port) calls it.

It renames through the existing scePthreadRename. A null name clears the name, as in FreeBSD. Like FreeBSD's version it returns nothing, so a failure (for example a null thread) is ignored.

Test (guest_thread_self): the main thread's name reads back through scePthreadGetname after a rename, is empty after a null name, and a null thread does nothing.

Related: #1798 implements pthread_getname_np; no overlap.

Tested

Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release.

  • The full suite (485 tests) passes on current main with this PR and four other small libc/libkernel PRs of mine merged together (atol, getprogname, dup2, ctime/rewind, pthread_set_name_np). It was run from the generated CTestTestfile.cmake commands because antivirus blocks ctest.exe on this machine.
  • tools/check_conventions.py --base origin/main passes on this branch alone.

Not tested on Linux or macOS.

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

🤖 Generated with Claude Code

pthread_set_name_np renames through scePthreadRename; a null name clears it,
as in FreeBSD.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

Progress report (ce64d8e → 25f95d9)

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

✅ 1 implemented
Library Name
libkernel pthread_set_name_np_nid_postfix

@Dextroid17 Dextroid17 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.

Verified on Linux — the differential holds, which is the half the "Tested" line could not cover.

  • Arm A (this PR): cmake --build build --target guest_thread_self_tests --parallel 16 → clean; the binary runs and passes, exit 0.
  • Arm B (control): the implementation file back at main with the new test kept → the target fails to link:
GuestThreadSelf.cpp:(.text.startup+0x206): undefined reference to `pthread_set_name_np_nid_postfix'

So the test cannot even run without the export, and its behavioural assertions are what carry the rest.

Claim cross-check: it delegates to scePthreadRename(thread, name != nullptr ? name : "") (Pthread/Posix/Thread.cpp:72) and returns void, so the null name clears the name and a failure (a null thread) is ignored, as the FreeBSD original does — the behaviour the body describes.

The titles are named (Quake II PPSA99007) — that is exactly the part reviewers ask for, and it is here.

Not verified: Windows (the author's platform), and behaviour beyond what this test asserts.

Written with AI assistance.

@github-actions

github-actions Bot commented Oct 9, 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
#1798 core/libs/prx/libkernel/Pthread/Posix/Thread.cpp L70

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Closing: Quake II (PPSA99007) stops at system on main, and PICO-8 reaches pthread_set_name_np only after six other missing imports (#1578). Reopen when it's a title's next stop on main, with the log line.

@babyhuey

Copy link
Copy Markdown
Contributor

This is now a title's next stop on current main, so here is the log line the close note asked for, plus a check of this branch.

Checked 25f95d9 merged onto main c963432 (the conflict in Thread.cpp is main's new pthread_getname_np right next to this function; keeping both resolves it), Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC from WinLibs), Release.

  • guest_thread_self passes 5/5 on both (--repeat until-fail:5); no CRT assertion dialog on Windows.
  • On main (catalog runs on 2edaf7f Linux and 0c0dc1e Windows) and with this branch:
Title main with this branch (Linux and Windows)
ScreenTester5 (PPSA69420) undefined symbol: oxMp8uPqa+U (pthread_set_name_np) JZKw5+Wrnaw (pthread_sigmask)

Example lines for ScreenTester5 (PPSA69420): main Windows FAIL: unresolved ELF import oxMp8uPqa+U (pthread_set_name_np) from libkernel.prx; with this branch, Linux app.elf: symbol lookup error: app.elf: undefined symbol: JZKw5+Wrnaw, Windows FAIL: unresolved ELF import JZKw5+Wrnaw from libkernel.prx.

@babyhuey babyhuey mentioned this pull request Oct 10, 2026
9 tasks done
@overlordxrz-source

Copy link
Copy Markdown
Contributor

Another title that stops here on current main: Nuvio (PPSA99997) on our Linux rig run of 2026-10-09 (x86-64 Ubuntu, lavapipe, Release) stops at the unresolved libkernel import oxMp8uPqa+U, which is pthread_set_name_np (tools/nid_names.py; also in zecoxao's aerolib.csv). Together with @babyhuey's ScreenTester5 lines above, that's two homebrew titles whose next stop on main is this function. Thanks @TheAggie, could this be reopened?

@TheAggie

Copy link
Copy Markdown
Contributor Author

@oneandonlydean the reopen condition is met: pthread_set_name_np is now a title's next stop on current main. Two runs by others above:

  • @babyhuey: ScreenTester5 (PPSA69420) stops at oxMp8uPqa+U (pthread_set_name_np) on main, Linux and Windows (FAIL: unresolved ELF import oxMp8uPqa+U (pthread_set_name_np) from libkernel.prx); with this branch it moves on to JZKw5+Wrnaw (pthread_sigmask).
  • @overlordxrz-source: Nuvio (PPSA99997) stops at the same import on their Linux run of 2026-10-09.

I rebased the branch onto current main (afb8cd2) and force-pushed it. The only conflict was main's new pthread_getname_np next to this function, and both are kept. On Windows (MinGW-w64 GCC 15.2, WinLibs, Release) it builds, guest_thread_self and the other guest_thread_* tests pass, and tools/check_conventions.py passes. I don't have ScreenTester5 or Nuvio locally, so the title runs are theirs, not mine.

Could you reopen it? GitHub doesn't let me reopen a PR a maintainer closed. Thanks @babyhuey and @overlordxrz-source for the runs.

AI-assisted (Claude Code).

@Get-fix

Get-fix commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Jelly5 (PPSA99505) also stops here, after its libSceAudioOut stop (#1578, branch Get-fix:fix/audioout-ex-exports f2b4bf3). I checked this branch at 07fb84d (the rebase onto afb8cd2) merged onto main b69270d (clean), together with that branch, on Windows 11 (WinLibs GCC 15.2.0 r7, Release):

  • ctest -R ^guest_thread --repeat until-fail:5: 4/4 (guest_thread_self, guest_thread_atexit, guest_thread_callback_abi, guest_thread_cpu_clock).
  • Jelly5 v0.6.1, with the same converted executable and libraries, two runs each:
Libraries Stop
main + fix/audioout-ex-exports FAIL: unresolved ELF import oxMp8uPqa+U from libkernel.prx
the same, with this branch's libkernel.prx FAIL: unresolved ELF import -nvxBWa0iDs from libSceLibcInternal.prx (gethostname)

The full library set rebuilt with both branches gives the same stop.

AI-assisted: yes (Claude Code).

@TheAggie

Copy link
Copy Markdown
Contributor Author

More titles stop here, from a triage of the whole homebrew catalog on main cf8b129 (Windows 11, MinGW-w64 GCC 15.2.0; each release ZIP checked against its catalog sha256, relinked with relinker --windows --registry, run for 12 s). Three titles stop at oxMp8uPqa+U (pthread_set_name_np), and with this branch each moves on:

Title main with this branch
ScreenTester5 (PPSA69420) pthread_set_name_np JZKw5+Wrnaw (pthread_sigmask)
EVO Player (PPSA99039) pthread_set_name_np n1KOc0lTUEs (arc4random_buf, libScePosixForWebKit)
PS5VR (PPSA99177) pthread_set_name_np Jb2uGFMr688 (pthread_getaffinity_np)

The "with this branch" column comes from one build of main with this branch (07fb84d, the rebased head) plus #2765, #2478 and #2024, which add unrelated imports (alarm, dup/dup2, utime). This matches @babyhuey's ScreenTester5 run on Linux and Windows and @overlordxrz-source's Nuvio report. @oneandonlydean, could this be reopened?

AI-assisted (Claude Code).

@babyhuey

Copy link
Copy Markdown
Contributor

Update for current main, since title stops moved after #2605 (each title's own libc.prx is now loaded; details in #1578). This is now the next stop for three catalog titles on main, and more reach it once other open work lands.

Checked 25f95d9 merged onto main 808d8dc, Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release. The only conflict is the same one as before: main's pthread_getname_np sits right above this function in Thread.cpp, and keeping both resolves it.

  • guest_thread_self passes 5/5 on both (--repeat until-fail:5).
  • Titles, same result on Linux and Windows:
Title main with this branch
ScreenTester5 (PPSA69420) oxMp8uPqa+U (pthread_set_name_np) JZKw5+Wrnaw (pthread_sigmask)
EVO Player (PPSA99039) oxMp8uPqa+U n1KOc0lTUEs (arc4random_buf)
PS5VR (PPSA99177) oxMp8uPqa+U Jb2uGFMr688 (pthread_getaffinity_np)

Example lines for EVO Player: main Windows FAIL: unresolved ELF import oxMp8uPqa+U (pthread_set_name_np) from libkernel.prx; with this branch, Linux app.elf: symbol lookup error: app.elf: undefined symbol: n1KOc0lTUEs, Windows FAIL: unresolved ELF import n1KOc0lTUEs (arc4random_buf) from libScePosixForWebKit.prx.

Titles that reach pthread_set_name_np once an open PR or posted branch is in: Jelly5 and Emby5 (Get-fix's sceAudioOutExGetMonitorInfo branch in #1578), PSBox Cloud Gaming (#1772), and OpenNOW (the cpuset and rwlockattr branches in #1578). Nuvio PS5 also stops here on Windows main; on Linux it reports Tf9-yOJwF-A (sceAudioOutSysGetHdmiMonitorInfo) first, so it needs both.

@babyhuey

Copy link
Copy Markdown
Contributor

@TheAggie in case it helps: with the intake check now at 10 merged PRs and the title lines above, this can go up again as a new PR (a closed PR can't be reopened by its author once a maintainer closed it).

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.

6 participants