[PATCH v3] time: Add TIME_MONOTONIC, TIME_ACTIVE, and TIME_THREAD_ACTIVE
Joseph Myers
josmyers@redhat.com
Mon Dec 1 22:13:16 GMT 2025
On Mon, 1 Dec 2025, Adhemerval Zanella wrote:
> +/* Helper that converts from C timebase to POSIX clockid_t. */
> +static inline clockid_t
> +clock_from_timebase (int timebase)
> +{
> + _Static_assert (TIME_UTC - 1 == CLOCK_REALTIME,
> + "TIME_UTC != CLOCK_REALTIME - 1");
> + _Static_assert (TIME_MONOTONIC -1 == CLOCK_MONOTONIC,
> + "TIME_UTC != CLOCK_MONOTONIC - 1");
> + _Static_assert (TIME_ACTIVE - 1 == CLOCK_PROCESS_CPUTIME_ID,
> + "TIME_UTC != CLOCK_PROCESS_CPUTIME_ID - 1");
> + _Static_assert (TIME_THREAD_ACTIVE - 1 == CLOCK_THREAD_CPUTIME_ID,
> + "TIME_UTC != CLOCK_THREAD_CPUTIME_ID - 1");
> + return timebase - 1;
The _Static_assert messages don't seem to match the content of the
assertions (both regarding the name used on the left, and regarding which
side has 1 subtracted).
--
Joseph S. Myers
josmyers@redhat.com
More information about the Libc-alpha
mailing list