Testing monotonic clock

Hasso Tepper hasso at estpak.ee
Tue Apr 1 04:33:44 PDT 2008


I have a software piece which checks for existance of monotonic clock with 
following testpiece:

#define _POSIX_C_SOURCE 199309L
#include <time.h>

int main(int argc, char *argv[]) {
    struct timespec tp;

    if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
        return 0;
    else
        return 1;
}

It fails in DragonFly:

In file included from clock-test.c:2:
/usr/include/time.h:135: error: expected '=', ',', ';', 'asm' 
or '__attribute__' before 'strftime'
clock-test.c: In function 'main':
clock-test.c:5: error: storage size of 'tp' isn't known
clock-test.c:7: error: 'CLOCK_MONOTONIC' undeclared (first use in this 
function)
clock-test.c:7: error: (Each undeclared identifier is reported only once
clock-test.c:7: error: for each function it appears in.)


It's obvious that someone has to include sys/time.h somewhere, but who and 
where? What's buggy - DragonFly or this test?


-- 
Hasso Tepper





More information about the Kernel mailing list