[Haskell-cafe] how to use hs_init_ghc and pass runtime params to a dll
Kees Bleijenberg
k.bleijenberg at lijbrandt.nl
Mon Sep 22 08:16:36 UTC 2014
Can someone provide a (pointer to a) working basic example of C code that
uses a Windows dll created by ghc that calls hs_init_ghc?
Can someone confirm that hs_init_ghc uses stdcall in a windows dll.
Is ghc -no-hs-main -shared -threaded -O2 -o TBGlas.dll TBGlasDll.hs a
correct way to create the dll?
Do I have to use the ghc parameter -dynamic? if I use this parameter, the
ghc tells me to install the 'dyn' libraries for package base. Sounds aweful.
I'am using ghc version 7.8.3. and the 32 bits Haskell Platform on 64 bits
Windows 7.
Background:
I create a dll with ghc. The program that uses the dll starts with a lookup
for all functions I want to use from the dll. The result is a bunch of
function pointers. I use a function pointer to call the real function. Then
I call the defaultRtsConfig function from the dll. I get a pointer to a
struct with a byte for the enumarable RTSOptEnabled followed by a pointer to
a string. In the returned struct this pointer is nil. Then I set the
pointer in the struct to the string "-N -s". After that I call
hs_init_ghc(nil,nil,defaultRtsConcfigStruct).
This works fine. I get a overview of the sparks created, the elapsed times,
there is a speedup from the parallel code etc. But sometimes (1 out of 100)
the program crashes.
Any ideas what could be wrong?
Kees
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140922/4e296c44/attachment.html>
More information about the Haskell-Cafe
mailing list