diff options
-rw-r--r-- | tests/ChangeLog | 6 | ||||
-rw-r--r-- | tests/stress1.c | 12 |
2 files changed, 13 insertions, 5 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index 9b00fa3..6b2c742 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2005-06-12 Ross Johnson <rpj@callisto.canberra.edu.au> + + * stress1.c (millisecondsFromNow): Remove limit 0 <= millisecs < 1000; + now works for -INT_MAX <= millisecs <= INT_MAX; not needed for + stress1.c but should be general anyway. + 2005-05-18 Ross Johnson <rpj@callisto.canberra.edu.au> * reuse2.c (main): Must use a read with memory barrier semantics 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; |