Skip to content

feat(libkernel_sys): implement settimeofday - #9682

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
Gruzzberry:feat/settimeofday
Oct 25, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
Gruzzberry:feat/settimeofday

Conversation

@Gruzzberry

@Gruzzberry Gruzzberry commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What

settimeofday was a throwing stub in libkernel_sys. FreeBSD 11.4's kern_settimeofday (called by sys_settimeofday, which treats a null pointer as not given) rejects a time with a negative second count or a microsecond count outside 0 to 999999 with EINVAL before changing anything, sets the clock from a valid time, and only then stores the time zone, which sys_gettimeofday reports.

SetTimeOfDay_nid_no_patch in Time.cpp, next to clock_settime, does the same checks. A valid time throws, naming it, as clock_settime does for CLOCK_REALTIME, because the host clock is never set; the time zone is then not stored. A time zone given without a time is kept for the process, and gettimeofday now reports it instead of 0 and 0 (which it still reports until one is set). settimeofday in libkernel_sys forwards to the helper. sceKernelGettimezone is unchanged and still reports 0 and 0: whether the console's reads the same value is not known. The debt entry next to clock_settime records the throw, the zone and the unverified privilege check.

Tested

Windows 11 (10.0.26200), WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, -DBUILD_TESTING=ON, on main d6eafa5.

Overlaps

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 silent stubs added
  • 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. Merge order: after feat(libkernel_sys): implement sigqueue #9389 (neighbouring stub in Export.Discovery.cpp); this PR then rebases.
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

AI-assisted (Claude Code).

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Progress report (1ee8f4b → e6b0732)

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

✅ 1 implemented
Library Name
libkernel_sys settimeofday_nid_postfix

Changed libraries (implemented exports)

Library Before After Change
libkernel_sys 69/531 (12.99%) 70/531 (13.18%) +0.19 pp

@Gruzzberry Gruzzberry mentioned this pull request Oct 22, 2026
12 tasks done

@MarcZX10 MarcZX10 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation and current-main conventions check look consistent with the documented host-clock limitation; I did not independently reproduce the author-reported Windows test run, and this checkout has no build configured for this head. I found one repository-readiness issue before this can proceed: 1. The current open #9389 changes the adjacent sigqueue stub in Export.Discovery.cpp; a pairwise merge check reports a conflict in that file. The PR body notes that one side will need rebasing, but the contribution rule asks authors to agree on the order and put the dependency on the checklist when one must wait. Please coordinate with #9389 and update the checklist accordingly. This head is also two commits behind current main; refresh it and rerun the relevant checks after the #9389 overlap order is resolved. The existing Windows test report and the passing conventions/eligibility checks are noted; product test jobs are skipped automatically on this PR.

