I made the modifcations you suggested (convert
__init_Main to __init_Convert and that results in:

/usr/lib/ghc-4.08.1/libHSstd.a(PrelMain__1.o)(.text+0x16):
undefined reference to `__init_Main'

I get the same result when I try to compile the test
program that you sent to me.  Attached is the output
of the compilation process generated when compiling
your test program (with the -v switch).

Any ideas why this is happening?

Thanks,
T.J.

--- Sigbjorn Finne <[EMAIL PROTECTED]> wrote:
> "T.J. Brown" [EMAIL PROTECTED] writes:
> >
> > I'm trying to write a program (in C) that calls a
> > function that is implemented in Haskell.
> > ...
> > The problem I'm seeing is that depending
> > on the size of the buffer, the program
> segmentation
> > faults.  I don't see any obvious reason that this
> is
> > happening so I'm wondering if something isn't
> going
> > wrong during the compilation.
> 
> Hi,
> 
> your converttst.c contains the following decl:
> 
> extern void startupHaskell (int argc, char* argv[],
> void* rootMod);
> void* __init_Main;
> 
> That won't work, as the root module argument needs
> to point to
> something valid. Rewrite it to:
> 
> extern void startupHaskell (int argc, char* argv[],
> void* rootMod);
> extern void* __init_Convert;
> 
> and substitute __init_Main with __init_Convert
> wherever it is used
> in the C code.
> 
> However, if you recompile and link, I believe you'll
> see it crashing
> even more regularly - I suspect this is due to a bug
> in the GHC
> RTS (at least 4.08.1's, don't know if 4.08.2 has
> fixed this) Attached
> is a simpler program that shows up the problem.
> 
> > Also, is there a better way of passing a buffer
> > between C and Haskell?  For instance, is there a
> way
> > to convert the buffer into a list automatically?
> 
> Yes, you can simplify Convert.convert a little, but
> your
> example highlights a dark corner that HaskellDirect
> doesn't
> implement fully, i.e., dependent arguments in
> Haskell
> server proxies. You *should* be able to just say
> 
>     [pure]
>     void convert([in,length_is(len)] unsigned long
> *inBuf,
>                         [in] int len,
>                         [out,length_is(len*4)]
> unsigned char *outBuf);
> 
> and have the generated Haskell code expect
> Convert.convert
> to have the signature ([Word32] -> [Word8]) - I'm
> working
> on implementing this at this very moment.
> 
> --sigbjorn
> 
> 
> 

> ATTACHMENT part 2 application/x-gzip
name=test.tar.gz



__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

_______________________________________________
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to