feat(libkernel): query real-time alarms with getitimer #3572

Merged
Lorkydey merged 1 commit from upstream-pr/3572 into main 2026-10-11 21:35:46 +00:00
Lorkydey commented 2026-10-11 13:32:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Lorkydey on 2026-10-11T13:32:23Z.


What

PS5MC 1.2 (PPSA99420, Kodi 22) imports getitimer from libkernel, but main a11c8f7f does not export it. Its public release's ELF dynamic symbol 457 is the undefined function J1H1QRCJf2Q#M#N; the import metadata maps this to libkernel. The same missing function is listed for PS5MC in #1578. Searches for the function and its NID found no existing PR; the relevant closed homebrew bundle #3293 also contains no implementation of it.

Implement getitimer(ITIMER_REAL) using the existing guest alarm's synchronized monotonic deadline. It returns normalized, signed 64-bit seconds/microseconds, reports an inactive or expired alarm as zero, and does not reset or cancel it. The interval is zero because the current alarm backend is one-shot. Invalid selectors return guest EINVAL; a null real-timer output returns EFAULT; success preserves errno. CPU interval timers (ITIMER_VIRTUAL and ITIMER_PROF) explicitly throw because those timers are not implemented.

The ABI and relative-time/error rules follow FreeBSD's getitimer implementation and itimerval definition. No new comments, Markdown changes, dependencies, or generated files.

Tested

Windows 11 Pro 26100, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON.

  • With the new regression test but main's unchanged implementation, the test executable fails to link: undefined reference to getitimer_nid_postfix.
  • Full build succeeds. All six targeted tests pass: guest_getitimer, guest_signals, guest_signal_sets, guest_sigtimedwait, guest_process_time, and guest_cpu_time_clocks.
  • The new behavioral test takes 1.17 seconds. It covers countdown, cancellation, expiry, simultaneous readers, alarms longer than INT32_MAX seconds, output bounds/layout, errno, invalid inputs, and explicit CPU-timer refusal.
  • Patched libkernel.prx exports J1H1QRCJf2Q. Conventions and diff whitespace checks pass.
  • tools/progress.py: system libraries 2903/3383 (85.81%) -> 2904/3384 (85.82%). This is the source counter, not a claim that CPU timers or PS5MC startup are fully supported.

Title evidence: the public PS5MC 1.2 Kodi 22 release, archive SHA256 5a9eeff4a0024a341a4924b8d283fe65b4ff94d7f5dbea446c8a677c4db157b6, verified against the catalog and inspected without executing it. PS5MC was not launched; this does not establish getitimer as its first startup failure. Linux and macOS runtime tests were not run locally.

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; no silent stubs
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes (Codex)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4819428415 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3572). Originally posted by [Lorkydey](https://github.com/Lorkydey) on 2026-10-11T13:32:23Z. --- ### What PS5MC 1.2 (PPSA99420, Kodi 22) imports `getitimer` from `libkernel`, but main `a11c8f7f` does not export it. Its public release's ELF dynamic symbol 457 is the undefined function `J1H1QRCJf2Q#M#N`; the import metadata maps this to `libkernel`. The same missing function is listed for PS5MC in #1578. Searches for the function and its NID found no existing PR; the relevant closed homebrew bundle #3293 also contains no implementation of it. Implement `getitimer(ITIMER_REAL)` using the existing guest alarm's synchronized monotonic deadline. It returns normalized, signed 64-bit seconds/microseconds, reports an inactive or expired alarm as zero, and does not reset or cancel it. The interval is zero because the current alarm backend is one-shot. Invalid selectors return guest `EINVAL`; a null real-timer output returns `EFAULT`; success preserves errno. CPU interval timers (`ITIMER_VIRTUAL` and `ITIMER_PROF`) explicitly throw because those timers are not implemented. The ABI and relative-time/error rules follow [FreeBSD's getitimer implementation](https://github.com/freebsd/freebsd-src/blob/releng/9.2/sys/kern/kern_time.c#L497-L538) and [itimerval definition](https://github.com/freebsd/freebsd-src/blob/releng/9.2/sys/sys/time.h). No new comments, Markdown changes, dependencies, or generated files. ### Tested Windows 11 Pro 26100, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. - With the new regression test but main's unchanged implementation, the test executable fails to link: `undefined reference to getitimer_nid_postfix`. - Full build succeeds. All six targeted tests pass: `guest_getitimer`, `guest_signals`, `guest_signal_sets`, `guest_sigtimedwait`, `guest_process_time`, and `guest_cpu_time_clocks`. - The new behavioral test takes 1.17 seconds. It covers countdown, cancellation, expiry, simultaneous readers, alarms longer than INT32_MAX seconds, output bounds/layout, errno, invalid inputs, and explicit CPU-timer refusal. - Patched `libkernel.prx` exports `J1H1QRCJf2Q`. Conventions and diff whitespace checks pass. - `tools/progress.py`: system libraries 2903/3383 (85.81%) -> 2904/3384 (85.82%). This is the source counter, not a claim that CPU timers or PS5MC startup are fully supported. Title evidence: the [public PS5MC 1.2 Kodi 22 release](https://github.com/VivaLaVent/PS5MC/releases/tag/1.2), archive SHA256 `5a9eeff4a0024a341a4924b8d283fe65b4ff94d7f5dbea446c8a677c4db157b6`, verified against the catalog and inspected without executing it. PS5MC was not launched; this does not establish `getitimer` as its first startup failure. Linux and macOS runtime tests were not run locally. ### 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; no silent stubs - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes (Codex)
github-actions[bot] commented 2026-10-11 13:32:42 +00:00 (Migrated from github.com)

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


Progress report (a11c8f7 → 1fc9b4d)

📈 System libraries: 85.82% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel getitimer_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109563365 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3572#issuecomment-6109563365). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T13:32:42Z. --- <!-- progress-report --> ### Progress report (a11c8f7 → 1fc9b4d) 📈 **System libraries**: 85.82% (+0.01%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel | `getitimer_nid_postfix` | </details>
adriadam10 commented 2026-10-11 21:35:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:35:43Z.


Checked build + guest_getitimer on Linux (passes; fails to link without the change), FreeBSD getitimer errno order/ABI, no NID alias duplicates; merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114037179 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3572#issuecomment-6114037179). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T21:35:43Z. --- Checked build + `guest_getitimer` on Linux (passes; fails to link without the change), FreeBSD getitimer errno order/ABI, no NID alias duplicates; merging.
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!3572
No description provided.