Timing bug somewhere-or-other
Oct. 17th, 2009 01:58 pmrichard@araminta:~$ cat t.c
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
#include <assert.h>
int main(void) {
for(;;) {
time_t t;
struct timeval tv;
assert(gettimeofday(&tv, NULL) == 0);
assert(time(&t) != (time_t)-1);
if(t < tv.tv_sec)
return printf("%ld %ld.%06ld\n", t, tv.tv_sec, tv.tv_usec);
}
}
richard@araminta:~$ gcc -o t t.c
richard@araminta:~$ ./t
1255784018 1255784019.000000
( versions )