-dsCImport modName id (CLabel cid) _ _
- = ASSERT(fromJust resTy `eqType` addrPrimTy) -- typechecker ensures this
- returnDs ([(id, rhs)], empty, empty)
- where
- (resTy, foRhs) = resultWrapper (idType id)
- rhs = foRhs (mkLit (MachLabel cid))
-dsCImport modName id (CFunction target) cconv safety
- = dsFCall modName id (CCall (CCallSpec target cconv safety))
-dsCImport modName id CWrapper cconv _
- = dsFExportDynamic modName id cconv
+dsCImport id (CLabel cid) _ _ no_hdrs
+ = resultWrapper (idType id) `thenDs` \ (resTy, foRhs) ->
+ ASSERT(fromJust resTy `eqType` addrPrimTy) -- typechecker ensures this
+ let rhs = foRhs (mkLit (MachLabel cid Nothing)) in
+ returnDs ([(setImpInline no_hdrs id, rhs)], empty, empty)
+dsCImport id (CFunction target) cconv safety no_hdrs
+ = dsFCall id (CCall (CCallSpec target cconv safety)) no_hdrs
+dsCImport id CWrapper cconv _ _
+ = dsFExportDynamic id cconv
+
+setImpInline :: Bool -- True <=> No #include headers
+ -- in the foreign import declaration
+ -> Id -> Id
+-- If there is a #include header in the foreign import
+-- we make the worker non-inlinable, because we currently
+-- don't keep the #include stuff in the CCallId, and hence
+-- it won't be visible in the importing module, which can be
+-- fatal.
+-- (The #include stuff is just collected from the foreign import
+-- decls in a module.)
+-- If you want to do cross-module inlining of the c-calls themselves,
+-- put the #include stuff in the package spec, not the foreign
+-- import decl.
+setImpInline True id = id
+setImpInline False id = id `setInlinePragma` NeverActive