Skip to content

feat(libkernel_sys): implement settimeofday - #9682

Draft
Gruzzberry wants to merge 1 commit into
boykopovar:mainfrom
Gruzzberry:feat/settimeofday
Draft

Gruzzberry wants to merge 1 commit into
boykopovar:mainfrom
Gruzzberry:feat/settimeofday

Conversation

@Gruzzberry

@Gruzzberry Gruzzberry commented Oct 22, 2026 •

Copy link
Copy Markdown

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 (8b3a6ba → 363acba)

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

✅ 1 implemented
Library Name
libkernel_sys settimeofday_nid_postfix

@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 L2471-2480

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 5021 core/libs/prx/libkernel/Time/Time.cpp
core/libs/prx/libkernel_sys/Export.cpp
docs/dev/debt/libkernel.md
PR 5528 core/libs/prx/libkernel_sys/Export.cpp
core/libs/tests/GuestKernelSys.cpp
PR 6044 core/libs/tests/GuestKernelSys.cpp
PR 6149 docs/dev/debt/libkernel.md
PR 6469 docs/dev/debt/libkernel.md
PR 6525 core/libs/prx/libkernel_sys/Export.cpp
core/libs/tests/GuestKernelSys.cpp
PR 6740 docs/dev/debt/libkernel.md
PR 6830 docs/dev/debt/libkernel.md
PR 6936 docs/dev/debt/libkernel.md
PR 7049 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 7201 core/libs/prx/libkernel/Time/Time.cpp
core/libs/prx/libkernel_sys/Export.cpp
PR 7509 docs/dev/debt/libkernel.md
PR 7565 docs/dev/debt/libkernel.md
PR 7653 docs/dev/debt/libkernel.md
PR 8010 docs/dev/debt/libkernel.md
PR 8344 docs/dev/debt/libkernel.md
PR 8373 docs/dev/debt/libkernel.md
PR 8457 core/libs/prx/libkernel_sys/Export.cpp
core/libs/tests/GuestKernelSys.cpp
PR 8520 docs/dev/debt/libkernel.md
PR 8553 docs/dev/debt/libkernel.md
PR 8658 core/libs/prx/libkernel/Time/Time.cpp
docs/dev/debt/libkernel.md
PR 8701 core/libs/prx/libkernel_sys/Export.cpp
core/libs/tests/GuestKernelSys.cpp
PR 9019 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
PR 9103 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
core/libs/tests/GuestKernelSys.cpp
PR 9109 docs/dev/debt/libkernel.md
PR 9133 docs/dev/debt/libkernel.md
PR 9161 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
PR 9162 core/libs/prx/libkernel_sys/Export.Discovery.cpp
PR 9322 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
core/libs/tests/GuestKernelSys.cpp
PR 9382 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
PR 9561 docs/dev/debt/libkernel.md
PR 9573 core/libs/prx/libkernel_sys/Export.Discovery.cpp
docs/dev/debt/libkernel.md
PR 9669 docs/dev/debt/libkernel.md
PR 9713 core/libs/prx/libkernel_sys/Export.Discovery.cpp
core/libs/prx/libkernel_sys/Export.cpp
core/libs/tests/GuestKernelSys.cpp
PR 9826 core/libs/prx/libkernel_sys/Export.cpp

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

Copy link
Copy Markdown
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.

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>
@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.

This branch has not been deployed

No deployments
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.

2 participants