[Haskell-cafe] FFI question

Vasili I. Galchin vigalchin at gmail.com
Wed Sep 10 03:36:55 UTC 2014


On Tue, Sep 9, 2014 at 10:36 PM, Vasili I. Galchin <vigalchin at gmail.com> wrote:
> Adam,
>
>        Did a find/grep under my posix-realtime  directory .. no
> definition of MCL_CURRENT, MCL_FUTURE or MCL_CURRENTandFUTURE!! But If
> I comment out the case arm MCL_CURRENTandFUTURE in my LockMem.hsc file
> and run "cabal build" from the directory where my *.cabal file lives
> .. clean compile ... Sigh!??!!
>
> Vasya
>
> On Mon, Sep 8, 2014 at 7:36 AM, adam vogt <vogt.adam at gmail.com> wrote:
>> Hi Vasili
>>
>> Does the sys/mman.h or another included header actually define
>> MCL_CURRENTandFUTURE?
>>
>> Regards,
>> Adam
>>
>> On Sep 8, 2014 4:45 AM, "Vasili I. Galchin" <vigalchin at gmail.com> wrote:
>>>
>>> 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
>>> _______________________________________________
>>> Haskell-Cafe mailing list
>>> Haskell-Cafe at haskell.org
>>> http://www.haskell.org/mailman/listinfo/haskell-cafe


More information about the Haskell-Cafe mailing list