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 = 199309. 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
This commit is contained in:
+1
-29
@@ -46,6 +46,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/_null.h>
|
||||
#include <sys/_types.h>
|
||||
#include <sys/_clock_id.h>
|
||||
|
||||
#if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE
|
||||
/*
|
||||
@@ -97,35 +98,6 @@ typedef __pid_t pid_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* These macros are also in sys/time.h. */
|
||||
#if !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 199506
|
||||
#define CLOCK_REALTIME 0
|
||||
#endif /* !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 199506 */
|
||||
#if !defined(CLOCK_VIRTUAL) && __BSD_VISIBLE
|
||||
#define CLOCK_VIRTUAL 1
|
||||
#define CLOCK_PROF 2
|
||||
#endif /* !defined(CLOCK_VIRTUAL) && __BSD_VISIBLE */
|
||||
#if !defined(CLOCK_MONOTONIC) && __POSIX_VISIBLE >= 200112
|
||||
#define CLOCK_MONOTONIC 4
|
||||
#define CLOCK_UPTIME 5 /* FreeBSD-specific. */
|
||||
#define CLOCK_UPTIME_PRECISE 7 /* FreeBSD-specific. */
|
||||
#define CLOCK_UPTIME_FAST 8 /* FreeBSD-specific. */
|
||||
#define CLOCK_REALTIME_PRECISE 9 /* FreeBSD-specific. */
|
||||
#define CLOCK_REALTIME_FAST 10 /* FreeBSD-specific. */
|
||||
#define CLOCK_MONOTONIC_PRECISE 11 /* FreeBSD-specific. */
|
||||
#define CLOCK_MONOTONIC_FAST 12 /* FreeBSD-specific. */
|
||||
#define CLOCK_SECOND 13 /* FreeBSD-specific. */
|
||||
#define CLOCK_THREAD_CPUTIME_ID 14
|
||||
#define CLOCK_PROCESS_CPUTIME_ID 15
|
||||
#endif /* !defined(CLOCK_MONOTONIC) && __POSIX_VISIBLE >= 200112 */
|
||||
|
||||
#if __BSD_VISIBLE
|
||||
#define TIMER_RELTIME 0x0 /* relative timer */
|
||||
#endif
|
||||
#if !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 199506
|
||||
#define TIMER_ABSTIME 0x1 /* absolute timer */
|
||||
#endif /* !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 199506 */
|
||||
|
||||
struct tm {
|
||||
int tm_sec; /* seconds after the minute [0-60] */
|
||||
int tm_min; /* minutes after the hour [0-59] */
|
||||
|
||||
Reference in New Issue
Block a user