From ce23171bfae282c75a47443b76b804369aa09f22 Mon Sep 17 00:00:00 2001 From: Till Wegmueller Date: Sat, 11 Jul 2026 14:48:01 +0200 Subject: [PATCH] solarish: add CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID 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). --- libc-test/semver/solarish.txt | 2 ++ src/unix/solarish/mod.rs | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libc-test/semver/solarish.txt b/libc-test/semver/solarish.txt index ba090304409ba..212436ffc87de 100644 --- a/libc-test/semver/solarish.txt +++ b/libc-test/semver/solarish.txt @@ -1,6 +1,8 @@ AIO_ALLDONE AIO_CANCELED AIO_NOTCANCELED +CLOCK_PROCESS_CPUTIME_ID +CLOCK_THREAD_CPUTIME_ID IPV6_BOUND_IF IPV6_DONTFRAG IPV6_HOPLIMIT diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 507ca30198940..6537a94fbe8b5 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -1309,15 +1309,16 @@ pub const SIGSTKSZ: size_t = 8192; // https://illumos.org/man/3c/clock_gettime // https://github.com/illumos/illumos-gate/ // blob/HEAD/usr/src/lib/libc/amd64/sys/__clock_gettime.s -// clock_gettime(3c) doesn't seem to accept anything other than CLOCK_REALTIME -// or __CLOCK_REALTIME0 // // https://github.com/illumos/illumos-gate/ // blob/HEAD/usr/src/uts/common/sys/time_impl.h // Confusing! CLOCK_HIGHRES==CLOCK_MONOTONIC==4 // __CLOCK_REALTIME0==0 is an obsoleted version of CLOCK_REALTIME==3 +// CLOCK_PROF==CLOCK_THREAD_CPUTIME_ID==2 (distinct from CLOCK_VIRTUAL==1) pub const CLOCK_REALTIME: crate::clockid_t = 3; pub const CLOCK_MONOTONIC: crate::clockid_t = 4; +pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 5; +pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 2; pub const TIMER_RELTIME: c_int = 0; pub const TIMER_ABSTIME: c_int = 1;