From 55c4d089d0d25998bebb124fa0642db17f99cdfb Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Tue, 13 Oct 1998 23:56:08 +0000 Subject: [PATCH] * stime.c (scm_get_internal_real_time): Do the arithmetic using SCM numbers, so we won't have rollover problems; the range of a signed long in milliseconds is about 25 days. (Thanks to Karl Hegbloom.) --- libguile/stime.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/libguile/stime.c b/libguile/stime.c index a3ee3ca74..8ddf310d9 100644 --- a/libguile/stime.c +++ b/libguile/stime.c @@ -140,15 +140,17 @@ SCM scm_get_internal_real_time() { struct timeb time_buffer; - long tmp; - ftime(&time_buffer); + + SCM tmp; + ftime (&time_buffer); time_buffer.time -= scm_your_base.time; - tmp = time_buffer.millitm - scm_your_base.millitm; - tmp = time_buffer.time*1000L + tmp; - tmp *= CLKTCK; - tmp /= 1000; - return scm_long2num (tmp); -} + tmp = scm_long2num (time_buffer.millitm - scm_your_base.millitm); + tmp = scm_sum (tmp, + scm_product (SCM_MAKINUM (1000), + SCM_MAKINUM (time_buffer.time))); + return scm_quotient (scm_product (tmp, SCM_MAKINUM (CLKTCK)), + SCM_MAKINUM (1000)); +}; #else