#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <err.h>

int
main(void)
{
    struct timespec ts;
    struct timeval tv;

    if (clock_gettime(CLOCK_REALTIME, &ts) == -1)
        err(EXIT_FAILURE, "clock_gettime");

    if (gettimeofday(&tv, NULL) == -1)
        err(EXIT_FAILURE, "gettimeofday");

    printf("                time()=%ld\n", (long) time(NULL));
    printf("struct timeval  tv.sec=%ld tv.usec=%ld\n", tv.tv_sec, tv.tv_usec);
    printf("struct timespec tv_sec=%ld tv_nsec=%ld\n", ts.tv_sec, ts.tv_nsec);

    exit(EXIT_SUCCESS);
}
