1/* Timer test using the monotonic clock. */
2
3#include <time.h>
4#include <unistd.h>
5
6#if defined CLOCK_MONOTONIC && defined _POSIX_MONOTONIC_CLOCK
7
8# define TEST_CLOCK CLOCK_MONOTONIC
9# define TEST_CLOCK_MISSING(clock) \
10 (setup_test () ? "CLOCK_MONOTONIC" : NULL)
11
12# include <stdio.h>
13
14static int
15setup_test (void)
16{
17 if (sysconf (_SC_MONOTONIC_CLOCK) <= 0)
18 return 1;
19
20 /* The user-level timers implementation doesn't support CLOCK_MONOTONIC,
21 even though sysconf claims it will. */
22 timer_t t;
23 if (timer_create (TEST_CLOCK, NULL, timerid: &t) != 0)
24 {
25 printf (format: "timer_create: %m\n");
26 return 1;
27 }
28 timer_delete (timerid: t);
29
30 return 0;
31}
32
33# include "tst-timer4.c"
34
35#else
36# define TEST_FUNCTION 0
37# include "../test-skeleton.c"
38#endif
39

source code of glibc/rt/tst-timer5.c