diff options
author | Daniel Barlow <dan@telent.net> | 2005-04-06 17:16:57 +0000 |
---|---|---|
committer | Daniel Barlow <dan@telent.net> | 2005-04-06 17:16:57 +0000 |
commit | 0834142e83d6a1ee99260baa3a8ca1d1557b3737 (patch) | |
tree | 654d625046c9f7127c032615f3726d6e41d8d093 /src | |
parent | 864c91b95c68eef808008fcb65780119e24831b4 (diff) |
0.8.21.20
Patch SLEEP to use nanosleep() and to restart the sleep if
interrupted e.g. by a signal, instead of returning early. Thanks
to Gabor Melis (ref sbcl-help, "Oddity with make-thread and sleep")
Diffstat (limited to 'src')
-rw-r--r-- | src/code/toplevel.lisp | 6 | ||||
-rw-r--r-- | src/code/unix.lisp | 12 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/code/toplevel.lisp b/src/code/toplevel.lisp index 2b6dcbd2b..43a5c0ba0 100644 --- a/src/code/toplevel.lisp +++ b/src/code/toplevel.lisp @@ -147,13 +147,13 @@ steppers to maintain contextual information.") :format-arguments (list n) :datum n :expected-type '(real 0))) - (multiple-value-bind (sec usec) + (multiple-value-bind (sec nsec) (if (integerp n) (values n 0) (multiple-value-bind (sec frac) (truncate n) - (values sec (truncate frac 1e-6)))) - (sb!unix:unix-select 0 0 0 0 sec usec)) + (values sec (truncate frac 1e-9)))) + (sb!unix:nanosleep sec nsec)) nil) ;;;; SCRUB-CONTROL-STACK diff --git a/src/code/unix.lisp b/src/code/unix.lisp index 39b23eb04..59cf3504d 100644 --- a/src/code/unix.lisp +++ b/src/code/unix.lisp @@ -658,6 +658,18 @@ (seconds-west sb!alien:int :out) (daylight-savings-p sb!alien:boolean :out)) +(defun nanosleep (secs nsecs) + (with-alien ((req (struct timespec)) + (rem (struct timespec))) + (setf (slot req 'tv-sec) secs) + (setf (slot req 'tv-nsec) nsecs) + (loop while (eql sb!unix:EINTR + (nth-value 1 + (int-syscall ("nanosleep" (* (struct timespec)) + (* (struct timespec))) + (addr req) (addr rem)))) + do (rotatef req rem)))) + (defun unix-get-seconds-west (secs) (multiple-value-bind (ignore seconds dst) (get-timezone secs) (declare (ignore ignore) (ignore dst)) |