Index: /trunk/ccl/level-1/l1-streams.lisp
===================================================================
--- /trunk/ccl/level-1/l1-streams.lisp	(revision 5356)
+++ /trunk/ccl/level-1/l1-streams.lisp	(revision 5357)
@@ -3645,5 +3645,8 @@
 (defmethod stream-read-char ((s basic-character-input-stream))
   (let* ((ioblock (basic-stream-ioblock s)))
-    (funcall (ioblock-read-char-function ioblock) ioblock)))
+    (declare (optimize (speed 3)))
+    (without-interrupts
+     (values
+      (funcall (ioblock-read-char-function ioblock) ioblock)))))
 
 
@@ -3651,20 +3654,32 @@
   (let* ((ioblock (basic-stream-ioblock stream)))
     (with-ioblock-input-locked (ioblock)
-      (%ioblock-tyi-no-hang ioblock))))
+      (locally (declare (optimize (speed 3)))
+        (without-interrupts
+         (values
+          (%ioblock-tyi-no-hang ioblock)))))))
        
 (defmethod stream-peek-char ((stream basic-character-input-stream))
   (let* ((ioblock (basic-stream-ioblock stream)))
     (with-ioblock-input-locked (ioblock)
-      (%ioblock-peek-char ioblock))))
+      (locally (declare (optimize (speed 3)))
+        (without-interrupts
+         (values
+          (%ioblock-peek-char ioblock)))))))
 
 (defmethod stream-clear-input ((stream basic-character-input-stream))
   (let* ((ioblock (basic-stream-ioblock stream)))
     (with-ioblock-input-locked (ioblock)
-      (%ioblock-clear-input ioblock))))
+      (locally (declare (optimize (speed 3)))
+        (without-interrupts
+         (values
+          (%ioblock-clear-input ioblock)))))))
 
 (defmethod stream-unread-char ((s basic-character-input-stream) char)
   (let* ((ioblock (basic-stream-ioblock s)))
     (with-ioblock-input-locked (ioblock)
-      (%ioblock-untyi ioblock char))))
+      (locally (declare (optimize (speed 3)))
+        (without-interrupts
+         (values
+          (%ioblock-untyi ioblock char)))))))
 
 (defmethod stream-read-ivector ((s basic-character-input-stream)
@@ -3672,5 +3687,8 @@
   (let* ((ioblock (basic-stream-ioblock s)))
     (with-ioblock-input-locked (ioblock)
-      (%ioblock-character-in-ivect ioblock iv start nb))))
+      (locally (declare (optimize (speed 3)))
+        (without-interrupts
+         (values
+          (%ioblock-character-in-ivect ioblock iv start nb)))))))
 
 (defmethod stream-read-vector ((stream basic-character-input-stream)
@@ -3681,11 +3699,17 @@
     (let* ((ioblock (basic-stream-ioblock stream)))
       (with-ioblock-input-locked (ioblock)
-        (funcall (ioblock-character-read-vector-function ioblock)
-                 ioblock vector start end)))))
+      (locally (declare (optimize (speed 3)))
+        (without-interrupts
+         (values
+          (funcall (ioblock-character-read-vector-function ioblock)
+                   ioblock vector start end))))))))
 
 (defmethod stream-read-line ((stream basic-character-input-stream))
   (let* ((ioblock (basic-stream-ioblock stream)))
     (with-ioblock-input-locked (ioblock)
-      (funcall (ioblock-read-line-function ioblock) ioblock))))
+      (locally (declare (optimize (speed 3)))
+        (without-interrupts
+         (values
+          (funcall (ioblock-read-line-function ioblock) ioblock)))))))
 
                              
@@ -4387,5 +4411,8 @@
   (let* ((ioblock (stream-ioblock stream nil)))
     (when ioblock
-      (%ioblock-close ioblock))))
+      (locally (declare (optimize (speed 3)))
+        (without-interrupts
+         (values
+          (%ioblock-close ioblock)))))))
 
 (defmethod close :before ((stream buffered-output-stream-mixin) &key abort)
@@ -4403,5 +4430,8 @@
   (let* ((ioblock (basic-stream.state stream)))
     (when ioblock
-      (%ioblock-close ioblock))))
+      (locally (declare (optimize (speed 3)))
+        (without-interrupts
+         (values
+          (%ioblock-close ioblock)))))))
 
 
@@ -4458,17 +4488,29 @@
 (defmethod stream-read-char ((stream buffered-character-input-stream-mixin))
   (let* ((ioblock (stream-ioblock stream t)))
-    (funcall (ioblock-read-char-function ioblock) ioblock)))
+    (locally (declare (optimize (speed 3)))
+      (without-interrupts
+       (values
+        (funcall (ioblock-read-char-function ioblock) ioblock))))))
 
 (defmethod stream-read-char-no-hang ((stream buffered-character-input-stream-mixin))
   (with-stream-ioblock-input (ioblock stream :speedy t)
-    (%ioblock-tyi-no-hang ioblock)))
+    (locally (declare (optimize (speed 3)))
+      (without-interrupts
+       (values
+        (%ioblock-tyi-no-hang ioblock))))))
 
 (defmethod stream-peek-char ((stream buffered-character-input-stream-mixin))
   (with-stream-ioblock-input (ioblock stream :speedy t)
-    (%ioblock-peek-char ioblock)))
+    (locally (declare (optimize (speed 3)))
+      (without-interrupts
+       (values
+        (%ioblock-peek-char ioblock))))))
 
 (defmethod stream-clear-input ((stream buffered-input-stream-mixin))
   (with-stream-ioblock-input (ioblock stream :speedy t)
-    (%ioblock-clear-input ioblock)))
+    (locally (declare (optimize (speed 3)))
+      (without-interrupts
+       (values
+        (%ioblock-clear-input ioblock))))))
 
 (defmethod stream-unread-char ((stream buffered-character-input-stream-mixin) char)
@@ -4479,14 +4521,23 @@
 (defmethod stream-read-byte ((stream buffered-binary-input-stream-mixin))
   (with-stream-ioblock-input (ioblock stream :speedy t)
-    (funcall (ioblock-read-byte-function ioblock) ioblock)))
+    (locally (declare (optimize (speed 3)))
+      (without-interrupts
+       (values
+        (funcall (ioblock-read-byte-function ioblock) ioblock))))))
 
 (defmethod stream-read-byte ((stream basic-binary-input-stream))
   (let* ((ioblock (basic-stream-ioblock stream)))
     (with-ioblock-input-locked (ioblock)
-      (funcall (ioblock-read-byte-function ioblock) ioblock))))
+      (locally (declare (optimize (speed 3)))
+        (without-interrupts
+         (values
+          (funcall (ioblock-read-byte-function ioblock) ioblock)))))))
 
 (defmethod stream-eofp ((stream buffered-input-stream-mixin))
   (with-stream-ioblock-input (ioblock stream :speedy t)
-    (%ioblock-eofp ioblock)))
+    (locally (declare (optimize (speed 3)))
+      (without-interrupts
+       (values
+        (%ioblock-eofp ioblock))))))
 
 (defmethod stream-eofp ((stream basic-input-stream))
@@ -4497,36 +4548,54 @@
 (defmethod stream-listen ((stream buffered-input-stream-mixin))
   (with-stream-ioblock-input (ioblock stream :speedy t)
-    (%ioblock-listen ioblock)))
+    (locally (declare (optimize (speed 3)))
+      (without-interrupts
+       (values
+        (%ioblock-listen ioblock))))))
 
 (defmethod stream-listen ((stream basic-input-stream))
   (let* ((ioblock (basic-stream-ioblock stream)))
     (with-ioblock-input-locked (ioblock)
-      (%ioblock-listen ioblock))))
-
-(defun flush-ioblock (ioblock finish-p)
-  (with-ioblock-output-locked (ioblock)
-    (%ioblock-force-output ioblock finish-p)))
+      (locally (declare (optimize (speed 3)))
+        (without-interrupts
+         (values
+          (%ioblock-listen ioblock)))))))
+
 
 (defmethod stream-write-byte ((stream buffered-binary-output-stream-mixin)
                               byte)
   (let* ((ioblock (stream-ioblock stream t)))
-    (funcall (ioblock-write-byte-function ioblock) ioblock byte)))
+    (locally (declare (optimize (speed 3)))
+      (without-interrupts
+       (values
+        (funcall (ioblock-write-byte-function ioblock) ioblock byte))))))
 
 (defmethod stream-write-byte ((stream basic-binary-output-stream) byte)
   (let* ((ioblock (basic-stream-ioblock stream)))
-    (funcall (ioblock-write-byte-function ioblock) ioblock byte)))
+    (locally (declare (optimize (speed 3)))
+      (without-interrupts
+       (values
+        (funcall (ioblock-write-byte-function ioblock) ioblock byte))))))
 
 (defmethod stream-write-char ((stream buffered-character-output-stream-mixin) char)
   (let* ((ioblock (stream-ioblock stream t)))
-    (funcall (ioblock-write-char-function ioblock) ioblock char)))
+    (locally (declare (optimize (speed 3)))
+      (without-interrupts
+       (values
+        (funcall (ioblock-write-char-function ioblock) ioblock char))))))
 
 (defmethod stream-write-char ((stream basic-character-output-stream) char)
   (let* ((ioblock (basic-stream-ioblock stream)))
-    (funcall (ioblock-write-char-function ioblock) ioblock char)))
+    (locally (declare (optimize (speed 3)))
+      (without-interrupts
+       (values
+        (funcall (ioblock-write-char-function ioblock) ioblock char))))))
 
 
 (defmethod stream-clear-output ((stream buffered-output-stream-mixin))
   (with-stream-ioblock-output (ioblock stream :speedy t)
-    (%ioblock-clear-output ioblock))
+    (locally (declare (optimize (speed 3)))
+      (without-interrupts
+       (values
+        (%ioblock-clear-output ioblock)))))
   nil)
 
