How do I call mmap() in Haskell?
William Lee Irwin III
wli at holomorphy.com
Thu Dec 2 12:56:57 EST 2004
On Thu, Dec 02, 2004 at 05:35:53PM +0000, Duncan Coutts wrote:
> Yes, I've used mmap in a couple projects now just using the FFI. I think
> it would be nice to have a System.Posix.MMap module or something with a
> portable underlying implementation (see how many mmap variants there are
> in the ghc rts MBlock.c implementation to deal with different OSs).
> Of course we would have to agree some common interface(s), like do we
> get back a raw Ptr () or a managed ForeignPtr or what? We'd need current
> users to speak up and say what they're using it for and what interface
> they could live with.
> My initial guess is that we'd need a mmap_raw which gives back an
> unmanaged pointer and also a managed version that has a finaliser that
> calls munmap(). Then there is the range of flags that mmap supports on
> different OSs. Posix specifies the common ones, and then there is
> anonymous pages which can be implemented directly on some systems or
> emulated by opening /dev/null or some other similar trick. Both these
> interfaces should be implementable on win32 systems (via MapViewOfFile
Someone showed me an example of darcs using mmap(). So now I just have
to figure out how to translate that to get it to work with Linux'
remap_file_pages() and some aio interface that can interoperate with it.
More information about the Glasgow-haskell-users