[Haskell-cafe] FFI question

Vasili I. Galchin vigalchin at gmail.com
Mon Sep 8 08:44:55 UTC 2014


Following is a fragment generated by hsc2hs from LockedMem.hsc:

#line 93 "LockedMem.hsc"
    hsc_const (MCL_CURRENTandFUTURE);
    hsc_fputs (")\n"
           "", hsc_stdout());
    hsc_line (94, "LockedMem.hsc");
    hsc_fputs ("\n"
           "foreign import ccall unsafe \"sys/mman.h mlockall\"\n"
           "    c_mlockall :: CInt -> IO CInt\n"
           "\n"
           "\n"
           "-- | unlock all mapped pages of a process!\n"
           "unlockAllMemory :: IO ()   \n"
           "unlockAllMemory = do\n"
           "   throwErrnoIfMinus1 \"unlockAllMemory\" (c_munlockall)\n"
           "   return ()\n"
           "\n"
           "foreign import ccall unsafe \"sys/mman.h munlockall\"\n"
           "    c_munlockall :: IO CInt\n"
           "", hsc_stdout());
    return 0;

On Mon, Sep 8, 2014 at 2:11 AM, Vasili I. Galchin <vigalchin at gmail.com> wrote:
> Hello,
>
>      I need memory refreshing about FFI because I need to fix a bug
> (plus I got down a rat hole because of Ukraine war :-(). Following a
> snippet of something I wrote:
>
> -- | lock all of the memory space of a process
> lockAllMemory :: LockAllFlags -> IO ()
> lockAllMemory flags = do
>     throwErrnoIfMinus1 "lockAllMemory" (c_mlockall cflags)
>     return ()
>   where
>     cflags = case flags of
>                    CURRENT          -> (#const MCL_CURRENT)
>                    FUTURE           -> (#const MCL_FUTURE)
>                    CURRENTandFUTURE -> (#const MCL_CURRENTandFUTURE)
>
>
> it is a file called LockedMem.hsc and the third arm CURRENTandFUTURE I
> just added to fix the this  bug ..
>
> MCL_CURRENTandFUTURE ends up in LockedMem_make.c(sp??) but I get a
> undeclared nasty message when I try to build LockedMem.hsc... my
> bad... . Please help so I can go back to help Ukraine.
>
> Kind regarsd,
>
> Vasya


More information about the Haskell-Cafe mailing list