feat(libc): export the std::__sce_v2 _Xtime_diff_to_millis2 helper #15490

Merged
Danigamer05 merged 1 commit from upstream-pr/15490 into main 2026-11-08 01:19:08 +00:00
Danigamer05 commented 2026-11-03 15:18:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Danigamer05 on 2026-11-03T15:18:26Z.


What

Export the versioned std::__sce_v2::_Xtime_diff_to_millis2 from libc.

Export NID Original RVA
_ZNSt8__sce_v222_Xtime_diff_to_millis2EPK8timespecS2_ qlkHBOfGcpQ 0xC9A60

The behavior comes from the libc.prx bundled with PPSA03671 v01.001.005 (J03848509, SHA-256 483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6).

It returns the milliseconds from now until target, rounded up, or 0 when target is not later. As in the module:

  • the target's nanoseconds are normalized into [0, 10^9) first, with the module's closed-form division rather than a loop, so it ends for every input;
  • now is subtracted as given, without normalizing it, borrowing one second when the target's nanoseconds are smaller;
  • a negative difference, or zero seconds with non-positive nanoseconds, returns 0;
  • otherwise the result is seconds * 1000 + (nanoseconds + 999999) / 1000000, with the module's 64-bit wraparound when a field is out of range.

It sits in TimeExtras.cpp beside _Xtime_diff_to_ts, and reuses the existing Xtime layout, which matches timespec.

Tested

Windows x86-64, WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON, main 4f41f4c375f. Exact tested commit: a17174c0c35.

  • Built libc, libkernel, their NID-patched production libraries and the related tests. The new guest_sce_v2_xtime_diff_to_millis, guest_time_extras, public_headers, guest_math_exact and guest_dinkumware_float_bits pass, along with the other guest_sce_v2_* CTests.

  • The new test checks 26 pairs: whole and partial seconds, rounding up from one nanosecond and half a millisecond, borrowing a second, equal and past targets, negative, huge and lowest target nanoseconds, nanoseconds of exactly one and two seconds, unnormalized and negative now nanoseconds, and wrapping seconds and milliseconds. It also checks that neither argument changes. Every expected value was taken from the original module, not from this implementation.

  • The original function was loaded from the bundled module with its relocations applied. Its imports were bound by NID to this branch's libc and libkernel, with __stack_chk_guard pointing at a local value. The function calls none of them.

  • Side by side with the patched production library, the result, both arguments, errno, MXCSR and the x87 control and status words agree in all 10,000,000 calls over two seeds. The inputs mixed edge values (0, ±1, 999,999, 10^6, 10^9 ± 1, 2·10^9 - 1, ±2·10^9, INT64_MIN, INT64_MAX and neighbors), random 64-bit fields, nearby seconds and realistic clock values.

  • Negative control: four lines were altered one at a time:

    • the target's negative nanoseconds were normalized one second short;
    • the borrow no longer took a second;
    • a negative difference was no longer clamped to 0;
    • the rounding added 999,998 instead of 999,999.

    The new CTest failed on each, and the side-by-side run reported differences each time. Two earlier alterations turned out to be equivalent: they never change the result. They were replaced, and a test row was added for the first alteration, which only a large negative nanosecond count exposes. The source was then restored byte for byte (SHA-256 checked) and rebuilt, and the test and side-by-side run passed again.

  • Code conventions and git diff --check pass.

  • tools/pr_overlap.py read 1,717 open PRs at the tested commit and reports no overlap. It keeps exit 2 for 36 branches that already conflict with main. None of them adds a line naming this export. Merging each of the 36 with this branch and with main using git merge-tree gives the same conflict blocks. The branch also merges cleanly with #15336, #15471 and #15484.

