Commit aba5a247 authored by sof's avatar sof
Browse files

[project @ 1999-10-31 15:35:32 by sof]

To workaround gcc/egcs bugs re: handling of non-toplevel "extern" decls,
lift them out to the top. i.e., extend mechanism by which "typedefs"
are lifted out to the toplevel (for the same reasons) to also encompass
"extern"s.

Note: the default is not to emit an "extern" decl for every _ccall_,
as this runs the chance of (trivially) conflicting with header file
includes. So, to enable, use -optC-femit-extern-decls.
parent 047d0537
% %
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
% %
% $Id: AbsCSyn.lhs,v 1.24 1999/06/24 13:04:13 simonmar Exp $ % $Id: AbsCSyn.lhs,v 1.25 1999/10/31 15:35:32 sof Exp $
% %
\section[AbstractC]{Abstract C: the last stop before machine code} \section[AbstractC]{Abstract C: the last stop before machine code}
...@@ -166,7 +166,8 @@ stored in a mixed type location.) ...@@ -166,7 +166,8 @@ stored in a mixed type location.)
typedefs if needs be (i.e., when generating .hc code and typedefs if needs be (i.e., when generating .hc code and
compiling 'foreign import dynamic's) compiling 'foreign import dynamic's)
-} -}
| CCallTypedef PrimOp{-CCallOp-} [CAddrMode] [CAddrMode] | CCallTypedef Bool {- True => use "typedef"; False => use "extern"-}
PrimOp{-CCallOp-} [CAddrMode] [CAddrMode]
-- *** the next three [or so...] are DATA (those above are CODE) *** -- *** the next three [or so...] are DATA (those above are CODE) ***
......
...@@ -27,7 +27,7 @@ import PrimRep ( getPrimRepSize, PrimRep(..) ) ...@@ -27,7 +27,7 @@ import PrimRep ( getPrimRepSize, PrimRep(..) )
import Unique ( Unique{-instance Eq-} ) import Unique ( Unique{-instance Eq-} )
import UniqSupply ( uniqFromSupply, uniqsFromSupply, splitUniqSupply, import UniqSupply ( uniqFromSupply, uniqsFromSupply, splitUniqSupply,
UniqSupply ) UniqSupply )
import CmdLineOpts ( opt_ProduceC ) import CmdLineOpts ( opt_ProduceC, opt_EmitCExternDecls )
import Maybes ( maybeToBool ) import Maybes ( maybeToBool )
import PrimOp ( PrimOp(..) ) import PrimOp ( PrimOp(..) )
import Panic ( panic ) import Panic ( panic )
...@@ -329,11 +329,17 @@ flatAbsC (CSwitch discrim alts deflt) ...@@ -329,11 +329,17 @@ flatAbsC (CSwitch discrim alts deflt)
= flatAbsC absC `thenFlt` \ (alt_heres, alt_tops) -> = flatAbsC absC `thenFlt` \ (alt_heres, alt_tops) ->
returnFlt ( (tag, alt_heres), alt_tops ) returnFlt ( (tag, alt_heres), alt_tops )
flatAbsC stmt@(COpStmt results td@(CCallOp (Right _) _ _ _) args vol_regs) flatAbsC stmt@(COpStmt results td@(CCallOp _ _ _ _) args vol_regs)
| maybeToBool opt_ProduceC | isCandidate && maybeToBool opt_ProduceC
= returnFlt (stmt, tdef) = returnFlt (stmt, tdef)
where where
tdef = CCallTypedef td results args (isCandidate, isDyn) =
case td of
CCallOp (Right _) _ _ _ -> (True, True)
CCallOp (Left _) is_asm _ _ -> (opt_EmitCExternDecls && not is_asm, False)
_ -> (False, False)
tdef = CCallTypedef isDyn td results args
flatAbsC stmt@(CSimultaneous abs_c) flatAbsC stmt@(CSimultaneous abs_c)
= flatAbsC abs_c `thenFlt` \ (stmts_here, tops) -> = flatAbsC abs_c `thenFlt` \ (stmts_here, tops) ->
......
...@@ -53,7 +53,7 @@ platforms. ...@@ -53,7 +53,7 @@ platforms.
\begin{code} \begin{code}
callConvAttribute :: CallConv -> String callConvAttribute :: CallConv -> String
callConvAttribute cc callConvAttribute cc
| cc == stdCallConv = "__attribute__((stdcall))" | cc == stdCallConv = "__stdcall"
| cc == cCallConv = "" | cc == cCallConv = ""
| otherwise = panic ("callConvAttribute: cannot handle" ++ showSDoc (pprCallConv cc)) | otherwise = panic ("callConvAttribute: cannot handle" ++ showSDoc (pprCallConv cc))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment