CLK_TCK
Andreas Jaeger
aj@suse.de
Tue Feb 6 06:00:00 GMT 2001
The CLK_TCK definitions confuse me.
sysdeps/unix/sysv/linux/i386/bits/time.h uses:
# if !defined __STRICT_ANSI__ && !defined __USE_XOPEN2K
/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK
presents the real value for clock ticks per second for the system. */
# include <bits/types.h>
extern long int __sysconf (int);
# define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */
# endif
and time/time.h has:
# if defined __USE_POSIX && !defined __USE_XOPEN2K
# ifndef CLK_TCK
# define CLK_TCK CLOCKS_PER_SEC
# endif
# endif
Why do we have both definitions?
With -D_GNU_SOURCE you don't get any at all since _GNU_SOURCE implies
__USE_XOPEN2K:
t.c: In function `main':
t.c:9: `CLK_TCK' undeclared (first use in this function)
t.c:9: (Each undeclared identifier is reported only once
t.c:9: for each function it appears in.)
Using -D_POSIX_SOURCE fixes this - but that's not what I want. IMO we
should make CLK_TCK available with _GNU_SOURCE.
What's the best way to fix this mess?
Andreas
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <stdio.h>
#include <time.h>
int
main (void)
{
printf ("CLK_TCK: %ld\n", (long)CLK_TCK);
return 0;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj
More information about the Libc-alpha
mailing list