Changeset 424


Ignore:
Timestamp:
Jan 30, 2004, 11:43:21 AM (21 years ago)
Author:
Gary Byers
Message:

CLOSE: set the closed slot to ... something non-NULL.
STREAM-IO-ERROR: so things like sockets can specialize it.
Need to test ELEMENT-SHIFT stuff; not sure if I merged Bryan's patch correctly.

File:
1 edited

Legend:

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

    r384 r424  
    203203  t)
    204204
     205(defmethod stream-io-error ((stream stream) error-number context)
     206  (error 'simple-stream-error :stream stream
     207         :format-control (format nil "~a during ~a"
     208                                 (%strerror error-number) context)))
    205209
    206210(defmethod instance-initialize :after ((stream input-stream) &key)
     
    245249  (declare (ignore abort))
    246250  (with-slots ((closed closed)) stream
    247       (unless closed
    248         (setf closed nil))))
     251    (unless closed
     252      (setf closed t))))
    249253
    250254
     
    822826
    823827(defun init-stream-ioblock (stream
    824                             &key
    825                             insize      ; integer to allocate inbuf here, nil
     828                            &key
     829                            insize ; integer to allocate inbuf here, nil
    826830                                        ; otherwise
    827                             outsize     ; integer to allocate outbuf here, nil
     831                            outsize ; integer to allocate outbuf here, nil
    828832                                        ; otherwise
    829                             share-buffers-p ; true if input and output
     833                            share-buffers-p ; true if input and output
    830834                                        ; share a buffer
    831                             (element-type 'character)
    832                             device
    833                             advance-function
    834                             listen-function
    835                             eofp-function
    836                             force-output-function
    837                             close-function
    838                             element-shift
    839                             interactive
    840                             &allow-other-keys)
     835                            element-type
     836                            device
     837                            advance-function
     838                            listen-function
     839                            eofp-function
     840                            force-output-function
     841                            close-function
     842                            element-shift
     843                            interactive
     844                            &allow-other-keys)
     845  (declare (ignorable element-shift))
    841846  (let* ((ioblock (or (let* ((ioblock (stream-ioblock stream nil)))
    842                         (when ioblock
    843                           (setf (ioblock-stream ioblock) stream)
    844                           ioblock))
    845                      (stream-create-ioblock stream))))
     847                        (when ioblock
     848                          (setf (ioblock-stream ioblock) stream)
     849                          ioblock))
     850                      (stream-create-ioblock stream))))
    846851    (when insize
    847852      (unless (ioblock-inbuf ioblock)
     
    852857                                :bufptr ptr
    853858                                :size in-size-in-octets
    854                                 :limit insize))
    855           (setf (ioblock-inbuf-lock ioblock) (make-lock)))))
     859                                :limit insize))
     860          (setf (ioblock-inbuf-lock ioblock) (make-lock))
     861          (setf (ioblock-element-shift ioblock) (1- (/ in-size-in-octets insize)))
     862          )))
    856863    (if share-buffers-p
    857       (if insize
    858         (progn (setf (ioblock-outbuf ioblock)
    859                      (ioblock-inbuf ioblock))
    860                (setf (ioblock-outbuf-lock ioblock)
    861                      (ioblock-inbuf-lock ioblock)))
    862         (error "Can't share buffers unless insize is non-zero and non-null"))
     864        (if insize
     865            (progn (setf (ioblock-outbuf ioblock)
     866                         (ioblock-inbuf ioblock))
     867                   (setf (ioblock-outbuf-lock ioblock)
     868                         (ioblock-inbuf-lock ioblock)))
     869          (error "Can't share buffers unless insize is non-zero and non-null"))
    863870     
    864871      (when outsize
     
    867874              (make-heap-buffer element-type outsize)
    868875            (setf (ioblock-outbuf ioblock)
    869                   (make-io-buffer :buffer buffer
    870                                   :bufptr ptr
    871                                   :count 0
    872                                   :limit outsize
    873                                   :size out-size-in-octets))
    874             (setf (ioblock-outbuf-lock ioblock) (make-lock))))))
    875     (when element-shift
    876       (setf (ioblock-element-shift ioblock) element-shift))
     876                  (make-io-buffer :buffer buffer
     877                                  :bufptr ptr
     878                                  :count 0
     879                                  :limit outsize
     880                                  :size out-size-in-octets))
     881            (setf (ioblock-outbuf-lock ioblock) (make-lock))
     882            (setf (ioblock-element-shift ioblock) (1- (/ out-size-in-octets outsize)))
     883            ))))
     884    (when element-type
     885      (setf (ioblock-element-type ioblock) element-type))
     886;    (when element-shift
     887;      (setf (ioblock-element-shift ioblock) element-shift))
    877888    (when device
    878889      (setf (ioblock-device ioblock) device))
     
    21552166          (declare (fixnum n))
    21562167          (if (< n 0)
    2157             (error 'simple-stream-error :stream s :format-control (%strerror n))
     2168            (stream-io-error s (- n) "read")
    21582169            (if (> n 0)
    21592170              (setf (io-buffer-count buf)
     
    22002211          (declare (fixnum written))
    22012212          (if (< written 0)
    2202             (error 'simple-stream-error
    2203                    :stream s
    2204                    :format-control (%strerror written)))
     2213            (stream-io-error s (- written) "write"))
    22052214          (decf octets written)
    22062215          (unless (zerop octets)
Note: See TracChangeset for help on using the changeset viewer.