m68k: update libm test ULPs
[glibc.git] / rt / tst-clock2.c
blob4c8fb9f247590a42a70be95a4c58d4c3b1c425c6
1 /* Test setting the monotonic clock. */
3 #include <time.h>
4 #include <unistd.h>
6 #if defined CLOCK_MONOTONIC && defined _POSIX_MONOTONIC_CLOCK
8 # include <errno.h>
9 # include <stdio.h>
11 static int
12 do_test (void)
14 if (sysconf (_SC_MONOTONIC_CLOCK) <= 0)
15 return 0;
17 struct timespec ts;
18 if (clock_gettime (CLOCK_MONOTONIC, &ts) != 0)
20 puts ("clock_gettime(CLOCK_MONOTONIC) failed");
21 return 1;
24 /* Setting the monotonic clock must fail. */
25 if (clock_settime (CLOCK_MONOTONIC, &ts) != -1)
27 puts ("clock_settime(CLOCK_MONOTONIC) did not fail");
28 return 1;
30 if (errno != EINVAL)
32 printf ("clock_settime(CLOCK_MONOTONIC) set errno to %d, expected %d\n",
33 errno, EINVAL);
34 return 1;
36 return 0;
38 # define TEST_FUNCTION do_test ()
40 #else
41 # define TEST_FUNCTION 0
42 #endif
43 #include "../test-skeleton.c"