standards/96016: clock_getres et al should be in <time.h>
bde at zeta.org.au
Wed Apr 19 10:30:25 UTC 2006
The following reply was made to PR standards/96016; it has been noted by GNATS.
From: Bruce Evans <bde at zeta.org.au>
To: Robert Millan <rmh at aybabtu.com>
Cc: FreeBSD-gnats-submit at FreeBSD.org, freebsd-standards at FreeBSD.org
Subject: Re: standards/96016: clock_getres et al should be in <time.h>
Date: Wed, 19 Apr 2006 20:22:11 +1000 (EST)
On Tue, 18 Apr 2006, Robert Millan wrote:
> POSIX says that the following functions should be declared in <time.h>, rather
> than <sys/time.h>:
> clock_getres, clock_gettime, clock_settime
Er, that's why they _are_ in declared in <time.h>. From
"cvs ann src/include/time.h":
% 1.24 (wollman 27-Jun-02): #if __POSIX_VISIBLE >= 199309
% 1.24 (wollman 27-Jun-02): int clock_getres(clockid_t, struct timespec *);
% 1.24 (wollman 27-Jun-02): int clock_gettime(clockid_t, struct timespec *);
% 1.24 (wollman 27-Jun-02): int clock_settime(clockid_t, const struct timespec *);
% 1.32 (das 02-Apr-05): /* XXX missing: clock_nanosleep() */
% 1.24 (wollman 27-Jun-02): int nanosleep(const struct timespec *, struct timespec *);
% 1.24 (wollman 27-Jun-02): #endif /* __POSIX_VISIBLE >= 199309 */
The main bugs in this area are:
- <sys/time.h> includes <time.h> in the !_KERNEL case. This gives lots of
namespace pollution in <sys/time.h> including clock_getres() etc., and
worse, struct tm etc. Lots of FreeBSD sources depend on this pollution.
When I last tried removing this include (almost 4 years ago), there were
several hundred lines of error output.
- all CLOCK_* ids are declared in <sys/time.h> where they cause namespace
pollution due to not being under any visibility ifdefs.
- the visibility ifdefs for the declarations of the CLOCK_* ids in <time.h>
are mostly wrong.
- all CLOCK_* ids are declared with style bugs in <sys/time.h> and <time.h>.
Duplication should be avoided by declaring the CLOCK_* ids in a little
namespace-nonpolluting header in <sys>, but there are already too many of
those, especially for times (there are <sys/timespec.h>, sys/<_timespec.h>
More information about the freebsd-standards