mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-23 13:30:06 +00:00
57ada0e7e7
C99 specifies that CLOCKS_PER_SEC is an expression with the type clock_t. This patch adds a generic <bits/time2.h> to define CLOCKS_PER_SEC and provides the Linux/x86-64 version of <bits/time2.h> to support x32. [BZ #17797] * bits/time.h (CLOCKS_PER_SEC): Changed to ((clock_t) 1000000). * sysdeps/unix/sysv/linux/bits/time.h (CLOCKS_PER_SEC): Likewise. * sysdeps/unix/sysv/linux/clock.c (clock): _Static_assert CLOCKS_PER_SEC == 1000000. * time/clocktest.c (main): Replace %ld with %jd and cast to intmax_t.
37 lines
671 B
C
37 lines
671 B
C
#include <signal.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
#include <unistd.h>
|
|
|
|
volatile int gotit = 0;
|
|
|
|
static void
|
|
alarm_handler (int signal)
|
|
{
|
|
gotit = 1;
|
|
}
|
|
|
|
|
|
int
|
|
main (int argc, char ** argv)
|
|
{
|
|
clock_t start, stop;
|
|
|
|
if (signal(SIGALRM, alarm_handler) == SIG_ERR)
|
|
{
|
|
perror ("signal");
|
|
exit (1);
|
|
}
|
|
alarm(1);
|
|
start = clock ();
|
|
while (!gotit);
|
|
stop = clock ();
|
|
|
|
printf ("%jd clock ticks per second (start=%jd,stop=%jd)\n",
|
|
(intmax_t) (stop - start), (intmax_t) start, (intmax_t) stop);
|
|
printf ("CLOCKS_PER_SEC=%jd, sysconf(_SC_CLK_TCK)=%ld\n",
|
|
(intmax_t) CLOCKS_PER_SEC, sysconf(_SC_CLK_TCK));
|
|
return 0;
|
|
}
|