[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] current-time on 32-bit hardware

From: Nicolas Pelletier
Subject: [Chicken-users] current-time on 32-bit hardware
Date: Thu, 29 Jul 2010 09:01:46 +0900


I've run into the following problem.

I am taking a mutex with a time-out, as follows:

        (+ 1 (time->seconds (current-time)))))

And I got the following error:

    Warning (#<thread: my-thread>): : (inexact->exact) inexact number
cannot be represented as an exact\
     number: 1189553855.

Looking at srfi-18.scm, the implementation of current-time is:

    (define (current-time)
      (let* ([s C_get_seconds]
             [ss C_startup_time_seconds]
             [ms C_ms] )
         (inexact->exact (truncate (+ (* (- s ss) 1000) C_ms)))
         C_ms) ) )

Due to the different representation of integers between C and chicken
(32 bits in C, 30 in chicken if I'm not mistaken), the above
inexact->exact fails.

I am using 4.3.0, but the implementation of current-time in 4.5.0 is
the same. On one hand, using 64-bit hardware instead is not an option.
On the other hand, I just need mutex-lock! to not wait forever;
waiting a little more than one second is okay. Could someone suggest a
workaround and/or a fix, please?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]