HomeFreeBSD

time.h: reduce CLOCK_ namespace pollution, move to _clock_id.h

Description

time.h: reduce CLOCK_ namespace pollution, move to _clock_id.h

Attempt to comply with the strict namespace pollution requirements of
_POSIX_C_SOURCE. Add guards to limit visitbility of CLOCK_ and TIMER_
defines as appropriate. Only define the CLOCK_ variables relevant to the
specific standards. Move all the sharing to sys/_clock_id.h and make
time.h and sys/time.h both include that rather than copy due to the
now large number of clocks and compat defines.

Please note: The old time.h previously used these newer dates:
CLOCK_REALTIME 199506
CLOCK_MONOTONIC 200112
CLOCK_THREAD_CPUTIME_ID 200112
CLOCK_PROCESS_CPUTIME_ID 200112

but glibc defines all of these for 199309. glibc uses this date for all
these values, however, only CLOCK_REALTIME was in IEEE 1003.1b. Add a
comment about this to document it. A large number of programs and
libraries assume that these will be defined for _POSIX_C_SOURCE =

In addition, leak CLOCK_UPTIME_FAST for the pocl package until it can be
updated to use a simple CLOCK_MONOTONIC.

Reviewed by: kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31056

(cherry picked from commit 7b797ba27a714594dac910035d857e653d566b19)

Details

Provenance
impAuthored on Jul 30 2021, 11:10 PM
Reviewer
kib
Differential Revision
D31056: time.h: reduce CLOCK_ namespace pollution, move to _clock_id.h
Parents
rG363f9e1114eb: nanobsd: adopt dhcpd to latest conventions
Branches
Unknown
Tags
Unknown