From: Nikodemus Siivola Date: Tue, 16 Aug 2011 17:58:41 +0000 (+0300) Subject: non-consing NANOSLEEP X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=567588a0316e6202e5158b8a9ff773b9e6d03762;p=sbcl.git non-consing NANOSLEEP ...and hence SLEEP as well. --- diff --git a/src/code/unix.lisp b/src/code/unix.lisp index 64db7ed..57f531c 100644 --- a/src/code/unix.lisp +++ b/src/code/unix.lisp @@ -950,8 +950,8 @@ corresponds to NAME, or NIL if there is none." (defun nanosleep (secs nsecs) (with-alien ((req (struct timespec)) (rem (struct timespec))) - (setf (slot req 'tv-sec) secs) - (setf (slot req 'tv-nsec) nsecs) + (setf (slot req 'tv-sec) secs + (slot req 'tv-nsec) nsecs) (loop while (and (eql sb!unix:eintr (nth-value 1 (int-syscall ("nanosleep" (* (struct timespec)) @@ -976,10 +976,9 @@ corresponds to NAME, or NIL if there is none." (rem-nsec (slot rem 'tv-nsec))) (when (or (> secs rem-sec) (and (= secs rem-sec) (>= nsecs rem-nsec))) - (setf secs rem-sec - nsecs rem-nsec) t))) - do (rotatef req rem)))) + do (setf (slot req 'tv-sec) (slot rem 'tv-sec) + (slot req 'tv-nsec) (slot rem 'tv-nsec))))) (defun unix-get-seconds-west (secs) (multiple-value-bind (ignore seconds dst) (get-timezone secs) diff --git a/tests/interface.pure.lisp b/tests/interface.pure.lisp index 411c8b5..d7f1835 100644 --- a/tests/interface.pure.lisp +++ b/tests/interface.pure.lisp @@ -12,6 +12,10 @@ ;;;; more information. (in-package :cl-user) + +(load "test-util.lisp") +(load "compiler-test-util.lisp") +(use-package :test-util) ;;;; properties of symbols, e.g. presence of doc strings for public symbols @@ -63,6 +67,10 @@ (sleep 2) (sleep 2)))) +;;; SLEEP should not cons +(with-test (:name (sleep :non-consing)) + (ctu:assert-no-consing (sleep 0.00001))) + ;;; SLEEP should work with large integers as well -- no timers ;;; on win32, so don't test there. (with-test (:name (sleep pretty-much-forever) :skipped-on :win32)