Skip to content

feat(libkernel): implement setitimer - #4382

Closed
MarcZX10 wants to merge 1 commit into
boykopovar:mainfrom
MarcZX10:codex/carry-setitimer-3735
Closed

MarcZX10 wants to merge 1 commit into
boykopovar:mainfrom
MarcZX10:codex/carry-setitimer-3735

Conversation

@MarcZX10

@MarcZX10 MarcZX10 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What

Carries the ready setitimer implementation from issue #3735 onto current main, integrating it with the existing getitimer and alarm timer state. ITIMER_REAL supports countdown, disarm, and periodic rearming. Invalid inputs return FreeBSD-style errors; unsupported CPU timers, sub-millisecond intervals, and signal delivery cases fail explicitly where the emulator lacks the required behavior.

This PR covers only the setitimer portion; getitimer remains as currently implemented on main.

Tested

  • Linux Release GCC 12.2 build: guest_itimer_tests, guest_signal_tests.
  • ctest --test-dir /tmp/AnyPS5-3735-build -R '^guest_itimer$' --output-on-failure: 1/1 passed.
  • ctest --test-dir /tmp/AnyPS5-3735-build -R '^guest_signals$' --output-on-failure: 1/1 passed.
  • python3 tools/check_conventions.py: passed.
  • git diff --check upstream/main: passed.

Checklist

  • Based on current main; no other open PR implements the same function
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; silent stubs are listed in TechnicalDebt
  • 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; carried from the original implementation commit with authorship preserved

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Progress report (1acfa7f → 12abb3f)

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

✅ 1 implemented
Library Name
libkernel setitimer_nid_postfix

@MarcZX10

Copy link
Copy Markdown
Contributor Author

The PR description was corrected to use the template section headings (### What, ### Tested, ### Checklist) and now passes the local conventions checker. The current hosted conventions result reflects the earlier body. Posting this update to trigger a fresh PR check against the corrected description.

@xXPBSXx

xXPBSXx commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Windows test: head 7fba6709c merged onto current main 3d8ffeb27 (clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release, -j4: full build 0 errors; ctest (guest_itimer): 1/1 passed; python tools/check_conventions.py --base upstream/main passed. I did not run the new tests against main without the change.

AI-assisted (Claude Code).

@blawesom

Copy link
Copy Markdown
Contributor

Rebase handoff — rebased onto current main, authorship unchanged (only a TechnicalDebt.md union conflict; both entries kept).

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV):

  • builds; tools/check_conventions.py --base origin/main passes
  • full suite: 954/954 passed

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/4382
git checkout <your branch>
git merge --ff-only FETCH_HEAD

@MarcZX10
MarcZX10 force-pushed the codex/carry-setitimer-3735 branch from 7fba670 to ca9bf36 Compare October 12, 2026 16:08
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@MarcZX10
MarcZX10 force-pushed the codex/carry-setitimer-3735 branch from ca9bf36 to d39d70d Compare October 12, 2026 18:35
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
PS5MC (PPSA99420) imports setitimer (hPWDGx8ioXQ, aerolib) at registry
index 472, after tcsetpgrp and before getitimer. Predicted stop:
"FAIL: unresolved ELF import hPWDGx8ioXQ from libkernel.prx".

setitimer follows FreeBSD 11.4 kern_time.c (8c639945) sys_setitimer and
kern_setitimer: EINVAL for an unknown timer and for an itimerfix failure
or more than INT32_MAX / 2 seconds; a zero value clears the interval and
disarms; a null value reads the timer, EFAULT when the output is null too.
ITIMER_REAL shares the alarm state, now with an interval that re-arms it
as realitexpire does; alarm clears it, as FreeBSD's alarm.c does.

Guest SIGALRM handlers are not run, so an expiry with a handler, or with
SIGALRM blocked (signals are never left pending), throws naming the
interval; SIG_IGN drops it and the default disposition exits with 142,
as alarm already did. Intervals below 1 ms throw (itimerfix rounds them
to tick / 16 and the console's hz is unknown). ITIMER_VIRTUAL and
ITIMER_PROF throw when armed and read and disarm as zero.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 6bef7bf)
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@MarcZX10

Copy link
Copy Markdown
Contributor Author

Closing this stale carry as superseded by merged #3800, which includes the same setitimer implementation plus the interval-reporting fix for getitimer. The current head here would also remove that merged getitimer interval reporting if rebased as written, so it no longer has a safe unique diff to preserve.

@MarcZX10 MarcZX10 closed this Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build docs libkernel needs rebase Conflicts with main, rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants