Fix rouding issues, Add reminder to rewrite faking time(), gettimeofday, etc. [rbalint pr29]

This commit is contained in:
Balint Reczey
2013-09-04 13:10:26 +02:00
committed by Wolfgang Hommel
parent 545685e5a8
commit 3d63dd33e5
2 changed files with 4 additions and 3 deletions

1
TODO
View File

@@ -6,3 +6,4 @@ Open issues / next steps for libfaketime development
and available through the wrapper shell script
- fake timer_create and friends
- handle CLOCK_REALTIME_COARSE and CLOCK_MONOTONIC_COARSE
- fake time(), etc. using clock_gettime() to provide more continuous faking with x10

View File

@@ -1621,7 +1621,7 @@ time_t fake_time(time_t *time_tptr)
struct timespec tp;
tp.tv_sec = *time_tptr;
tp.tv_nsec = 0;
tp.tv_nsec = ftpl_starttime.real.tv_nsec;
(void)fake_clock_gettime(CLOCK_REALTIME, &tp);
*time_tptr = tp.tv_sec;
return *time_tptr;
@@ -1632,7 +1632,7 @@ int fake_ftime(struct timeb *tp)
struct timespec ts;
int ret;
ts.tv_sec = tp->time;
ts.tv_nsec =tp->millitm * 1000000;
ts.tv_nsec =tp->millitm * 1000000 + ftpl_starttime.real.tv_nsec % 1000000;
ret = fake_clock_gettime(CLOCK_REALTIME, &ts);
tp->time = ts.tv_sec;
@@ -1646,7 +1646,7 @@ int fake_gettimeofday(struct timeval *tv, void *tz)
struct timespec ts;
int ret;
ts.tv_sec = tv->tv_sec;
ts.tv_nsec =tv->tv_usec * 1000;
ts.tv_nsec = tv->tv_usec * 1000 + ftpl_starttime.real.tv_nsec % 1000;
ret = fake_clock_gettime(CLOCK_REALTIME, &ts);
tv->tv_sec = ts.tv_sec;