working example for mmap (for me OpenBSD 32 bit, chicken. master) added by C-Keen on Wed Oct 2 15:41:48 2013
;;; test.scm (use posix) (use lolevel) ;; Reading #;(let* ((fd (file-open "example-mmap.scm" (+ open/read open/nonblock))) (size (file-size fd)) (mmap (map-file-to-memory #f size prot/read (+ map/file map/shared) fd)) (buf (memory-mapped-file-pointer mmap)) (str (make-string size))) (move-memory! buf str size) (display str) (unmap-file-from-memory mmap) (file-close fd)) ;; Writing - SEGFAULTS! (let* ((fd (file-open "example-mmap.scm" open/rdwr)) (size (file-size fd)) (mmap (map-file-to-memory #f size (+ prot/read prot/write) (+ map/file map/shared) fd)) (buf (memory-mapped-file-pointer mmap))) (print "file size " size) (print "string size " (string-length "0123456789\n")) (print "buf " buf) (move-memory! "0123456789\n" buf size))