standards/96016: clock_getres et al should be in <time.h>
Bruce Evans
bde at zeta.org.au
Wed Apr 19 10:22:15 UTC 2006
On Tue, 18 Apr 2006, Robert Millan wrote:
>> Description:
> 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>
and <_sys/_timeval.h>).
Bruce
More information about the freebsd-standards
mailing list