Not tested: Linux, macOS, another SDK, a game, GPU or console. No game compatibility claim. No original module, extracted bytes, harness or log is committed or uploaded.

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 under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5139748186 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15490). Originally posted by [Danigamer05](https://github.com/Danigamer05) on 2026-11-03T15:18:26Z. --- ### What Export the versioned `std::__sce_v2::_Xtime_diff_to_millis2` from libc. | Export | NID | Original RVA | | --- | --- | --- | | `_ZNSt8__sce_v222_Xtime_diff_to_millis2EPK8timespecS2_` | `qlkHBOfGcpQ` | `0xC9A60` | The behavior comes from the `libc.prx` bundled with PPSA03671 v01.001.005 (J03848509, SHA-256 `483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6`). It returns the milliseconds from `now` until `target`, rounded up, or 0 when `target` is not later. As in the module: - the target's nanoseconds are normalized into [0, 10^9) first, with the module's closed-form division rather than a loop, so it ends for every input; - `now` is subtracted as given, without normalizing it, borrowing one second when the target's nanoseconds are smaller; - a negative difference, or zero seconds with non-positive nanoseconds, returns 0; - otherwise the result is `seconds * 1000 + (nanoseconds + 999999) / 1000000`, with the module's 64-bit wraparound when a field is out of range. It sits in `TimeExtras.cpp` beside `_Xtime_diff_to_ts`, and reuses the existing `Xtime` layout, which matches `timespec`. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows x86-64, WinLibs GCC 15.2.0, Release, `BUILD_TESTING=ON`, main `4f41f4c375f`. Exact tested commit: `a17174c0c35`. - Built libc, libkernel, their NID-patched production libraries and the related tests. The new `guest_sce_v2_xtime_diff_to_millis`, `guest_time_extras`, `public_headers`, `guest_math_exact` and `guest_dinkumware_float_bits` pass, along with the other `guest_sce_v2_*` CTests. - The new test checks 26 pairs: whole and partial seconds, rounding up from one nanosecond and half a millisecond, borrowing a second, equal and past targets, negative, huge and lowest target nanoseconds, nanoseconds of exactly one and two seconds, unnormalized and negative `now` nanoseconds, and wrapping seconds and milliseconds. It also checks that neither argument changes. Every expected value was taken from the original module, not from this implementation. - The original function was loaded from the bundled module with its relocations applied. Its imports were bound by NID to this branch's libc and libkernel, with `__stack_chk_guard` pointing at a local value. The function calls none of them. - Side by side with the patched production library, the result, both arguments, `errno`, MXCSR and the x87 control and status words agree in all 10,000,000 calls over two seeds. The inputs mixed edge values (0, ±1, 999,999, 10^6, 10^9 ± 1, 2·10^9 - 1, ±2·10^9, `INT64_MIN`, `INT64_MAX` and neighbors), random 64-bit fields, nearby seconds and realistic clock values. - Negative control: four lines were altered one at a time: - the target's negative nanoseconds were normalized one second short; - the borrow no longer took a second; - a negative difference was no longer clamped to 0; - the rounding added 999,998 instead of 999,999. The new CTest failed on each, and the side-by-side run reported differences each time. Two earlier alterations turned out to be equivalent: they never change the result. They were replaced, and a test row was added for the first alteration, which only a large negative nanosecond count exposes. The source was then restored byte for byte (SHA-256 checked) and rebuilt, and the test and side-by-side run passed again. - Code conventions and `git diff --check` pass. - `tools/pr_overlap.py` read 1,717 open PRs at the tested commit and reports no overlap. It keeps exit 2 for 36 branches that already conflict with main. None of them adds a line naming this export. Merging each of the 36 with this branch and with main using `git merge-tree` gives the same conflict blocks. The branch also merges cleanly with #15336, #15471 and #15484. Not tested: Linux, macOS, another SDK, a game, GPU or console. No game compatibility claim. No original module, extracted bytes, harness or log is committed or uploaded. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-03 15:36:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-03T15:36:00Z.

Review: COMMENTED


Reviewed — no blocking findings; checks pending

I reviewed all five changed files at head a17174c0c3593e0a7f7131889db441658c1e5977 and found no substantiated blocking defect; hosted Windows and macOS jobs are not complete, so this is a COMMENTED result rather than an approval.

What I ran

Reviewed head a17174c0c3593e0a7f7131889db441658c1e5977 against base 4f41f4c375f5abb487dbd184fbc150f31994d762; the stack preview merges cleanly. Environment: Debian Linux x86_64, Python 3.11.2, GCC 12.2.0, Git 2.39.5. No local C++ build or CTest was run. The Windows CTest and binary differential results in the PR description are author-reported, not runs I performed.

git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...a17174c0c3593e0a7f7131889db441658c1e5977
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 15490
python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 --head a17174c0c3593e0a7f7131889db441658c1e5977 --title 'feat(libc): export the std::__sce_v2 _Xtime_diff_to_millis2 helper' --body /tmp/anyps5-15490-pr-body.md
python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 4f41f4c375f5abb487dbd184fbc150f31994d762 --head a17174c0c3593e0a7f7131889db441658c1e5977 --json
python3 tools/pr_stack_check.py 15490 --repo boykopovar/AnyPS5
gh api repos/boykopovar/AnyPS5/commits/a17174c0c3593e0a7f7131889db441658c1e5977/check-runs --jq '[.check_runs[] | {name,status,conclusion}]'

Results

Check Result Note
Diff and merge preview passed Clean against the stated base.
Conventions and template passed Direct check and hosted check pass.
Export ABI audit passed New export has one declaration and definition; computed NID matches.
Test registration and assertions passed CMake registration and the 26 input/expected-value cases were inspected.
Hosted checks not run Windows and macOS jobs remain pending; some platform-specific jobs are skipped.
Local build and CTest not run No local build was performed.
No-build precheck wrapper failed Its isolated snapshot lacks optional local helper scripts; details below.
Precheck table and raw check output
Check Status Command / reason
build_and_compile not_applicable The precheck deliberately does not configure, build, or compile AnyPS5.
diff_check passed git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...a17174c0c3593e0a7f7131889db441658c1e5977
conventions_and_pr_template not_executable /usr/bin/python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 --head a17174c0c3593e0a7f7131889db441658c1e5977 --title feat(libc): export the std::__sce_v2 _Xtime_diff_to_millis2 helper --body /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-15490-a17174c0c359/pr-body.md
changed_export_abi_audit not_executable /usr/bin/python3 tools/pr_abi_audit.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 --head a17174c0c3593e0a7f7131889db441658c1e5977 --json
python_syntax not_applicable No changed Python implementation files.
related_python_unit_tests not_applicable No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.
python_test_registration not_applicable No changed test_*.py files.
live_dependency_and_mergeability_check passed /usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 15490 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-15490-a17174c0c359/stack
build_dependent_cpp_tests not_applicable Not run: C++ tests need exact-head binaries, which require a build; the precheck does not build.
test_quality_heuristics failed /usr/bin/python3 /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-15490-a17174c0c359/head-a17174c0c359-537f0f72/tools/pr_test_quality.py --root /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-15490-a17174c0c359/head-a17174c0c359-537f0f72 --json core/libs/prx/libc/CMakeLists.txt core/libs/prx/libc/include/Api.hpp core/libs/prx/libc/src/TimeExtras.cpp core/libs/tests/GuestSceV2XtimeDiffToMillis.cpp docs/dev/debt/libc.md
negative_controls not_applicable No changed Python test module in tools/ can be run as a no-build base-source control.

Direct convention check:

All conventions checks passed.

ABI audit entry for the new symbol:

{
  "name": "_ZNSt8__sce_v222_Xtime_diff_to_millis2EPK8timespecS2__nid_postfix",
  "computed_nid": "qlkHBOfGcpQ",
  "declarations": ["core/libs/prx/libc/include/Api.hpp"],
  "definitions": ["core/libs/prx/libc/src/TimeExtras.cpp"],
  "explicit_aliases": [],
  "version": "not encoded by these source declarations; not verified"
}

The audit also emitted three warnings outside this new export for libc___cxa_finalize, longjmp_nid_postfix, and setjmp_nid_postfix.

Negative control

I did not run a mutation locally because the C++ test needs a build. The PR description reports four one-line mutations that made its new CTest fail and a restored-source differential run against the bundled module; I did not independently reproduce those results.

Findings

Blocking

None found in the inspected change.

Non-blocking

  • The implementation’s console equivalence and 10-million-call differential are author-reported; the original module and raw comparison logs are not attached. The PR does identify the module version and SHA-256, and records console/other-firmware coverage as unverified.
  • Required hosted checks are not all complete. I will re-check this head after Windows and queued macOS jobs finish before considering approval.

Sources

Not verified

I did not run the C++ test, build the library, repeat the reported binary differential, inspect the original private firmware module, or test Linux/macOS runtime or console behavior. The hosted Windows job and queued macOS jobs have not completed.

To get this to a good state

No code change is requested from this review. Let the pending hosted jobs finish; I will re-check their exact-head results and then approve only if they pass and no new issue appears.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5755014650 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15490#pullrequestreview-5755014650). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-03T15:36:00Z. **Review:** COMMENTED --- # Reviewed — no blocking findings; checks pending I reviewed all five changed files at head `a17174c0c3593e0a7f7131889db441658c1e5977` and found no substantiated blocking defect; hosted Windows and macOS jobs are not complete, so this is a COMMENTED result rather than an approval. ## What I ran Reviewed head `a17174c0c3593e0a7f7131889db441658c1e5977` against base `4f41f4c375f5abb487dbd184fbc150f31994d762`; the stack preview merges cleanly. Environment: Debian Linux x86_64, Python 3.11.2, GCC 12.2.0, Git 2.39.5. No local C++ build or CTest was run. The Windows CTest and binary differential results in the PR description are author-reported, not runs I performed. ```sh git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...a17174c0c3593e0a7f7131889db441658c1e5977 python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 15490 python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 --head a17174c0c3593e0a7f7131889db441658c1e5977 --title 'feat(libc): export the std::__sce_v2 _Xtime_diff_to_millis2 helper' --body /tmp/anyps5-15490-pr-body.md python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 4f41f4c375f5abb487dbd184fbc150f31994d762 --head a17174c0c3593e0a7f7131889db441658c1e5977 --json python3 tools/pr_stack_check.py 15490 --repo boykopovar/AnyPS5 gh api repos/boykopovar/AnyPS5/commits/a17174c0c3593e0a7f7131889db441658c1e5977/check-runs --jq '[.check_runs[] | {name,status,conclusion}]' ``` ## Results | Check | Result | Note | |---|---|---| | Diff and merge preview | passed | Clean against the stated base. | | Conventions and template | passed | Direct check and hosted check pass. | | Export ABI audit | passed | New export has one declaration and definition; computed NID matches. | | Test registration and assertions | passed | CMake registration and the 26 input/expected-value cases were inspected. | | Hosted checks | not run | Windows and macOS jobs remain pending; some platform-specific jobs are skipped. | | Local build and CTest | not run | No local build was performed. | | No-build precheck wrapper | failed | Its isolated snapshot lacks optional local helper scripts; details below. | <details> <summary>Precheck table and raw check output</summary> | Check | Status | Command / reason | |---|---|---| | build_and_compile | not_applicable | `The precheck deliberately does not configure, build, or compile AnyPS5.` | | diff_check | passed | `git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...a17174c0c3593e0a7f7131889db441658c1e5977` | | conventions_and_pr_template | not_executable | `/usr/bin/python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 --head a17174c0c3593e0a7f7131889db441658c1e5977 --title feat(libc): export the std::__sce_v2 _Xtime_diff_to_millis2 helper --body /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-15490-a17174c0c359/pr-body.md` | | changed_export_abi_audit | not_executable | `/usr/bin/python3 tools/pr_abi_audit.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 --head a17174c0c3593e0a7f7131889db441658c1e5977 --json` | | python_syntax | not_applicable | `No changed Python implementation files.` | | related_python_unit_tests | not_applicable | `No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.` | | python_test_registration | not_applicable | `No changed test_*.py files.` | | live_dependency_and_mergeability_check | passed | `/usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 15490 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-15490-a17174c0c359/stack` | | build_dependent_cpp_tests | not_applicable | `Not run: C++ tests need exact-head binaries, which require a build; the precheck does not build.` | | test_quality_heuristics | failed | `/usr/bin/python3 /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-15490-a17174c0c359/head-a17174c0c359-537f0f72/tools/pr_test_quality.py --root /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-15490-a17174c0c359/head-a17174c0c359-537f0f72 --json core/libs/prx/libc/CMakeLists.txt core/libs/prx/libc/include/Api.hpp core/libs/prx/libc/src/TimeExtras.cpp core/libs/tests/GuestSceV2XtimeDiffToMillis.cpp docs/dev/debt/libc.md` | | negative_controls | not_applicable | `No changed Python test module in tools/ can be run as a no-build base-source control.` | Direct convention check: ```text All conventions checks passed. ``` ABI audit entry for the new symbol: ```json { "name": "_ZNSt8__sce_v222_Xtime_diff_to_millis2EPK8timespecS2__nid_postfix", "computed_nid": "qlkHBOfGcpQ", "declarations": ["core/libs/prx/libc/include/Api.hpp"], "definitions": ["core/libs/prx/libc/src/TimeExtras.cpp"], "explicit_aliases": [], "version": "not encoded by these source declarations; not verified" } ``` The audit also emitted three warnings outside this new export for `libc___cxa_finalize`, `longjmp_nid_postfix`, and `setjmp_nid_postfix`. </details> ## Negative control I did not run a mutation locally because the C++ test needs a build. The PR description reports four one-line mutations that made its new CTest fail and a restored-source differential run against the bundled module; I did not independently reproduce those results. ## Findings ### Blocking None found in the inspected change. ### Non-blocking - The implementation’s console equivalence and 10-million-call differential are author-reported; the original module and raw comparison logs are not attached. The PR does identify the module version and SHA-256, and records console/other-firmware coverage as unverified. - Required hosted checks are not all complete. I will re-check this head after Windows and queued macOS jobs finish before considering approval. ## Sources - [Implementation at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/a17174c0c3593e0a7f7131889db441658c1e5977/core/libs/prx/libc/src/TimeExtras.cpp#L87-L111) - [Export declaration at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/a17174c0c3593e0a7f7131889db441658c1e5977/core/libs/prx/libc/include/Api.hpp#L1299) - [Test cases at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/a17174c0c3593e0a7f7131889db441658c1e5977/core/libs/tests/GuestSceV2XtimeDiffToMillis.cpp#L16-L56) - [CMake test registration at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/a17174c0c3593e0a7f7131889db441658c1e5977/core/libs/prx/libc/CMakeLists.txt#L919-L927) - [Reverse-engineering evidence rules at the reviewed base](https://github.com/boykopovar/AnyPS5/blob/4f41f4c375f5abb487dbd184fbc150f31994d762/docs/dev/REVERSE_ENGINEERING.md) ## Not verified I did not run the C++ test, build the library, repeat the reported binary differential, inspect the original private firmware module, or test Linux/macOS runtime or console behavior. The hosted Windows job and queued macOS jobs have not completed. ## To get this to a good state No code change is requested from this review. Let the pending hosted jobs finish; I will re-check their exact-head results and then approve only if they pass and no new issue appears.
XairRrR commented 2026-11-03 15:36:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T15:36:47Z.

Review: APPROVED


Reviewed — approved

The new libc export std::__sce_v2::_Xtime_diff_to_millis2 (NID qlkHBOfGcpQ) merges cleanly and builds. Its test passes, and a negative control plus two mutations of my own each make the test fail. The one new failure in the scripted run is an AGC driver timing test this change cannot reach, and it passed on all three of my reruns.

What I ran

Head a17174c0c3593e0a7f7131889db441658c1e5977, main 4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree c6a2eed48267764ef9f01d6f1d60b02cc899d0c8. Release, GCC 14.2.0, Ninja, BUILD_TESTING=ON, Debian 13 VM (Xeon Gold 6136), lavapipe.

git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...a17174c0c3593e0a7f7131889db441658c1e5977
python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762
ctest --test-dir build --output-on-failure -R "^(guest_sce_v2_xtime_diff_to_millis|guest_time_extras|public_headers)$"
# three times:
ctest --test-dir build -R "^agc_driver_same_queue_label_wait_draw_pipeline$"
# negative control (production files from main), then two single-line mutations, then restore:
git show 4f41f4c375f5:core/libs/prx/libc/src/TimeExtras.cpp > core/libs/prx/libc/src/TimeExtras.cpp
git show 4f41f4c375f5:core/libs/prx/libc/include/Api.hpp > core/libs/prx/libc/include/Api.hpp
ninja -C build -j32 -l32 guest_sce_v2_xtime_diff_to_millis_tests
ninja -C build -j32 -l32 libc guest_sce_v2_xtime_diff_to_millis_tests
ctest --test-dir build --output-on-failure -R "^guest_sce_v2_xtime_diff_to_millis$"
git status --porcelain

Results

Check Result
git diff --check clean
check_conventions.py All conventions checks passed
Configure / build / libs (script) ok
guest_sce_v2_xtime_diff_to_millis passed (0.00 s)
guest_time_extras passed
public_headers passed (60 s; it is a Python check, and the time is spread across the whole tree)
agc_driver_same_queue_label_wait_draw_pipeline (script reported it as a new failure) passed on all 3 reruns; not caused by this PR, see below
Known failures on main (9) and the guest_net_ctl skip also on main, not counted against this PR
Vulkan validation comparison skipped by the script: no AGC driver, shader recompiler or VideoOut files changed

About the AGC failure: the PR only adds a libc function, a test and a debt entry. Nothing in the AGC test calls the new function. Its output (attempt N: … bumps with 16 waits) shows a timing-dependent check, and it passed on all three reruns. I treat it as a flake and do not count it against the PR.

Rerun output
100% tests passed, 0 tests failed out of 1   Total Test time (real) =   0.49 sec
100% tests passed, 0 tests failed out of 1   Total Test time (real) =   0.48 sec
100% tests passed, 0 tests failed out of 1   Total Test time (real) =   0.48 sec

Negative control

  • Production files from main: with TimeExtras.cpp and Api.hpp taken from main, the test no longer compiles ('_ZNSt8__sce_v222_Xtime_diff_to_millis2EPK8timespecS2__nid_postfix' was not declared in this scope).
  • Rounding constant: changing nanos + 999999 to nanos + 999998 makes the test fail with one nanosecond rounds up: 0.
  • Borrow: making the borrow path skip the extra second (seconds -= now->sec instead of seconds += ~now->sec) makes the test fail with borrow from seconds: 1001.
  • Restore: I put the merged files back from c6a2eed4 and rebuilt. Both tests pass again, and git status --porcelain is empty.

Findings

Blocking

None.

Non-blocking

None.

I checked the arithmetic by hand and it agrees with the description:

  • Negative target nanoseconds (core/libs/prx/libc/src/TimeExtras.cpp:91-96): -1, -10^9, -10^9-1 and -2·10^9 come out as (sec-1, 10^9-1), (sec-1, 0), (sec-2, 10^9-1) and (sec-2, 0).
  • Positive target nanoseconds (TimeExtras.cpp:97-101): 10^9, 2·10^9-1, 2·10^9 and 3·10^9-1 come out correctly.
  • Termination: both normalizations are closed-form, so the function ends for every input.
  • No undefined behaviour: all intermediate arithmetic is unsigned. The signed division at TimeExtras.cpp:110 has a positive divisor, so it cannot overflow.
  • Rules: the function has exactly one declaration, in Api.hpp. There are no code comments. The debt entry in docs/dev/debt/libc.md puts the gap first: console execution and other firmware or SDK versions are unverified. The checklist lines are present.

Not verified

  • I could not compare against the original libc.prx. I do not have the module, so the 26 expected values and the claimed 10,000,000-call side-by-side agreement are the author's evidence, not mine.
  • Windows, macOS, console behaviour and other firmware or SDK versions.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5755025955 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15490#pullrequestreview-5755025955). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T15:36:47Z. **Review:** APPROVED --- # Reviewed — approved The new libc export `std::__sce_v2::_Xtime_diff_to_millis2` (NID `qlkHBOfGcpQ`) merges cleanly and builds. Its test passes, and a negative control plus two mutations of my own each make the test fail. The one new failure in the scripted run is an AGC driver timing test this change cannot reach, and it passed on all three of my reruns. ## What I ran Head `a17174c0c3593e0a7f7131889db441658c1e5977`, `main` `4f41f4c375f5abb487dbd184fbc150f31994d762`, merged tree `c6a2eed48267764ef9f01d6f1d60b02cc899d0c8`. Release, GCC 14.2.0, Ninja, `BUILD_TESTING=ON`, Debian 13 VM (Xeon Gold 6136), lavapipe. ``` git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...a17174c0c3593e0a7f7131889db441658c1e5977 python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 ctest --test-dir build --output-on-failure -R "^(guest_sce_v2_xtime_diff_to_millis|guest_time_extras|public_headers)$" # three times: ctest --test-dir build -R "^agc_driver_same_queue_label_wait_draw_pipeline$" # negative control (production files from main), then two single-line mutations, then restore: git show 4f41f4c375f5:core/libs/prx/libc/src/TimeExtras.cpp > core/libs/prx/libc/src/TimeExtras.cpp git show 4f41f4c375f5:core/libs/prx/libc/include/Api.hpp > core/libs/prx/libc/include/Api.hpp ninja -C build -j32 -l32 guest_sce_v2_xtime_diff_to_millis_tests ninja -C build -j32 -l32 libc guest_sce_v2_xtime_diff_to_millis_tests ctest --test-dir build --output-on-failure -R "^guest_sce_v2_xtime_diff_to_millis$" git status --porcelain ``` ## Results | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | All conventions checks passed | | Configure / build / `libs` (script) | ok | | `guest_sce_v2_xtime_diff_to_millis` | passed (0.00 s) | | `guest_time_extras` | passed | | `public_headers` | passed (60 s; it is a Python check, and the time is spread across the whole tree) | | `agc_driver_same_queue_label_wait_draw_pipeline` (script reported it as a new failure) | passed on all 3 reruns; not caused by this PR, see below | | Known failures on `main` (9) and the `guest_net_ctl` skip | also on `main`, not counted against this PR | | Vulkan validation comparison | skipped by the script: no AGC driver, shader recompiler or VideoOut files changed | About the AGC failure: the PR only adds a libc function, a test and a debt entry. Nothing in the AGC test calls the new function. Its output (`attempt N: … bumps with 16 waits`) shows a timing-dependent check, and it passed on all three reruns. I treat it as a flake and do not count it against the PR. <details><summary>Rerun output</summary> ``` 100% tests passed, 0 tests failed out of 1 Total Test time (real) = 0.49 sec 100% tests passed, 0 tests failed out of 1 Total Test time (real) = 0.48 sec 100% tests passed, 0 tests failed out of 1 Total Test time (real) = 0.48 sec ``` </details> ## Negative control - **Production files from `main`:** with `TimeExtras.cpp` and `Api.hpp` taken from `main`, the test no longer compiles (`'_ZNSt8__sce_v222_Xtime_diff_to_millis2EPK8timespecS2__nid_postfix' was not declared in this scope`). - **Rounding constant:** changing `nanos + 999999` to `nanos + 999998` makes the test fail with `one nanosecond rounds up: 0`. - **Borrow:** making the borrow path skip the extra second (`seconds -= now->sec` instead of `seconds += ~now->sec`) makes the test fail with `borrow from seconds: 1001`. - **Restore:** I put the merged files back from `c6a2eed4` and rebuilt. Both tests pass again, and `git status --porcelain` is empty. ## Findings ### Blocking None. ### Non-blocking None. I checked the arithmetic by hand and it agrees with the description: - **Negative target nanoseconds** (`core/libs/prx/libc/src/TimeExtras.cpp:91-96`): -1, -10^9, -10^9-1 and -2·10^9 come out as (sec-1, 10^9-1), (sec-1, 0), (sec-2, 10^9-1) and (sec-2, 0). - **Positive target nanoseconds** (`TimeExtras.cpp:97-101`): 10^9, 2·10^9-1, 2·10^9 and 3·10^9-1 come out correctly. - **Termination:** both normalizations are closed-form, so the function ends for every input. - **No undefined behaviour:** all intermediate arithmetic is unsigned. The signed division at `TimeExtras.cpp:110` has a positive divisor, so it cannot overflow. - **Rules:** the function has exactly one declaration, in `Api.hpp`. There are no code comments. The debt entry in `docs/dev/debt/libc.md` puts the gap first: console execution and other firmware or SDK versions are unverified. The checklist lines are present. ## Not verified - I could not compare against the original `libc.prx`. I do not have the module, so the 26 expected values and the claimed 10,000,000-call side-by-side agreement are the author's evidence, not mine. - Windows, macOS, console behaviour and other firmware or SDK versions. <!-- anyps5-bots job=3411 head=a17174c0c3593e0a7f7131889db441658c1e5977 -->
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!15490
No description provided.