@@ -4534,5 +4603,8 @@
   (let* ((ioblock (basic-stream-ioblock stream)))
     (with-ioblock-output-locked (ioblock)
-      (%ioblock-clear-output ioblock))
+      (locally (declare (optimize (speed 3)))
+        (without-interrupts
+         (values
+          (%ioblock-clear-output ioblock)))))
     nil))
 
@@ -4559,5 +4631,8 @@
 (defmethod stream-force-output ((stream buffered-output-stream-mixin))
   (with-stream-ioblock-output (ioblock stream :speedy t)
-    (%ioblock-force-output ioblock nil)
+    (locally (declare (optimize (speed 3)))
+      (without-interrupts
+       (values
+        (%ioblock-force-output ioblock nil))))
     nil))
 
@@ -4565,10 +4640,16 @@
   (let* ((ioblock (basic-stream-ioblock stream)))
     (with-ioblock-output-locked (ioblock)
-      (%ioblock-force-output ioblock nil)
+      (locally (declare (optimize (speed 3)))
+        (without-interrupts
+         (values
+          (%ioblock-force-output ioblock nil))))
       nil)))
 
 (defmethod maybe-stream-force-output ((stream buffered-output-stream-mixin))
   (with-stream-ioblock-output-maybe (ioblock stream :speedy t)
-    (%ioblock-force-output ioblock nil)
+    (locally (declare (optimize (speed 3)))
+      (without-interrupts
+       (values
+        (%ioblock-force-output ioblock nil))))
     nil))
 
@@ -4576,10 +4657,16 @@
   (let* ((ioblock (basic-stream-ioblock stream)))
     (with-ioblock-output-locked-maybe (ioblock)
-      (%ioblock-force-output ioblock nil)
+      (locally (declare (optimize (speed 3)))
+        (without-interrupts
+         (values
+          (%ioblock-force-output ioblock nil))))
       nil)))
 
 (defmethod stream-finish-output ((stream buffered-output-stream-mixin))
   (with-stream-ioblock-output (ioblock stream :speedy t)
-    (%ioblock-force-output ioblock t)
+    (locally (declare (optimize (speed 3)))
+      (without-interrupts
+       (values
+        (%ioblock-force-output ioblock t))))
     nil))
 
@@ -4587,5 +4674,8 @@
   (let* ((ioblock (basic-stream-ioblock stream)))
     (with-ioblock-output-locked (ioblock)
-      (%ioblock-force-output ioblock t)
+      (locally (declare (optimize (speed 3)))
+        (without-interrupts
+         (values
+          (%ioblock-force-output ioblock t))))
       nil)))
 
@@ -4598,6 +4688,9 @@
     (if (and (typep string 'simple-string)
 	     (not start-p))
-      (funcall (ioblock-write-simple-string-function ioblock)
-               ioblock string 0 (length string))
+      (locally (declare (optimize (speed 3)))
+        (without-interrupts
+         (values
+          (funcall (ioblock-write-simple-string-function ioblock)
+                   ioblock string 0 (length string)))))
       (progn
         (setq end (check-sequence-bounds string start end))
@@ -4610,6 +4703,9 @@
               (incf start offset)
               (incf end offset))
-            (funcall (ioblock-write-simple-string-function ioblock)
-                     ioblock arr start (the fixnum (- end start))))))))
+            (locally (declare (optimize (speed 3)))
+              (without-interrupts
+               (values
+                (funcall (ioblock-write-simple-string-function ioblock)
+                         ioblock arr start (the fixnum (- end start)))))))))))
   string)
 
@@ -4621,6 +4717,9 @@
       (if (and (typep string 'simple-string)
                (not start-p))
-        (funcall (ioblock-write-simple-string-function ioblock)
-                 ioblock string 0 (length string))
+        (locally (declare (optimize (speed 3)))
+          (without-interrupts
+           (values
+            (funcall (ioblock-write-simple-string-function ioblock)
+                     ioblock string 0 (length string)))))
         (progn
           (setq end (check-sequence-bounds string start end))
@@ -4633,6 +4732,9 @@
                 (incf start offset)
                 (incf end offset))
-              (funcall (ioblock-write-simple-string-function ioblock)
-                       ioblock arr start (the fixnum (- end start)))))))))
+              (locally (declare (optimize (speed 3)))
+                (without-interrupts
+                 (values
+                  (funcall (ioblock-write-simple-string-function ioblock)
+                           ioblock arr start (the fixnum (- end start))))))))))))
   string)
 
@@ -4641,5 +4743,8 @@
 				 iv start length)
   (with-stream-ioblock-output (ioblock s :speedy t)
-    (%ioblock-out-ivect ioblock iv start length)))
+    (locally (declare (optimize (speed 3)))
+      (without-interrupts
+       (values    
+        (%ioblock-out-ivect ioblock iv start length))))))
 
 (defmethod stream-write-ivector ((s basic-output-stream)
@@ -4647,5 +4752,8 @@
   (let* ((ioblock (basic-stream-ioblock s)))
     (with-ioblock-output-locked (ioblock)
-      (%ioblock-out-ivect ioblock iv start length))))
+      (locally (declare (optimize (speed 3)))
+        (without-interrupts
+         (values
+          (%ioblock-out-ivect ioblock iv start length)))))))
 
 
@@ -4653,10 +4761,16 @@
 				iv start nb)
   (with-stream-ioblock-input (ioblock s :speedy t)
-    (%ioblock-character-in-ivect ioblock iv start nb)))
+    (locally (declare (optimize (speed 3)))
+      (without-interrupts
+       (values
+        (%ioblock-character-in-ivect ioblock iv start nb))))))
 
 (defmethod stream-read-ivector ((s buffered-binary-input-stream-mixin)
 				iv start nb)
   (with-stream-ioblock-input (ioblock s :speedy t)
-    (%ioblock-binary-in-ivect ioblock iv start nb)))
+    (locally (declare (optimize (speed 3)))
+      (without-interrupts
+       (values
+        (%ioblock-binary-in-ivect ioblock iv start nb))))))
 
 
@@ -4669,6 +4783,9 @@
       (let* ((total (- end start)))
 	(declare (fixnum total))
-        (funcall (ioblock-write-simple-string-function ioblock)
-                 ioblock vector start total)))))
+        (locally (declare (optimize (speed 3)))
+          (without-interrupts
+           (values
+            (funcall (ioblock-write-simple-string-function ioblock)
+                     ioblock vector start total))))))))
 
 (defmethod stream-write-vector ((stream basic-character-output-stream)
@@ -4681,6 +4798,9 @@
       (declare (fixnum total))
       (with-ioblock-output-locked (ioblock)
-                (funcall (ioblock-write-simple-string-function ioblock)
-                 ioblock vector start total)))))
+        (locally (declare (optimize (speed 3)))
+          (without-interrupts
+           (values
+            (funcall (ioblock-write-simple-string-function ioblock)
+                     ioblock vector start total))))))))
 
 (defmethod stream-write-vector ((stream buffered-binary-output-stream-mixin)
@@ -4688,47 +4808,46 @@
   (declare (fixnum start end))
   (with-stream-ioblock-output (ioblock stream :speedy t)
-    (let* ((out (ioblock-outbuf ioblock))
-	   (buf (io-buffer-buffer out))
-	   (written 0)
-	   (limit (io-buffer-limit out))
-	   (total (- end start))
-	   (buftype (typecode buf)))
-      (declare (fixnum buftype written total limit))
-      (if (not (= (the fixnum (typecode vector)) buftype))
-	(do* ((i start (1+ i))
-              (wbf (ioblock-write-byte-function ioblock)))
-	     ((= i end))
-	  (let ((byte (uvref vector i)))
-	    (when (characterp byte)
-	      (setq byte (char-code byte)))
-	    (funcall wbf ioblock byte)))
-	(do* ((pos start (+ pos written))
-	      (left total (- left written)))
-	     ((= left 0))
-	  (declare (fixnum pos left))
-	  (setf (ioblock-dirty ioblock) t)
-	  (let* ((index (io-buffer-idx out))
-		 (count (io-buffer-count out))
-		 (avail (- limit index)))
-	    (declare (fixnum index avail count))
-	    (cond
-	      ((= (setq written avail) 0)
-	       (%ioblock-force-output ioblock nil))
-	      (t
-	       (if (> written left)
-		 (setq written left))
-	       (%copy-ivector-to-ivector
-		vector
-		(ioblock-elements-to-octets ioblock pos)
-		buf
-		(ioblock-elements-to-octets ioblock index)
-		(ioblock-elements-to-octets ioblock written))
-	       (setf (ioblock-dirty ioblock) t)
-	       (incf index written)
-	       (if (> index count)
-		 (setf (io-buffer-count out) index))
-	       (setf (io-buffer-idx out) index)
-	       (if (= index  limit)
-		 (%ioblock-force-output ioblock nil))))))))))
+    (without-interrupts
+     (let* ((out (ioblock-outbuf ioblock))
+            (buf (io-buffer-buffer out))
+            (written 0)
+            (limit (io-buffer-limit out))
+            (total (- end start))
+            (buftype (typecode buf)))
+       (declare (fixnum buftype written total limit))
+       (if (not (= (the fixnum (typecode vector)) buftype))
+         (do* ((i start (1+ i))
+               (wbf (ioblock-write-byte-function ioblock)))
+              ((= i end))
+           (let ((byte (uvref vector i)))
+             (funcall wbf ioblock byte)))
+         (do* ((pos start (+ pos written))
+               (left total (- left written)))
+              ((= left 0))
+           (declare (fixnum pos left))
+           (setf (ioblock-dirty ioblock) t)
+           (let* ((index (io-buffer-idx out))
+                  (count (io-buffer-count out))
+                  (avail (- limit index)))
+             (declare (fixnum index avail count))
+             (cond
+               ((= (setq written avail) 0)
+                (%ioblock-force-output ioblock nil))
+               (t
+                (if (> written left)
+                  (setq written left))
+                (%copy-ivector-to-ivector
+                 vector
+                 (ioblock-elements-to-octets ioblock pos)
+                 buf
+                 (ioblock-elements-to-octets ioblock index)
+                 (ioblock-elements-to-octets ioblock written))
+                (setf (ioblock-dirty ioblock) t)
+                (incf index written)
+                (if (> index count)
+                  (setf (io-buffer-count out) index))
+                (setf (io-buffer-idx out) index)
+                (if (= index  limit)
+                  (%ioblock-force-output ioblock nil)))))))))))
 
 (defmethod stream-write-vector ((stream basic-binary-output-stream)
@@ -4737,47 +4856,48 @@
   (let* ((ioblock (basic-stream-ioblock stream)))
     (with-ioblock-output-locked (ioblock)
-    (let* ((out (ioblock-outbuf ioblock))
-	   (buf (io-buffer-buffer out))
-	   (written 0)
-	   (limit (io-buffer-limit out))
-	   (total (- end start))
-	   (buftype (typecode buf)))
-      (declare (fixnum buftype written total limit))
-      (if (not (= (the fixnum (typecode vector)) buftype))
-	(do* ((i start (1+ i))
-              (wbf (ioblock-write-byte-function ioblock)))
-	     ((= i end))
-	  (let ((byte (uvref vector i)))
-	    (when (characterp byte)
-	      (setq byte (char-code byte)))
-	    (funcall wbf ioblock byte)))
-	(do* ((pos start (+ pos written))
-	      (left total (- left written)))
-	     ((= left 0))
-	  (declare (fixnum pos left))
-	  (setf (ioblock-dirty ioblock) t)
-	  (let* ((index (io-buffer-idx out))
-		 (count (io-buffer-count out))
-		 (avail (- limit index)))
-	    (declare (fixnum index avail count))
-	    (cond
-	      ((= (setq written avail) 0)
-	       (%ioblock-force-output ioblock nil))
-	      (t
-	       (if (> written left)
-		 (setq written left))
-	       (%copy-ivector-to-ivector
-		vector
-		(ioblock-elements-to-octets ioblock pos)
-		buf
-		(ioblock-elements-to-octets ioblock index)
-		(ioblock-elements-to-octets ioblock written))
-	       (setf (ioblock-dirty ioblock) t)
-	       (incf index written)
-	       (if (> index count)
-		 (setf (io-buffer-count out) index))
-	       (setf (io-buffer-idx out) index)
-	       (if (= index  limit)
-		 (%ioblock-force-output ioblock nil)))))))))))
+      (without-interrupts
+       (let* ((out (ioblock-outbuf ioblock))
+              (buf (io-buffer-buffer out))
+              (written 0)
+              (limit (io-buffer-limit out))
+              (total (- end start))
+              (buftype (typecode buf)))
+         (declare (fixnum buftype written total limit))
+         (if (not (= (the fixnum (typecode vector)) buftype))
+           (do* ((i start (1+ i))
+                 (wbf (ioblock-write-byte-function ioblock)))
+                ((= i end))
+             (let ((byte (uvref vector i)))
+               (when (characterp byte)
+                 (setq byte (char-code byte)))
+               (funcall wbf ioblock byte)))
+           (do* ((pos start (+ pos written))
+                 (left total (- left written)))
+                ((= left 0))
+             (declare (fixnum pos left))
+             (setf (ioblock-dirty ioblock) t)
+             (let* ((index (io-buffer-idx out))
+                    (count (io-buffer-count out))
+                    (avail (- limit index)))
+               (declare (fixnum index avail count))
+               (cond
+                 ((= (setq written avail) 0)
+                  (%ioblock-force-output ioblock nil))
+                 (t
+                  (if (> written left)
+                    (setq written left))
+                  (%copy-ivector-to-ivector
+                   vector
+                   (ioblock-elements-to-octets ioblock pos)
+                   buf
+                   (ioblock-elements-to-octets ioblock index)
+                   (ioblock-elements-to-octets ioblock written))
+                  (setf (ioblock-dirty ioblock) t)
+                  (incf index written)
+                  (if (> index count)
+                    (setf (io-buffer-count out) index))
+                  (setf (io-buffer-idx out) index)
+                  (if (= index  limit)
+                    (%ioblock-force-output ioblock nil))))))))))))
 
 
@@ -4790,5 +4910,8 @@
     (let* ((ioblock (basic-stream-ioblock stream)))
       (with-ioblock-input-locked (ioblock)
-        (%ioblock-binary-read-vector ioblock vector start end)))))
+        (locally (declare (optimize (speed 3)))
+          (without-interrupts
+           (values
+            (%ioblock-binary-read-vector ioblock vector start end))))))))
 
 (defmethod stream-read-vector ((stream buffered-character-input-stream-mixin)
@@ -4798,6 +4921,9 @@
     (call-next-method)
     (with-stream-ioblock-input (ioblock stream :speedy t)
-      (funcall (ioblock-character-read-vector-function ioblock)
-               ioblock vector start end))))
+        (locally (declare (optimize (speed 3)))
+          (without-interrupts
+           (values
+            (funcall (ioblock-character-read-vector-function ioblock)
+                     ioblock vector start end)))))))
 
 
@@ -4809,5 +4935,8 @@
     (call-next-method)
     (with-stream-ioblock-input (ioblock stream :speedy t)
-      (%ioblock-binary-read-vector ioblock vector start end))))
+        (locally (declare (optimize (speed 3)))
+          (without-interrupts
+           (values
+            (%ioblock-binary-read-vector ioblock vector start end)))))))
 
 
Index: /trunk/ccl/lib/streams.lisp
===================================================================
--- /trunk/ccl/lib/streams.lisp	(revision 5356)
+++ /trunk/ccl/lib/streams.lisp	(revision 5357)
@@ -34,11 +34,13 @@
 (defun read-line (&optional input-stream (eof-error-p t) eof-value recursive-p)
   
-  (declare (ignore recursive-p))
+  (declare (ignore recursive-p)
+           (optimize (speed 3)))
   (let* ((input-stream (designated-input-stream input-stream)))
     (multiple-value-bind (string eof)
         (if (typep input-stream 'basic-stream)
           (let* ((ioblock (basic-stream-ioblock input-stream)))
-            (with-ioblock-input-locked (ioblock)
-              (funcall (ioblock-read-line-function ioblock) ioblock)))
+            (without-interrupts
+             (with-ioblock-input-locked (ioblock)
+               (funcall (ioblock-read-line-function ioblock) ioblock))))
           (stream-read-line input-stream))
       (if eof
@@ -55,10 +57,10 @@
   (setq input-stream (designated-input-stream input-stream))
   (if (typep input-stream 'basic-stream)
-    (let* ((ioblock (basic-stream.state input-stream)))
-      (if ioblock
-        (check-eof
-         (funcall (ioblock-read-char-function ioblock) ioblock)
-         input-stream eof-error-p eof-value)
-        (stream-is-closed input-stream)))
+    (let* ((ioblock (basic-stream-ioblock input-stream)))
+      (check-eof
+       (without-interrupts
+        (values
+         (funcall (ioblock-read-char-function ioblock) ioblock)))
+       input-stream eof-error-p eof-value))
     (check-eof (stream-read-char input-stream)
                input-stream
@@ -68,5 +70,16 @@
 (defun unread-char (char &optional input-stream)
   (let* ((input-stream (designated-input-stream input-stream)))
-    (stream-unread-char input-stream char)
+    (if (typep input-stream 'basic-stream)
+      (let* ((flags (basic-stream.flags input-stream)))
+        (declare (fixnum flags))
+        (if (= (the fixnum (logand flags (logior (ash 1 basic-stream-flag.open-input)
+                                                 (ash 1 basic-stream-flag.open-character))))
+               (logior (ash 1 basic-stream-flag.open-input)
+                                                 (ash 1 basic-stream-flag.open-character)))
+          (let* ((ioblock (basic-stream-ioblock input-stream)))
+            (without-interrupts
+             (%ioblock-untyi ioblock char)))
+          (stream-unread-char input-stream char)))
+      (stream-unread-char input-stream char))
     nil))
 
@@ -96,12 +109,12 @@
 
 (defun read-byte (stream &optional (eof-error-p t) eof-value)
+  (declare (optimize (speed 3) (space 0)))
   (if (typep stream 'basic-stream)
-    (let* ((ioblock (basic-stream.state stream)))
-      (if ioblock
-        (check-eof (funcall (ioblock-read-byte-function ioblock) ioblock)
-                   stream
-                   eof-error-p
-                   eof-value)
-        (stream-is-closed ioblock)))
+    (let* ((ioblock (basic-stream-ioblock stream)))
+      (check-eof (without-interrupts
+                  (values (funcall (ioblock-read-byte-function ioblock) ioblock)))
+                 stream
+                 eof-error-p
+                 eof-value))
     (check-eof
      (stream-read-byte stream)
@@ -129,8 +142,11 @@
 
 (defun write-byte (byte stream)
+  (declare (optimize (speed 3) (space 0)))
   "Write one byte, BYTE, to STREAM."
   (if (typep stream 'basic-stream)
     (let* ((ioblock (basic-stream-ioblock stream)))
-      (funcall (ioblock-write-byte-function ioblock) ioblock byte))
+      (without-interrupts
+       (values
+        (funcall (ioblock-write-byte-function ioblock) ioblock byte))))
     (stream-write-byte stream byte))
   byte)
