0.8.8.8:
[sbcl.git] / contrib / sb-simple-streams / file.lisp
index 56ec6ec..5fd3d70 100644 (file)
            (sb-ext:cancel-finalization stream)
            (error "Error fstating ~S: ~A" stream
                   (sb-int:strerror dev)))
-         (when (> size most-positive-fixnum)
+         (when (>= size most-positive-fixnum)
            ;; Or else BUF-LEN has to be a general integer, or
            ;; maybe (unsigned-byte 32).  In any case, this means
            ;; BUF-MAX and BUF-PTR have to be the same, which means
            ;; bigger files, anyway.  Maybe DEVICE-READ can adjust
            ;; the mapped portion of the file when necessary?
            (warn "Unable to memory-map entire file.")
-           (setf size most-positive-fixnum))
+           (setf size (1- most-positive-fixnum)))
          (let ((buffer
                 (handler-case
                   (sb-posix:mmap nil size prot sb-posix::MAP-SHARED fd 0)
     (sb-unix:unix-close (or (sm input-handle stream) (sm output-handle stream))))
   t)
 
-;; TODO: implement msync in sb-posix; activate this
-#+paul
 (defmethod device-write ((stream mapped-file-simple-stream) buffer
                         start end blocking)
   (assert (eq buffer :flush) (buffer)) ; finish/force-output
   (with-stream-class (mapped-file-simple-stream stream)
-    (unix:unix-msync (sm buffer stream) (sm buf-len stream)
-                    (if blocking unix:ms_sync unix:ms_async))))
+    (sb-posix:msync (sm buffer stream) (sm buf-len stream)
+                    (if blocking sb-posix::ms-sync sb-posix::ms-async))))
 
 (defmethod device-open ((stream probe-simple-stream) options)
   (let ((pathname (getf options :filename)))