Skip to content

solarish: add CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID - #5274

Merged
tgross35 merged 1 commit into
rust-lang:mainfrom
Toasterson:solarish-cputime-clock-ids
Jul 21, 2026
Merged

solarish: add CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID#5274
tgross35 merged 1 commit into
rust-lang:mainfrom
Toasterson:solarish-cputime-clock-ids

Conversation

@Toasterson

Copy link
Copy Markdown
Contributor

Description

This does two things described below for reference if somebody needs to verify those.

illumos usr/src/uts/common/sys/time_impl.h defines CLOCK_THREAD_CPUTIME_ID=2 (alias CLOCK_PROF) and
CLOCK_PROCESS_CPUTIME_ID=5, but libc never bound them for solarish, so any crate that references these clock ids (e.g. the cpu-time crate) fails to build on illumos/solaris. And since I needed that I implemented them :)

Also drops the stale comment claiming clock_gettime(3c) "doesn't seem to accept anything other than CLOCK_REALTIME". This got fixed with illumos-gate commit dea9f5e6a49 (2021-10-16, "14126 clock_gettime() could work with thread/proc clocks"), which taught clock_gettime(3c) to honor the thread/process CPU-time clocks; both Oracle Solaris 11.4 and current illumos document and accept them.

Sources

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

@rustbot label +stable-nominated

illumos usr/src/uts/common/sys/time_impl.h defines
CLOCK_THREAD_CPUTIME_ID=2 (alias CLOCK_PROF) and
CLOCK_PROCESS_CPUTIME_ID=5, but libc never bound them for solarish,
so any crate that references these clock ids (e.g. the cpu-time
crate) fails to build on illumos/solaris.

Also drops the stale comment claiming clock_gettime(3c) "doesn't
seem to accept anything other than CLOCK_REALTIME" -- that was true
prior to illumos-gate commit dea9f5e6a49 (2021-10-16, "14126
clock_gettime() could work with thread/proc clocks"), which taught
clock_gettime(3c) to honor the thread/process CPU-time clocks; both
Oracle Solaris 11.4 and current illumos document and accept them.

Verified at runtime on OpenIndiana 2026.04 via clock_gettime(3c)
with both clock ids (both return 0).
@rustbot

rustbot commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in a solarish module

cc @jclulow, @pfmooney

@rustbot rustbot added O-solarish O-unix S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Jul 11, 2026

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

@tgross35
tgross35 added this pull request to the merge queue Jul 21, 2026
Merged via the queue into rust-lang:main with commit efe08d7 Jul 21, 2026
57 checks passed
@Toasterson
Toasterson deleted the solarish-cputime-clock-ids branch July 21, 2026 08:06
jollaitbot pushed a commit to sailfishos-mirror/rust-libc that referenced this pull request Jul 22, 2026
illumos usr/src/uts/common/sys/time_impl.h defines
CLOCK_THREAD_CPUTIME_ID=2 (alias CLOCK_PROF) and
CLOCK_PROCESS_CPUTIME_ID=5, but libc never bound them for solarish,
so any crate that references these clock ids (e.g. the cpu-time
crate) fails to build on illumos/solaris.

Also drops the stale comment claiming clock_gettime(3c) "doesn't
seem to accept anything other than CLOCK_REALTIME" -- that was true
prior to illumos-gate commit dea9f5e6a49 (2021-10-16, "14126
clock_gettime() could work with thread/proc clocks"), which taught
clock_gettime(3c) to honor the thread/process CPU-time clocks; both
Oracle Solaris 11.4 and current illumos document and accept them.

Verified at runtime on OpenIndiana 2026.04 via clock_gettime(3c)
with both clock ids (both return 0).

(backport <rust-lang/libc#5274>)
(cherry picked from commit efe08d7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-solarish O-unix stable-nominated This PR should be considered for cherry-pick to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants