fix(libc): add missing Unity engine static imports #3648

Merged
hamb3r merged 1 commit from upstream-pr/3648 into main 2026-10-12 07:53:15 +00:00
hamb3r commented 2026-10-11 14:44:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hamb3r on 2026-10-11T14:44:32Z.


What

During the boot sequence of Unity Engine titles like God of War: Sons of Sparta (PPSA28997), eboot.elf and associated game guest PRXs (Il2cppUserAssemblies.prx, lib_burst_generated.prx, PS5Util.prx, etc.) statically import symbols from libc.prx.

Without these exports in libc.prx, the Windows loader startup stub fails at boot:

FAIL: unresolved ELF import c+4r-T-tEIc from libc.prx
GetLastError: 127 - The specified procedure could not be found.

This PR implements the missing static exports for libc.prx:

  • c+4r-T-tEIc = nearbyintf: implemented in core/libs/prx/libc/src/Math.cpp via std::nearbyint(x).
  • k6pGNMwJB08 = _Mtx_trylock: implemented in core/libs/prx/libc/src/Threads.cpp over DinkumwareMutex matching _Mtx_lock semantics.
  • jfRI3snge3o = _Thrd_sleep: implemented in core/libs/prx/libc/Export.cpp as libc__Thrd_sleep taking (const Xtime*, Xtime*) and looping on nanosleep until the deadline.
  • H2e8t5ScQGc = __cxa_finalize: exported in libc.prx as libc___cxa_finalize forwarding directly to CxaFinalize_nid_no_patch(dsoHandle).
  • Added guest test guest_libc_static_imports (core/libs/tests/GuestLibcStaticImports.cpp) registered in ctest pinning nearbyintf (±0.5, ±1.5, ±2.5, -0.0, ±inf, NaN), _Mtx_trylock (free, held, and recursive mutex), and _Thrd_sleep (deadline checks).

