On Tue, Mar 06, 2012 at 01:01:57AM -0500, Woodchuck wrote:

> I.  The system call clock_getres(2) and clock_gettime(2) show strange
> results.
> 
> Consider this small program and its output on OpenBSD 5.0, amd64:
> 
> #include <stdio.h>
> #include <sys/time.h>
> 
> main()
> {
>         struct timespec tp;
>       int             i;
> 
>       clock_getres(CLOCK_REALTIME, &tp);

BTW, your format strings are not right, both in size of operand and
signedness.  Here:

>       printf("Resolution:  %lu %lu\n", tp.tv_sec, tp.tv_nsec);

>       for (i = 0; i < 10; i++) {
>               clock_gettime(CLOCK_REALTIME, &tp);

And here:
>               printf("Performance: %lu %lu\n", tp.tv_sec, tp.tv_nsec);
>       }
>       return 0;
> }


struct timespec {
        time_t  tv_sec;         /* seconds */
        long    tv_nsec;        /* and nanoseconds */
};

and time_t is int

        -Otto

Reply via email to