tst-timer5.c 753 B

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