mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 05:50:26 +02:00
* 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.)
This commit is contained in:
parent
eebc12c634
commit
55c4d089d0
1 changed files with 10 additions and 8 deletions
|
@ -140,15 +140,17 @@ SCM
|
||||||
scm_get_internal_real_time()
|
scm_get_internal_real_time()
|
||||||
{
|
{
|
||||||
struct timeb time_buffer;
|
struct timeb time_buffer;
|
||||||
long tmp;
|
|
||||||
ftime(&time_buffer);
|
SCM tmp;
|
||||||
|
ftime (&time_buffer);
|
||||||
time_buffer.time -= scm_your_base.time;
|
time_buffer.time -= scm_your_base.time;
|
||||||
tmp = time_buffer.millitm - scm_your_base.millitm;
|
tmp = scm_long2num (time_buffer.millitm - scm_your_base.millitm);
|
||||||
tmp = time_buffer.time*1000L + tmp;
|
tmp = scm_sum (tmp,
|
||||||
tmp *= CLKTCK;
|
scm_product (SCM_MAKINUM (1000),
|
||||||
tmp /= 1000;
|
SCM_MAKINUM (time_buffer.time)));
|
||||||
return scm_long2num (tmp);
|
return scm_quotient (scm_product (tmp, SCM_MAKINUM (CLKTCK)),
|
||||||
}
|
SCM_MAKINUM (1000));
|
||||||
|
};
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue