guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Feature Request] Some ideas on 'mmap'


From: Nala Ginrut
Subject: [Feature Request] Some ideas on 'mmap'
Date: Tue, 30 Apr 2013 17:27:59 +0800

hi guys!
A discussion on IRC about adding 'mmap' raised, and I will share some
ideas on this topic:

1. Complex one or simple one?
The simple one is just a simple wrapper taking advantage of (system
foreign).
The complex one is more alike Python's mmap module. Contains a special
type of <mmap>, and a bunch of functions to handle it.

2. If simple one, just leave the rest of the mail alone.
But if complex one was chosen, we need (ice-9 mmap).

3. I'll choose Python alike interface for mmap:
(mmap port #:optional length prog flags offset)
And if port is #f, it works as anonymous-mapping.

4. mmap returns a new type <mmap>, and it may work like 'array':
(define m (mmap port))
(mmap-ref m 10 20)
(mmap-set! m 0 0 1024)
The interfaces maybe:
(mmap-ref <mmap> from to) ==> return u8 bytevector
(mmap-set! <mmap> byte from to) ==> return unspecified

5. use munmap to release it
(munmap <mmap>)

6. other helper functions also available:
(mmap-find <mmap> string #:optional start end)
(mmap-flush <mmap> #:optional offset size)
(mmap-move <mmap> dest src count)
(mmap-read <mmap> num)
(mmap-readbyte <mmap>)
(mmap-readline <mmap>)
(mmap-resize <mmap> newsize)
(mmap-rfind <mmap> string #:optional start end)
(mmap-seek <mmap> pos #:optional whence)
(mmap-size <mmap>)
(mmap-tell <mmap>) ; Returns the current position of the file pointer.
(mmap-write <mmap> str/bv)
(mmap-writebyte <mmap> byte)

Comments?
Thanks!





reply via email to

[Prev in Thread] Current Thread [Next in Thread]