[ Simply can't resist...  ;-) ]

Simon Marlow wrote:
> The easiest way is to declare mmap as a foreign function using
> foreign import, then build a little wrapper around it.

A problem will be: What Haskell types should be used for size_t and
off_t? Getting this done properly would require autoconf or something
similar. Perhaps some more Haskell types (Size, Off, ...) should be
added to the FFI module. I'm not sure which ones exactly and if FFI
is the right place for it. Opinions?

> [...] but you'll be able to return an Addr and use writeXXXOffAddr/
> readXXXOffAddr to access it(*).

If you are using GHC 4.06 you should better use the Storable class in
the module FFI. For an idea what a slightly higher-level module
layered upon FFI could look like, see

   http://www.informatik.uni-muenchen.de/~Sven.Panne/haskell_libs/ffi/Marshal.hs

or Manuel's

   http://www.informatik.uni-muenchen.de/~Sven.Panne/haskell_libs/ffi/C2HSMarsh.hs

from his C->HS tool. Both should be merged and improved somehow,
suggestions welcome.

> (*) the readXXXOffAddr functions are known to be broken at the
> moment (see recent discussion on ghc-bugs), we're currently working
> on fixing them.

A workaround is not using -O for modules using FFI or readXXXOffAddr.

Cheers,
   Sven
-- 
Sven Panne                                        Tel.: +49/89/2178-2235
LMU, Institut fuer Informatik                     FAX : +49/89/2178-2211
LFE Programmier- und Modellierungssprachen              Oettingenstr. 67
mailto:[EMAIL PROTECTED]            D-80538 Muenchen
http://www.informatik.uni-muenchen.de/~Sven.Panne

Reply via email to