I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

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
PR 9389 core/libs/prx/libkernel_sys/Export.Discovery.cpp L2302-2308
PR 9713 core/libs/tests/GuestKernelSys.cpp L3
PR 10975 core/libs/prx/libkernel/Time/Time.cpp L543-546, L563-565

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 4630 docs/dev/debt/libkernel.md
PR 5021 core/libs/prx/libkernel/Time/Time.cpp
core/libs/prx/libkernel_sys/Export.cpp
docs/dev/debt/libkernel.md
PR 6149 docs/dev/debt/libkernel.md
PR 6740 docs/dev/debt/libkernel.md
PR 6830 docs/dev/debt/libkernel.md
PR 6936 docs/dev/debt/libkernel.md
PR 7088 docs/dev/debt/libkernel.md
PR 7105 docs/dev/debt/libkernel.md
PR 7121 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7192 docs/dev/debt/libkernel.md
PR 7201 core/libs/prx/libkernel/Time/Time.cpp
core/libs/prx/libkernel_sys/Export.cpp
PR 7447 docs/dev/debt/libkernel.md
PR 7509 docs/dev/debt/libkernel.md
PR 7804 core/libs/prx/libkernel/Time/Time.cpp
docs/dev/debt/libkernel.md
PR 8010 docs/dev/debt/libkernel.md
PR 8520 docs/dev/debt/libkernel.md
PR 8605 docs/dev/debt/libkernel.md
PR 9097 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
core/libs/tests/GuestKernelSys.cpp
PR 9156 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9199 docs/dev/debt/libkernel.md
PR 9242 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9284 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9293 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9297 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9302 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9383 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9509 docs/dev/debt/libkernel.md
PR 9557 docs/dev/debt/libkernel.md
PR 9566 docs/dev/debt/libkernel.md
PR 9575 docs/dev/debt/libkernel.md
PR 9632 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9669 docs/dev/debt/libkernel.md
PR 9684 docs/dev/debt/libkernel.md
PR 9826 core/libs/prx/libkernel_sys/Export.cpp
PR 9938 docs/dev/debt/libkernel.md
PR 10061 docs/dev/debt/libkernel.md
PR 10442 docs/dev/debt/libkernel.md
PR 10499 core/libs/prx/libkernel/Time/Time.cpp
docs/dev/debt/libkernel.md
PR 10501 docs/dev/debt/libkernel.md
PR 10621 docs/dev/debt/libkernel.md
PR 10657 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 10666 docs/dev/debt/libkernel.md
PR 10749 docs/dev/debt/libkernel.md
PR 10767 docs/dev/debt/libkernel.md
PR 10898 docs/dev/debt/libkernel.md
PR 11002 docs/dev/debt/libkernel.md
PR 11047 docs/dev/debt/libkernel.md

@Gruzzberry
Gruzzberry marked this pull request as draft October 22, 2026 11:41
@Gruzzberry

Copy link
Copy Markdown
Contributor Author

Holding this as a draft, following the direction on #5239: the open queue is above 700 and no named title needs this change on current main. I will only mark it ready again with a current-main title ID, its Game bring-up discussion and the log line where it stops on this, or once the queue is below 700. Thanks for the reviews so far; the requested fixes are being made on the branch in the meantime.

@MarcZX10

MarcZX10 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

I’ve noticed that asking you to hold this PR was unnecessary. It’s fine to keep submitting PRs; maintainers will handle them in due course.

@Gruzzberry

Copy link
Copy Markdown
Contributor Author

Rebased onto main 938812d and marked ready for review, as @MarcZX10 noted the #5239 hold does not need to apply here. On Windows (MinGW GCC 15.2.0): the focused tests pass, check_conventions.py passes, and the full suite (2029 tests) on main merged with #9442, #9469, #9474, #9487, #9496, #9661 and #9682 matches main itself, apart from parallel-run flakes that pass when run alone.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 23, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 23, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 24, 2026
FreeBSD 11.4's kern_settimeofday rejects a timeval with a microsecond
field outside 0 to 999999 or a negative second field with EINVAL before
changing anything, sets the clock from a valid timeval, and then stores
the timezone, which gettimeofday reports. settimeofday now checks the
timeval the same way and throws for a valid one, as clock_settime does,
because the host clock is not changed. A timezone given without a
timeval is stored and gettimeofday reports it instead of 0 and 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gruzzberry

Copy link
Copy Markdown
Contributor Author

Rebased onto main 4017310: the test now takes its declarations from the shared headers (adding Time/include/Time.hpp for gettimeofday), and the settimeofday declaration replaces the stub one in libkernel_sys/include/Api.hpp. guest_kernel_sys and the time tests pass three runs out of three, also merged with #9442; check_conventions.py passes.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 25, 2026
@adriadam10 adriadam10 self-assigned this Oct 25, 2026
@adriadam10
adriadam10 dismissed MarcZX10’s stale review October 25, 2026 18:36

Dismissing a stale review: the requested changes were addressed after it (new head) and the merge queue blocks on it. Please request changes again if anything is still open.

@adriadam10
adriadam10 merged commit d19a809 into boykopovar:main Oct 25, 2026
10 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the order of validation and zone storage against FreeBSD 11.4 kern_settimeofday, the test (fails on main, pins EINVAL rows, the throw and the stored zone) and the debt entry. The conflict with #9389 @MarcZX10 raised is gone on the current head; merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants