Changeset 4885


Ignore:
Timestamp:
Jul 20, 2006, 12:07:58 AM (18 years ago)
Author:
Gary Byers
Message:

Introduce "owner" slot in basic ioblock. A little tricky to bootstrap.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/level-1/l1-streams.lisp

    r4828 r4885  
    352352  (interactive nil)
    353353  (dirty nil)
    354   (outbuf-lock nil))
     354  (outbuf-lock nil)
     355  (owner nil))
    355356
    356357
     
    422423        (setq idx (io-buffer-idx buf)
    423424              limit (io-buffer-count buf)))
    424       (let ((byte (uvref (io-buffer-buffer buf) idx)))
    425         (setf (io-buffer-idx buf) (the fixnum (1+ idx)))
    426         (if (characterp byte) (%char-code byte) byte)))))
    427 
    428 (defun %ioblock-tyi (ioblock &optional (hang t))
     425      (setf (io-buffer-idx buf) (the fixnum (1+ idx)))
     426      (aref (the (simple-array (unsigned-byte 8) (*))
     427              (io-buffer-buffer buf)) idx))))
     428
     429(declaim (inline %ioblock-tyi))
     430
     431(defun %ioblock-tyi (ioblock)
     432  (declare (optimize (speed 3) (safety 0)))
    429433  (if (ioblock-untyi-char ioblock)
    430434    (prog1 (ioblock-untyi-char ioblock)
     
    435439      (declare (fixnum idx limit))
    436440      (when (= idx limit)
    437         (unless (%ioblock-advance ioblock hang)
     441        (unless (%ioblock-advance ioblock t)
    438442          (return-from %ioblock-tyi (if (ioblock-eof ioblock) :eof)))
    439443        (setq idx (io-buffer-idx buf)
    440444              limit (io-buffer-count buf)))
    441       (let ((byte (uvref (io-buffer-buffer buf) idx)))
    442         (setf (io-buffer-idx buf) (the fixnum (1+ idx)))
    443         (if (characterp byte) byte (%code-char byte))))))
     445      (setf (io-buffer-idx buf) (the fixnum (1+ idx)))
     446      (schar (io-buffer-buffer buf) idx))))
     447
     448(declaim (inline %ioblock-tyy-no-hang))
     449
     450(defun %ioblock-tyi-no-hang (ioblock)
     451  (declare (optimize (speed 3) (safety 0)))
     452  (if (ioblock-untyi-char ioblock)
     453    (prog1 (ioblock-untyi-char ioblock)
     454      (setf (ioblock-untyi-char ioblock) nil))
     455    (let* ((buf (ioblock-inbuf ioblock))
     456           (idx (io-buffer-idx buf))
     457           (limit (io-buffer-count buf)))
     458      (declare (fixnum idx limit))
     459      (when (= idx limit)
     460        (unless (%ioblock-advance ioblock nil)
     461          (return-from %ioblock-tyi-no-hang (if (ioblock-eof ioblock) :eof)))
     462        (setq idx (io-buffer-idx buf)
     463              limit (io-buffer-count buf)))
     464      (setf (io-buffer-idx buf) (the fixnum (1+ idx)))
     465      (schar (io-buffer-buffer buf) idx))))
     466
    444467
    445468(defun %ioblock-peek-char (ioblock)
     
    17611784
    17621785(defun stream-ioblock (stream &optional (error-if-nil t))
    1763   (or (%stream-ioblock stream)
    1764       (when error-if-nil
    1765         (error "~s is closed" stream))))
     1786  (with-slots (ioblock) stream
     1787    (or ioblock
     1788        (when error-if-nil
     1789          (error "~s is closed" stream)))))
    17661790
    17671791(defmethod stream-device ((s buffered-stream-mixin) direction)
     
    18981922(defmethod stream-read-char-no-hang ((stream buffered-character-input-stream-mixin))
    18991923  (with-stream-ioblock-input (ioblock stream :speedy t)
    1900     (%ioblock-tyi ioblock nil)))
     1924    (%ioblock-tyi-no-hang ioblock)))
    19011925
    19021926(defmethod stream-peek-char ((stream buffered-character-input-stream-mixin))
Note: See TracChangeset for help on using the changeset viewer.