cvs commit: hugs98/src HsFFI.h builtin.c connect.h ffi.c static.c

Simon Marlow simonmar@microsoft.com
Wed, 19 Jun 2002 13:57:04 +0100


This is a multi-part message in MIME format.

------_=_NextPart_001_01C21790.CF7D5CE4
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

> reid        2002/06/17 14:46:48 PDT
>=20
>   Modified files:
>     src                  HsFFI.h builtin.c connect.h ffi.c=20
>                          static.c=20
>   Log:
>   Made dynamic and wrapper forms work.
>  =20
>   This is my current test program:

Thanks Alastair, I slurped your test program into GHC's test suite.  I
had to make a few changes to get it to run: the main one is that you
used 'Ptr Char' in a lot of places where the type should have been 'Ptr
CChar', i.e. CString.  I guess in Hugs that doesn't matter too much
because Char and CChar have the same representation at the C level, but
that's not the case for GHC.

I've attached my version.

You might want to take a look in
fptools/testsuite/tests/ghc-regress/ccall, and see if there's anything
in there that might be useful for your test suite.

Cheers,
	Simon

------_=_NextPart_001_01C21790.CF7D5CE4
Content-Type: application/octet-stream;
	name="ffi005.hs"
Content-Transfer-Encoding: base64
Content-Description: ffi005.hs
Content-Disposition: attachment;
	filename="ffi005.hs"

aW1wb3J0IEZvcmVpZ24KaW1wb3J0IEZvcmVpZ24uQwppbXBvcnQgQ29udHJvbC5FeGNlcHRpb24K
aW1wb3J0IFN5c3RlbS5JTy5VbnNhZmUKaW1wb3J0IFByZWx1ZGUgaGlkaW5nIChyZWFkKQppbXBv
cnQgU3lzdGVtLklPIGhpZGluZyAoYnJhY2tldCkKCm1haW4gPSBkbwoKICBwdXRTdHJMbiAiXG5U
ZXN0aW5nIHNpbj09bXlzaW4gKHNob3VsZCByZXR1cm4gbG90cyBvZiBUcnVlcykiCiAgcHJpbnQg
KHRlc3RTaW4gc2luIG15c2luKQoKICBwdXRTdHJMbiAiXG5UZXN0aW5nIGVycm5vIgogIGVyciA8
LSBwZWVrIGVycm5vCiAgcHV0U3RyTG4gJCAiZXJybm8gPT0gIiArKyBzaG93IGVycgoKICBwdXR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