Sven Panne writes:
>
> The rules for _casm_/_casm_GC_ seem to be as follows:
>
> * Haskell code called via performIO from C-land can use _casm_
> (see (1) above).
>
> * Haskell code calling C-code which calls back Haskell *must* use
> _casm_GC_ (see (2) above).
>
> * Otherwise _casm_ and _casm_GC_ can be mixed freely.
>
Yup, since you're jumping back into Haskell land from C, you'll have
to tidy up all STG context before leaving Haskell (because GCs may
occur while you're away.)
BTW, we're currently reworking the basic FFI primitives. Included in
the new bits is compiler support for exposing Haskell
functions/callbacks to C.
>
> But the whole story is: The _casm_(GC_)s are code generated by
> GreenCard, so a consistent method for calling C is needed. With the
> above observations my "solution" is as follows: Split GreenCard
> sources files in two parts: The first part is the "pure-C" part
The current Green Card (v2) sources support %safecode, which allow you
to control this on a per procedure spec basis. There's a month old
snapshot available in the green-card/ directory on the local ftp
server.
--Sigbjorn