Back to index

glibc  2.9
tst-timer5.c
Go to the documentation of this file.
00001 /* Timer test using the monotonic clock.  */
00002 
00003 #include <time.h>
00004 #include <unistd.h>
00005 
00006 #if defined CLOCK_MONOTONIC && defined _POSIX_MONOTONIC_CLOCK
00007 
00008 # define TEST_CLOCK  CLOCK_MONOTONIC
00009 # define TEST_CLOCK_MISSING(clock) \
00010   (setup_test () ? "CLOCK_MONOTONIC" : NULL)
00011 
00012 # include <stdio.h>
00013 
00014 static int
00015 setup_test (void)
00016 {
00017   if (sysconf (_SC_MONOTONIC_CLOCK) <= 0)
00018     return 1;
00019 
00020   /* The user-level timers implementation doesn't support CLOCK_MONOTONIC,
00021      even though sysconf claims it will.  */
00022   timer_t t;
00023   if (timer_create (TEST_CLOCK, NULL, &t) != 0)
00024     {
00025       printf ("timer_create: %m\n");
00026       return 1;
00027     }
00028   timer_delete (t);
00029 
00030   return 0;
00031 }
00032 
00033 # include "tst-timer4.c"
00034 
00035 #else
00036 # define TEST_FUNCTION      0
00037 # include "../test-skeleton.c"
00038 #endif