diff options
Diffstat (limited to 'tests/stress1.c')
-rw-r--r-- | tests/stress1.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/stress1.c b/tests/stress1.c index 68d2ed7..2562167 100644 --- a/tests/stress1.c +++ b/tests/stress1.c @@ -117,15 +117,17 @@ millisecondsFromNow (struct timespec * time, int millisecs) /* get current system time and add millisecs */ _ftime(&currSysTime); - nanosecs = ((int64_t) (millisecs + currSysTime.millitm)) * NANOSEC_PER_MILLISEC; + secs = (int64_t)(currSysTime.time + (millisecs / 1000)); + nanosecs = ((int64_t) (millisecs%1000 + currSysTime.millitm)) * NANOSEC_PER_MILLISEC; if (nanosecs >= NANOSEC_PER_SEC) { - secs = currSysTime.time + 1; - nanosecs %= NANOSEC_PER_SEC; + secs++; + nanosecs -= NANOSEC_PER_SEC; } - else + else if (nanosecs < 0) { - secs = currSysTime.time; + secs--; + nanosecs += NANOSEC_PER_SEC; } time->tv_nsec = (long)nanosecs; |