fixing SRFI-18 time interface which uses timevals, not tms

This commit is contained in:
Alex Shinn 2011-07-22 00:40:30 +09:00
parent 0270f52ecb
commit 75af68ad76
4 changed files with 10 additions and 2 deletions

View file

@ -2,7 +2,7 @@
(module (chibi time) (module (chibi time)
(export current-seconds get-time-of-day set-time-of-day! (export current-seconds get-time-of-day set-time-of-day!
seconds->time seconds->string time->seconds time->string seconds->time seconds->string time->seconds time->string
timeval-seconds timeval-microseconds make-timeval timeval-seconds timeval-microseconds
timezone-offset timezone-dst-time timezone-offset timezone-dst-time
time-second time-minute time-hour time-day time-month time-year time-second time-minute time-hour time-day time-month time-year
time-day-of-week time-day-of-year time-dst? time-day-of-week time-day-of-year time-dst?

View file

@ -19,6 +19,7 @@
(define-c-struct timeval (define-c-struct timeval
predicate: timeval? predicate: timeval?
constructor: (make-timeval tv_sec tv_usec)
(time_t tv_sec timeval-seconds) (time_t tv_sec timeval-seconds)
(int tv_usec timeval-microseconds)) (int tv_usec timeval-microseconds))

View file

@ -15,7 +15,8 @@
join-timeout-exception? abandoned-mutex-exception? join-timeout-exception? abandoned-mutex-exception?
terminated-thread-exception? uncaught-exception? terminated-thread-exception? uncaught-exception?
uncaught-exception-reason) uncaught-exception-reason)
(import (scheme) (srfi 9) (chibi ast) (chibi time)) (import (scheme) (srfi 9) (chibi ast)
(except (chibi time) time->seconds seconds->time))
(include "18/types.scm") (include "18/types.scm")
(include-shared "18/threads") (include-shared "18/threads")
(include "18/interface.scm")) (include "18/interface.scm"))

View file

@ -40,6 +40,12 @@
(define current-time get-time-of-day) (define current-time get-time-of-day)
(define time? timeval?) (define time? timeval?)
(define (time->seconds x)
(timeval-seconds (if (pair? x) (car x) x)))
(define (seconds->time x)
(make-timeval (if (inexact? x) (inexact->exact x) x) 0))
(define (join-timeout-exception? x) (define (join-timeout-exception? x)
(and (exception? x) (and (exception? x)
(equal? (exception-message x) "timed out waiting for thread"))) (equal? (exception-message x) "timed out waiting for thread")))