/* comparetimeofday.c * * Compare the /proc/xtime output of xtime.tv_sec and xtime.tv_usec with * the result from gettimeofday system call. */ /* Standard include files for syscall, see man syscall */ #include /* for printf */ #include /* for gettimeofday */ #define MAXLINE 80 int main(void) { char buf[MAXLINE+1]; /* room for string terminator zero */ FILE *fp; struct timeval now; fp = fopen("/proc/xtime", "r"); printf("The xtime from /proc/xtime is the following:\n"); /* fgets reads one less than specified number of chars and adds zero */ while (fgets(buf, MAXLINE+1, fp) != NULL ) { printf("%s", buf); } printf("\nThe result of gettimeofday system call is:\n"); gettimeofday(&now, NULL); printf("now.tv_sec: %ld now.tv_usec: %ld\n", now.tv_sec, now.tv_usec ); return 0; }