feat(libSceLibcInternal): implement _Mtxinit, _Mtxlock, _Mtxunlock and _Mtxdst #13724
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13724"
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 MaxLikesCode on 2026-10-31T02:45:23Z.
What
Implements the four libSceLibcInternal mutex helpers that were
NotImplementedstubs under their NIDs:_Mtxinit(z7STeF6abuU),_Mtxlock(pE4Ot3CffW0),_Mtxunlock(cMwgSSmpE5o) and_Mtxdst(LaPaA6mYA38). Each name hashes to its NID, and ps5sdk's libSceLibcInternal stubs list all four.int _Mtxinit(PthreadMutex* mutex, const char* name)creates a recursive mutex namedSceLibcI_<name>, orSceLibcIwhennameis null, cut to 32 bytes. It returns 0 on success. It returns 1 when the attribute or the mutex cannot be created, or when the attribute cannot be destroyed afterwards._Mtxlock,_Mtxunlockand_Mtxdstreturn 1 when the pthread lock, unlock or destroy fails, and 0 otherwise.shadPS4 and fpPS4 agree on the signatures, the name, the recursive type and every return value:
libc_internal_threads.cppL10-L62ps4_mtx_internal.pasL47-L99, registered inps4_libscelibcinternal.pasL445-L448Lock, unlock and destroy go through libkernel's POSIX mutex calls, as in shadPS4. Both references set up a zeroed mutex on its first lock and return 0 when one is destroyed; the POSIX calls do the same. A null mutex pointer throws in libkernel, as it does for every other mutex call: shadPS4 dereferences it, fpPS4 returns
EINVAL. AnyPS5'sscePthreadMutexInitdoes not store names yet, so theSceLibcI_name is passed on and then dropped.No known title imports these. shadPS4 added them as callees of its own stdio code (shadPS4#4019).
Tested
Windows 11 Pro 10.0.26200, MinGW-W64 GCC 15.2.0 (winlibs r7), Release build of this branch on
main014c19ab19. It was then rebased onto0cc02f7cde; the 4 new commits don't touch these files.guest_libc_internal_mtxpasses 3 of 3 runs. It covers recursion, ownership checks from another thread, unlocking a released mutex, destroying twice, locking after destroy, a null name, a long name, and a zeroed mutex. Onmainit does not build, because the four functions only exist there as unnamed stubs.-k 0and thelibstarget: no errors, and no warnings from the new files. The patchedlibSceLibcInternal.prxexportsz7STeF6abuU,pE4Ot3CffW0,cMwgSSmpE5oandLaPaA6mYA38.ctest: 3162 of 3163 pass. The first run used the Windows Store Python, whereimport ctypesis denied, so its 135 Python tool and relinker tests were rerun with Anaconda's Python, the one the usual build uses. The one failure isguest_wide_formatting, which also fails onmainon this machine (#10981, fix in #10987).python3 tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branch feat/libcinternal-mtxfound no overlapping lines or exports. It could not compare #5021, #11750 and #11751 automatically; checked by hand, they share only files and touch other lines.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-31T03:05:24Z.
Review: COMMENTED
Re-checked — exact-head test evidence needed
Source review of head
0e8a80443ad09690e144f3ae252475f026c74234found no blocking defect, but the newguest_libc_internal_mtxtest was not executed by the hosted Windows job.The Windows log says no guest core/libs test sources changed; Linux and specialized test jobs were skipped. The PR description reports three passes and a broader CTest run, but does not identify the tested head SHA. The no-build review also confirmed the test is registered in the changed CMake file; its test-quality warning was a heuristic false positive. No local build or test was run.
Please provide the exact tested SHA and output for
guest_libc_internal_mtx(or arrange for CI to select and run it). I will recheck the same evidence on the updated head.