blob: 13b7420e2e27d23aeeba193ab5b1236e8771f6f8 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#include <signal.h>
2#include <stdio.h>
3#include <stdlib.h>
4#include <time.h>
5#include <unistd.h>
6
7volatile int gotit = 0;
8
9static void
10alarm_handler (int signal)
11{
12 gotit = 1;
13}
14
15
16int
17main (int argc, char ** argv)
18{
19 clock_t start, stop;
20
21 if (signal(SIGALRM, alarm_handler) == SIG_ERR)
22 {
23 perror ("signal");
24 exit (1);
25 }
26 alarm(1);
27 start = clock ();
28 while (!gotit);
29 stop = clock ();
30
31 printf ("%jd clock ticks per second (start=%jd,stop=%jd)\n",
32 (intmax_t) (stop - start), (intmax_t) start, (intmax_t) stop);
33 printf ("CLOCKS_PER_SEC=%jd, sysconf(_SC_CLK_TCK)=%ld\n",
34 (intmax_t) CLOCKS_PER_SEC, sysconf(_SC_CLK_TCK));
35 return 0;
36}