Repository navigation
feat(libc): implement the C11 mtx and cnd functions - #492
Amielle-Inside wants to merge 1 commit into
Conversation
Twelve libc imports that shipped as throwing libcCyberUnknown stubs are identified by NID hash and implemented: _Mtx_init, _Mtx_lock, _Mtx_trylock, _Mtx_unlock, _Mtx_destroy, _Cnd_init, _Cnd_wait, _Cnd_broadcast, _Cnd_destroy, __powidf2, _WStoul, _Iswctype and abs. The mtx/cnd state is host-native (recursive/plain mutex, condition_variable) stored through an atomic slot in the guest-provided storage, matching the pointer-sized PS5 layout observed in bundled libc binaries. The stub exports for the now-implemented NIDs are removed from Export.cpp; quick_exit and _Execute_once stay NotImplemented.
|
Thanks for identifying these, the names match the NIDs. I compared the code with Sony's own libc.prx (the one PPSA21564 ships in sce_module), and a few things differ from it:
Since Sony's wrappers call |
Progress report (9f9a8f5 → 88e1756)📈 System libraries: 77.73% (+0.38%, +13 implemented, -12 removed functions) ✅ 13 implemented
🗑️ 12 removed
|
The DQbtGaBKlaw import was a throwing stub (libcCyberUnknown17). It is the NID of "strnlen_s", which C11 K.3.7.4.4 defines as strnlen that returns 0 for a null pointer. The removed stub comment from #358 described its call site as float -> float, which contradicts the hash-verified name; #492 left the stub untouched for that reason.
|
Following up on this one: are you still working on it? It now conflicts with The owner has also asked us to check on every PR which title needs it. Do you know a title that calls the C11 If you don't have time for it, no problem, just say so and we'll close it for now; it can be reopened later. |
|
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.
|
|
Closing this one, for these reasons:
You're welcome to reopen (or open a new PR) with only the mtx/cnd functions, following Sony's wrappers ( |
What
Twelve libc imports that shipped as throwing
libcCyberUnknown*stubs (PR #358) are identified by NID hash and implemented incore/libs/prx/libc/src/Threads.cpp:YaHc3GS7y7g_Mtx_initiS4aWbUonl0_Mtx_lock_Mtx_trylockgTuXQwP9rrs_Mtx_unlock5Lf51jvohTQ_Mtx_destroySreZybSRWpU_Cnd_initvEaqE-7IZYc_Cnd_waitVsP3daJgmVA_Cnd_broadcast7yMFgcS8EPA_Cnd_destroyH+8UBOwfScI__powidf2JhVR7D4Ax6Y_WStoulCyXs2l-1kNA_IswctypeYe20uNnlglAabsIdentification is hash-verified: every name was run forward through the project's own
Nid::ComputeSHA-1/salt/base64 algorithm and all 13 NIDs match (22/22 across all previously-unknown libc exports, including names left unchanged here). The mtx/cnd implementations keep host-native state (recursive/plainstd::mutex,std::condition_variable) behind an atomic slot in the guest-provided storage; disassembly of a title-bundledlibc.prxshows_Mtx_init/_Cnd_initare pointer-passing wrappers, so the storage only needs to hold the private pointer. Error codes follow C11 (thrd_success/thrd_busy/thrd_error), mapped from the disassembled wrappers.Left untouched on purpose:
qdGFBoLVNKI(quick_exit— open PR #405 owns it),DiGVep5yB5w(_ZSt13_Execute_once...),Pu0Ecyk-7FU/u2tMGOLaqnE(libc++ internals that throw), and the three file-idiom Cyberpunk stubs whose aerolib names (strnlen_s/vsnprintf_s/vsscanf_s) contradict the observed signatures in #358 — those need signature confirmation first.Tested
Linux (Bazzite/Fedora Atomic, GCC in distrobox),
cmake --build buildclean (568/568),ctest173/173 passed, 0 failed (skips are pre-existing GPU tests).nid_patcheroutput verified: all 13 renamed symbols hash to the exact previous NIDs in the patchedlibc.prx(readelf), no duplicate definitions introduced. Runtime smoke: PPSA16951 (Tales of Xillia Remastered, Unity IL2CPP title with bundled libc.prx) relinked with this build — C11 imports resolve and the previoussymbol lookup errorchain is gone; the title still stops at the #476 bundled-libc iostream init, which is unrelated to this change.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)