Tested

  • Guest test suite: guest_libc_static_imports passes via ctest.
  • God of War: Sons of Sparta (PPSA28997), Windows 10, RTX 3080:
    • Without these exports in libc.prx, startup aborts immediately with FAIL: unresolved ELF import c+4r-T-tEIc from libc.prx.
    • With these exports in libc.prx, all 1813 external PRX imports resolve cleanly, and the title boots through early runtime initialization.

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)
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4819877110 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3648). Originally posted by [hamb3r](https://github.com/hamb3r) on 2026-10-11T14:44:32Z. --- ### What During the boot sequence of Unity Engine titles like *God of War: Sons of Sparta* (PPSA28997), `eboot.elf` and associated game guest PRXs (`Il2cppUserAssemblies.prx`, `lib_burst_generated.prx`, `PS5Util.prx`, etc.) statically import symbols from `libc.prx`. Without these exports in `libc.prx`, the Windows loader startup stub fails at boot: ```text FAIL: unresolved ELF import c+4r-T-tEIc from libc.prx GetLastError: 127 - The specified procedure could not be found. ``` This PR implements the missing static exports for `libc.prx`: - `c+4r-T-tEIc` = `nearbyintf`: implemented in `core/libs/prx/libc/src/Math.cpp` via `std::nearbyint(x)`. - `k6pGNMwJB08` = `_Mtx_trylock`: implemented in `core/libs/prx/libc/src/Threads.cpp` over `DinkumwareMutex` matching `_Mtx_lock` semantics. - `jfRI3snge3o` = `_Thrd_sleep`: implemented in `core/libs/prx/libc/Export.cpp` as `libc__Thrd_sleep` taking `(const Xtime*, Xtime*)` and looping on `nanosleep` until the deadline. - `H2e8t5ScQGc` = `__cxa_finalize`: exported in `libc.prx` as `libc___cxa_finalize` forwarding directly to `CxaFinalize_nid_no_patch(dsoHandle)`. - Added guest test `guest_libc_static_imports` (`core/libs/tests/GuestLibcStaticImports.cpp`) registered in ctest pinning `nearbyintf` (±0.5, ±1.5, ±2.5, -0.0, ±inf, NaN), `_Mtx_trylock` (free, held, and recursive mutex), and `_Thrd_sleep` (deadline checks). ### Tested - Guest test suite: `guest_libc_static_imports` passes via ctest. - *God of War: Sons of Sparta* (PPSA28997), Windows 10, RTX 3080: - Without these exports in `libc.prx`, startup aborts immediately with `FAIL: unresolved ELF import c+4r-T-tEIc from libc.prx`. - With these exports in `libc.prx`, all 1813 external PRX imports resolve cleanly, and the title boots through early runtime initialization. ### Checklist - [x] Based on current **main**; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (NotImplemented_nid_no_patch) - [x] No notes, investigation .md files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-11 14:44:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T14:44:53Z.


Progress report (24865e8 → b8a1cbe)

📈 System libraries: 86.21% (+0.01%, +4 implemented, -1 removed functions)

✅ 4 implemented
Library Name
libc _Mtx_trylock_nid_postfix
libc _Thrd_sleep_nid_postfix
libc libc___cxa_finalize
libc nearbyintf_nid_postfix
🗑️ 1 removed
Library Name
libSceAmpr _Thrd_sleep_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110201195 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3648#issuecomment-6110201195). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T14:44:53Z. --- <!-- progress-report --> ### Progress report (24865e8 → b8a1cbe) 📈 **System libraries**: 86.21% (+0.01%, +4 implemented, -1 removed functions) <details> <summary>✅ 4 implemented</summary> | Library | Name | | - | - | | libc | `_Mtx_trylock_nid_postfix` | | libc | `_Thrd_sleep_nid_postfix` | | libc | `libc___cxa_finalize` | | libc | `nearbyintf_nid_postfix` | </details> <details> <summary>🗑️ 1 removed</summary> | Library | Name | | - | - | | libSceAmpr | `_Thrd_sleep_nid_postfix` | </details>
adriadam10 commented 2026-10-11 14:47:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T14:47:55Z.

Review: CHANGES_REQUESTED


Thanks for tracking this down. Some of these NIDs are already exported on main, so the stubs would duplicate them:

  • 802pFCwC9w0 = __udivti3: implemented in core/libs/prx/libc/src/RuntimeSupport.cpp:158 (__udivti3_nid_postfix).
  • VUzjXknPPBs = mbstowcs: implemented in core/libs/prx/libc/src/Multibyte.cpp:162.
  • KuOuD58hqn4 = malloc_stats_fast: implemented in core/libs/prx/libc/src/FileAndHeap.cpp:267 (covered by ApplicationHeapStats).

A second APS5_EXPORT for the same NID exports it twice; the Windows PE patcher rejects that (duplicate patched export name), and a stub must never shadow a real implementation. Please drop these three. Your import_audit.py run was probably against a registry/build older than current main; please re-run it on a fresh main build and keep only what is still absent.

For the rest:

  • H2e8t5ScQGc = __cxa_finalize is exported by libSceLibcInternal (Export.cpp:112). Check which library the title imports it from before adding it to libc.
  • jfRI3snge3o = _Thrd_sleep has an implementation in libSceAmpr/Export.cpp:946. Check the same (and whether it belongs in libc).
  • c+4r-T-tEIc = nearbyintf and k6pGNMwJB08 = _Mtx_trylock are not implemented anywhere, so a throwing stub is fine there if they are still absent after the re-run.

Also, use the real names (nearbyintf, _Mtx_trylock) with the actual signatures instead of libcUnknown_*(void), per docs/dev/CONVENTIONS.md/docs/dev/TechnicalDebt.md, and add the stubs' lines to TechnicalDebt (stubs that throw).

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5483726203 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3648#pullrequestreview-5483726203). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T14:47:55Z. **Review:** CHANGES_REQUESTED --- Thanks for tracking this down. Some of these NIDs are already exported on `main`, so the stubs would duplicate them: - `802pFCwC9w0` = `__udivti3`: implemented in `core/libs/prx/libc/src/RuntimeSupport.cpp:158` (`__udivti3_nid_postfix`). - `VUzjXknPPBs` = `mbstowcs`: implemented in `core/libs/prx/libc/src/Multibyte.cpp:162`. - `KuOuD58hqn4` = `malloc_stats_fast`: implemented in `core/libs/prx/libc/src/FileAndHeap.cpp:267` (covered by `ApplicationHeapStats`). A second `APS5_EXPORT` for the same NID exports it twice; the Windows PE patcher rejects that (`duplicate patched export name`), and a stub must never shadow a real implementation. Please drop these three. Your `import_audit.py` run was probably against a registry/build older than current `main`; please re-run it on a fresh `main` build and keep only what is still absent. For the rest: - `H2e8t5ScQGc` = `__cxa_finalize` is exported by `libSceLibcInternal` (`Export.cpp:112`). Check which library the title imports it from before adding it to `libc`. - `jfRI3snge3o` = `_Thrd_sleep` has an implementation in `libSceAmpr/Export.cpp:946`. Check the same (and whether it belongs in `libc`). - `c+4r-T-tEIc` = `nearbyintf` and `k6pGNMwJB08` = `_Mtx_trylock` are not implemented anywhere, so a throwing stub is fine there if they are still absent after the re-run. Also, use the real names (`nearbyintf`, `_Mtx_trylock`) with the actual signatures instead of `libcUnknown_*(void)`, per `docs/dev/CONVENTIONS.md`/`docs/dev/TechnicalDebt.md`, and add the stubs' lines to TechnicalDebt (stubs that throw).
blawesom commented 2026-10-11 15:19:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-11T15:19:44Z.


Independent pre-review on Linux (full CI runs only happen on manual trigger, so recording one): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON.

  • Builds; tools/check_conventions.py --base origin/main passes.
  • Full suite: 832/832 passed (all tests including the Vulkan suites on AMD RX 9070 XT / RADV).
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110517301 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3648#issuecomment-6110517301). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-11T15:19:44Z. --- Independent pre-review on **Linux** (full CI runs only happen on manual trigger, so recording one): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`. - Builds; `tools/check_conventions.py --base origin/main` passes. - Full suite: **832/832 passed** (all tests including the Vulkan suites on AMD RX 9070 XT / RADV).
github-actions[bot] commented 2026-10-11 15:28:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T15:28:32Z.


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
#3743 core/libs/prx/libSceAmpr/Export.cpp L228-231, L241-256
#3798 docs/dev/TechnicalDebt.md L392-393
#3883 docs/dev/TechnicalDebt.md L55
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110598172 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3648#issuecomment-6110598172). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T15:28:32Z. --- <!-- pr-overlap --> 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 | |---|---|---|---| | #3743 | `core/libs/prx/libSceAmpr/Export.cpp` [L228-231](https://github.com/boykopovar/AnyPS5/blob/436e310ddb56fcf5dd1d40ba1f8113fe8cb8c113/core/libs/prx/libSceAmpr/Export.cpp#L228-L231), [L241-256](https://github.com/boykopovar/AnyPS5/blob/436e310ddb56fcf5dd1d40ba1f8113fe8cb8c113/core/libs/prx/libSceAmpr/Export.cpp#L241-L256) | | | | #3798 | `docs/dev/TechnicalDebt.md` [L392-393](https://github.com/boykopovar/AnyPS5/blob/436e310ddb56fcf5dd1d40ba1f8113fe8cb8c113/docs/dev/TechnicalDebt.md#L392-L393) | | | | #3883 | `docs/dev/TechnicalDebt.md` [L55](https://github.com/boykopovar/AnyPS5/blob/436e310ddb56fcf5dd1d40ba1f8113fe8cb8c113/docs/dev/TechnicalDebt.md#L55) | | |
hamb3r commented 2026-10-11 15:29:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hamb3r on 2026-10-11T15:29:51Z.


Thanks for the thorough review @adriadam10.

I've rebased on current main and addressed all points:

  1. Dropped the 3 duplicates:

    • 802pFCwC9w0 (__udivti3), VUzjXknPPBs (mbstowcs), and KuOuD58hqn4 (malloc_stats_fast) were removed from this PR since they are already implemented on main.
  2. Checked import sources:

    • Both H2e8t5ScQGc and jfRI3snge3o are indeed imported from libc.prx by the title:
      • eboot.elf explicitly imports jfRI3snge3o (_Thrd_sleep) from libc.prx.
      • The game's guest modules (Il2cppUserAssemblies.prx, lib_burst_generated.prx, PS5Util.prx, etc.) explicitly import H2e8t5ScQGc (__cxa_finalize) from libc.prx.
    • For H2e8t5ScQGc, libc___cxa_finalize is now exported in libc forwarding directly to the existing CxaFinalize_nid_no_patch(dsoHandle).
  3. Function names, signatures, and TechnicalDebt:

    • Replaced generic libcUnknown_* stubs with their actual signatures:
      • float APS5_VABI nearbyintf_nid_postfix(float x) (c+4r-T-tEIc)
      • int APS5_VABI _Mtx_trylock_nid_postfix(void** handle) (k6pGNMwJB08)
      • libc__Thrd_sleep (jfRI3snge3o)
    • Added entries for these throwing stubs to docs/dev/TechnicalDebt.md under Unknown function info.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110609987 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3648#issuecomment-6110609987). Originally posted by [hamb3r](https://github.com/hamb3r) on 2026-10-11T15:29:51Z. --- Thanks for the thorough review @adriadam10. I've rebased on current `main` and addressed all points: 1. **Dropped the 3 duplicates**: - `802pFCwC9w0` (`__udivti3`), `VUzjXknPPBs` (`mbstowcs`), and `KuOuD58hqn4` (`malloc_stats_fast`) were removed from this PR since they are already implemented on `main`. 2. **Checked import sources**: - Both `H2e8t5ScQGc` and `jfRI3snge3o` are indeed imported from `libc.prx` by the title: - `eboot.elf` explicitly imports `jfRI3snge3o` (`_Thrd_sleep`) from `libc.prx`. - The game's guest modules (`Il2cppUserAssemblies.prx`, `lib_burst_generated.prx`, `PS5Util.prx`, etc.) explicitly import `H2e8t5ScQGc` (`__cxa_finalize`) from `libc.prx`. - For `H2e8t5ScQGc`, `libc___cxa_finalize` is now exported in `libc` forwarding directly to the existing `CxaFinalize_nid_no_patch(dsoHandle)`. 3. **Function names, signatures, and TechnicalDebt**: - Replaced generic `libcUnknown_*` stubs with their actual signatures: - `float APS5_VABI nearbyintf_nid_postfix(float x)` (`c+4r-T-tEIc`) - `int APS5_VABI _Mtx_trylock_nid_postfix(void** handle)` (`k6pGNMwJB08`) - `libc__Thrd_sleep` (`jfRI3snge3o`) - Added entries for these throwing stubs to `docs/dev/TechnicalDebt.md` under `Unknown function info`.
adriadam10 commented 2026-10-11 15:31:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T15:31:06Z.

Review: CHANGES_REQUESTED


Thanks for dropping the duplicates and rebasing. Three of the four exports can be exact instead of throwing, and main already has the pieces:

  • _Mtx_trylock (core/libs/prx/libc/Export.cpp:41): libc already implements _Mtx_init/_Mtx_lock/_Mtx_unlock over DinkumwareMutex (core/libs/prx/libc/src/Threads.cpp:93). Add _Mtx_trylock next to _Mtx_lock there (same ResolveMutex, native.try_lock(), same owner/recursive handling, threadBusy when it is held), not a throwing stub in Export.cpp.
  • _Thrd_sleep (Export.cpp:52): an exact implementation already exists as _Thrd_sleep_nid_postfix in core/libs/prx/libSceAmpr/Export.cpp:946 (takes const Xtime*, loops on nanosleep until the deadline). Reuse that logic/signature for the libc export instead of a new (const void*, void*) stub.
  • nearbyintf (Export.cpp:35): this is plain C99 (round to integer in the current rounding mode, default round-half-even). Implement it with std::nearbyintf rather than throwing; the TechnicalDebt entry for it is then not needed.
  • Please add a guest test, registered in ctest, pinning values: nearbyintf at ±0.5, ±1.5, ±2.5, -0.0, ±inf, NaN; _Mtx_trylock on a free, held (other thread) and recursive mutex; _Thrd_sleep returning after the deadline. It must fail without the change.
  • If any of these stays a stub, the TechnicalDebt lines need a full stop at the end and a source for the signature beyond "C11 threads" (_Mtx_trylock and _Thrd_sleep here are the Dinkumware _Mtx_*/_Thrd_* internals, not <threads.h>).

__cxa_finalize forwarding to CxaFinalize_nid_no_patch looks fine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5483855225 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3648#pullrequestreview-5483855225). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T15:31:06Z. **Review:** CHANGES_REQUESTED --- Thanks for dropping the duplicates and rebasing. Three of the four exports can be exact instead of throwing, and `main` already has the pieces: - `_Mtx_trylock` (`core/libs/prx/libc/Export.cpp:41`): `libc` already implements `_Mtx_init`/`_Mtx_lock`/`_Mtx_unlock` over `DinkumwareMutex` (`core/libs/prx/libc/src/Threads.cpp:93`). Add `_Mtx_trylock` next to `_Mtx_lock` there (same `ResolveMutex`, `native.try_lock()`, same owner/recursive handling, `threadBusy` when it is held), not a throwing stub in `Export.cpp`. - `_Thrd_sleep` (`Export.cpp:52`): an exact implementation already exists as `_Thrd_sleep_nid_postfix` in `core/libs/prx/libSceAmpr/Export.cpp:946` (takes `const Xtime*`, loops on `nanosleep` until the deadline). Reuse that logic/signature for the `libc` export instead of a new `(const void*, void*)` stub. - `nearbyintf` (`Export.cpp:35`): this is plain C99 (round to integer in the current rounding mode, default round-half-even). Implement it with `std::nearbyintf` rather than throwing; the TechnicalDebt entry for it is then not needed. - Please add a guest test, registered in ctest, pinning values: `nearbyintf` at ±0.5, ±1.5, ±2.5, -0.0, ±inf, NaN; `_Mtx_trylock` on a free, held (other thread) and recursive mutex; `_Thrd_sleep` returning after the deadline. It must fail without the change. - If any of these stays a stub, the TechnicalDebt lines need a full stop at the end and a source for the signature beyond "C11 threads" (`_Mtx_trylock` and `_Thrd_sleep` here are the Dinkumware `_Mtx_*`/`_Thrd_*` internals, not `<threads.h>`). `__cxa_finalize` forwarding to `CxaFinalize_nid_no_patch` looks fine.
hamb3r commented 2026-10-11 15:53:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hamb3r on 2026-10-11T15:53:17Z.


Thanks for the guidance @adriadam10.

I have updated the PR with exact implementations and guest test coverage:

  1. _Mtx_trylock (k6pGNMwJB08):

    • Implemented in core/libs/prx/libc/src/Threads.cpp right next to _Mtx_lock.
    • Uses ResolveMutex, native.try_lock(), handles caller ownership and recursive mutexes, returning threadBusy (3) when held by another thread.
  2. nearbyintf (c+4r-T-tEIc):

    • Implemented in core/libs/prx/libc/src/Math.cpp via std::nearbyintf(x).
  3. _Thrd_sleep (jfRI3snge3o):

    • Implemented in core/libs/prx/libc/Export.cpp as libc__Thrd_sleep taking (const Xtime* target, Xtime* remaining).
    • Reuses the XtimeDeadline normalization and nanosleep loop checking clock_gettime(CLOCK_REALTIME).
  4. TechnicalDebt:

    • Removed the entries from docs/dev/TechnicalDebt.md since all three are now fully implemented rather than stubs.
  5. Guest Test:

    • Added guest_libc_static_imports in core/libs/tests/GuestLibcStaticImports.cpp and registered in ctest under core/libs/prx/libc/CMakeLists.txt.
    • Pins nearbyintf at ±0.5, ±1.5, ±2.5, -0.0, ±inf, and NaN (including signbit checks).
    • Pins _Mtx_trylock on free, held (cross-thread), and recursive mutexes.
    • Pins _Thrd_sleep verifying return after the deadline and rejection of null target.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110823857 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3648#issuecomment-6110823857). Originally posted by [hamb3r](https://github.com/hamb3r) on 2026-10-11T15:53:17Z. --- Thanks for the guidance @adriadam10. I have updated the PR with exact implementations and guest test coverage: 1. **`_Mtx_trylock` (`k6pGNMwJB08`)**: - Implemented in `core/libs/prx/libc/src/Threads.cpp` right next to `_Mtx_lock`. - Uses `ResolveMutex`, `native.try_lock()`, handles caller ownership and recursive mutexes, returning `threadBusy` (3) when held by another thread. 2. **`nearbyintf` (`c+4r-T-tEIc`)**: - Implemented in `core/libs/prx/libc/src/Math.cpp` via `std::nearbyintf(x)`. 3. **`_Thrd_sleep` (`jfRI3snge3o`)**: - Implemented in `core/libs/prx/libc/Export.cpp` as `libc__Thrd_sleep` taking `(const Xtime* target, Xtime* remaining)`. - Reuses the `XtimeDeadline` normalization and `nanosleep` loop checking `clock_gettime(CLOCK_REALTIME)`. 4. **TechnicalDebt**: - Removed the entries from `docs/dev/TechnicalDebt.md` since all three are now fully implemented rather than stubs. 5. **Guest Test**: - Added `guest_libc_static_imports` in `core/libs/tests/GuestLibcStaticImports.cpp` and registered in ctest under `core/libs/prx/libc/CMakeLists.txt`. - Pins `nearbyintf` at ±0.5, ±1.5, ±2.5, -0.0, ±inf, and NaN (including signbit checks). - Pins `_Mtx_trylock` on free, held (cross-thread), and recursive mutexes. - Pins `_Thrd_sleep` verifying return after the deadline and rejection of null target.
adriadam10 commented 2026-10-11 20:51:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T20:51:23Z.

Review: DISMISSED


Checked on Linux (build + guest_libc_static_imports pass; without the change the test does not link, so it pins the new code). The NIDs match aerolib. Two things left:

  • _Thrd_sleep (core/libs/prx/libc/Export.cpp:11-35,72-88) is a copy of the one already in libSceAmpr (core/libs/prx/libSceAmpr/Export.cpp:221-259,946-960: same Xtime, XtimeDeadline, loop and error strings). Please don't duplicate it: libc is the module the title imports it from and libSceAmpr already links libc, so keep a single implementation (in libc, next to the other thread code) and have libSceAmpr stop exporting its own copy, as in the duplicate-exports cases of #228/#241. Move the _Thrd_sleep part of the "Dinkumware thread exports" TechnicalDebt line along with it.
  • Add TechnicalDebt lines (under "Unknown function info", not at the end of the section) for what is unverified: _Mtx_trylock (busy for a non-recursive mutex already owned by the caller, assumed to match _Mtx_lock's ownership handling), nearbyintf (host rounding mode, not the console's) and _Thrd_sleep once moved.

Minor: nanosleep returning EINTR currently throws; since the loop rechecks the deadline, retry on EINTR and throw only on other errors.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5484903150 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3648#pullrequestreview-5484903150). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T20:51:23Z. **Review:** DISMISSED --- Checked on Linux (build + `guest_libc_static_imports` pass; without the change the test does not link, so it pins the new code). The NIDs match aerolib. Two things left: - `_Thrd_sleep` (`core/libs/prx/libc/Export.cpp:11-35,72-88`) is a copy of the one already in `libSceAmpr` (`core/libs/prx/libSceAmpr/Export.cpp:221-259,946-960`: same `Xtime`, `XtimeDeadline`, loop and error strings). Please don't duplicate it: libc is the module the title imports it from and `libSceAmpr` already links `libc`, so keep a single implementation (in libc, next to the other thread code) and have `libSceAmpr` stop exporting its own copy, as in the duplicate-exports cases of #228/#241. Move the `_Thrd_sleep` part of the "Dinkumware thread exports" TechnicalDebt line along with it. - Add TechnicalDebt lines (under "Unknown function info", not at the end of the section) for what is unverified: `_Mtx_trylock` (busy for a non-recursive mutex already owned by the caller, assumed to match `_Mtx_lock`'s ownership handling), `nearbyintf` (host rounding mode, not the console's) and `_Thrd_sleep` once moved. Minor: `nanosleep` returning `EINTR` currently throws; since the loop rechecks the deadline, retry on `EINTR` and throw only on other errors.
hamb3r commented 2026-10-11 22:14:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hamb3r on 2026-10-11T22:14:24Z.


Thanks for the feedback @adriadam10.

I've rebased on current main and addressed the remaining items:

  1. Deduplicated _Thrd_sleep:

    • Moved _Thrd_sleep_nid_postfix along with Xtime and XtimeDeadline into core/libs/prx/libc/src/Threads.cpp alongside the other thread functions.
    • Removed the duplicate export and helper code from core/libs/prx/libSceAmpr/Export.cpp.
    • Cleaned up core/libs/prx/libc/Export.cpp so it only contains libc___cxa_finalize.
  2. Handle EINTR in _Thrd_sleep:

    • Added an errno == EINTR check on nanosleep failure to continue the deadline loop, throwing only on other errors.
  3. TechnicalDebt.md:

    • Updated the libSceAmpr Dinkumware thread exports entry to remove _Thrd_sleep.
    • Added entries under ### Unknown function info for:
      • _Mtx_trylock: busy return for a non-recursive mutex already held by the caller;
      • nearbyintf: host rounding mode rather than the console's;
      • _Thrd_sleep: Dinkumware threads library origin and EINTR retry behavior.

All relevant tests (guest_libc_threads, guest_libc_static_imports, guest_ampr_threads) and tools/check_conventions.py pass.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114454783 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3648#issuecomment-6114454783). Originally posted by [hamb3r](https://github.com/hamb3r) on 2026-10-11T22:14:24Z. --- Thanks for the feedback @adriadam10. I've rebased on current `main` and addressed the remaining items: 1. **Deduplicated `_Thrd_sleep`**: - Moved `_Thrd_sleep_nid_postfix` along with `Xtime` and `XtimeDeadline` into `core/libs/prx/libc/src/Threads.cpp` alongside the other thread functions. - Removed the duplicate export and helper code from `core/libs/prx/libSceAmpr/Export.cpp`. - Cleaned up `core/libs/prx/libc/Export.cpp` so it only contains `libc___cxa_finalize`. 2. **Handle `EINTR` in `_Thrd_sleep`**: - Added an `errno == EINTR` check on `nanosleep` failure to `continue` the deadline loop, throwing only on other errors. 3. **TechnicalDebt.md**: - Updated the `libSceAmpr` Dinkumware thread exports entry to remove `_Thrd_sleep`. - Added entries under `### Unknown function info` for: - `_Mtx_trylock`: busy return for a non-recursive mutex already held by the caller; - `nearbyintf`: host rounding mode rather than the console's; - `_Thrd_sleep`: Dinkumware threads library origin and `EINTR` retry behavior. All relevant tests (`guest_libc_threads`, `guest_libc_static_imports`, `guest_ampr_threads`) and `tools/check_conventions.py` pass.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!3648
No description provided.