#ifndef HAVE_LIBRT
/*
* On systems where clock_gettime() is not available, the
- * definition for CLOCK_MONOTONIC will also not be available.
- * This variable should define which type of clock clock_gettime()
- * should use. We define it here if it is not defined simply
- * so the reimplementation can ignore it.
+ * definition for CLOCK_MONOTONIC and CLOCK_REALTIME will
+ * also not be available. This variable should define which
+ * type of clock clock_gettime() should use. We define it
+ * here if it is not defined simply so the reimplementation
+ * can ignore it.
*/
#ifndef CLOCK_MONOTONIC
#define CLOCK_MONOTONIC 0
#endif
+#ifndef CLOCK_REALTIME
+#define CLOCK_REALTIME 0
+#endif
#ifdef STRUCT_ITIMERSPEC_DEFINITION_MISSING
/*
int status = 0;
struct timespec ts_start, ts_end;
+ int timer_create_result;
timer_t timerid;
struct itimerspec timer_spec;
TestResult * tr;
}
alarm_received = 0;
-
- if(timer_create(CLOCK_MONOTONIC,
- NULL /* fire SIGALRM if timer expires */,
- &timerid) == 0)
+
+ timer_create_result = timer_create(CLOCK_MONOTONIC,
+ NULL /* fire SIGALRM if timer expires */,
+ &timerid);
+
+ /*
+ * CLOCK_MONOTONIC is not supported on the Cygwin platform
+ * (maybe others as well). If the timer creation fails, attempt with
+ * CLOCK_REALTIME before bailing out.
+ */
+ if(timer_create_result != 0)
+ {
+ timer_create_result = timer_create(CLOCK_REALTIME,
+ NULL /* fire SIGALRM if timer expires */,
+ &timerid);
+ }
+
+ if(timer_create_result == 0)
{
/* Set the timer to fire once */
timer_spec.it_value = tc->timeout;