Remove GHC's haskell98 dependency
[ghc-hetmet.git] / compiler / prelude / ForeignCall.lhs
index df30934..a6047a5 100644 (file)
@@ -13,7 +13,7 @@
 
 module ForeignCall (
        ForeignCall(..),
-       Safety(..), playSafe, playThreadSafe,
+       Safety(..), playSafe,
 
        CExportSpec(..), CLabelString, isCLabelString, pprCLabelString,
        CCallSpec(..), 
@@ -25,9 +25,10 @@ module ForeignCall (
     ) where
 
 import FastString
-import Char            ( isAlphaNum )
 import Binary
 import Outputable
+
+import Data.Char
 \end{code}
 
 
@@ -57,11 +58,14 @@ instance Outputable ForeignCall where
 data Safety
   = PlaySafe           -- Might invoke Haskell GC, or do a call back, or
                        -- switch threads, etc.  So make sure things are
-                       -- tidy before the call
-       Bool            -- => True, external function is also re-entrant.
-                       --    [if supported, RTS arranges for the external call
-                       --    to be executed by a separate OS thread, i.e.,
-                       --    _concurrently_ to the execution of other Haskell threads.]
+                       -- tidy before the call. Additionally, in the threaded
+                       -- RTS we arrange for the external call to be executed
+                       -- by a separate OS thread, i.e., _concurrently_ to the
+                       -- execution of other Haskell threads.
+
+      Bool              -- Indicates the deprecated "threadsafe" annotation
+                        -- which is now an alias for "safe". This information
+                        -- is never used except to emit a deprecation warning.
 
   | PlayRisky          -- None of the above can happen; the call will return
                        -- without interacting with the runtime system at all
@@ -77,10 +81,6 @@ instance Outputable Safety where
 playSafe :: Safety -> Bool
 playSafe PlaySafe{} = True
 playSafe PlayRisky  = False
-
-playThreadSafe :: Safety -> Bool
-playThreadSafe (PlaySafe x) = x
-playThreadSafe _ = False
 \end{code}
 
 
@@ -116,7 +116,7 @@ data CCallTarget
 
 isDynamicTarget :: CCallTarget -> Bool
 isDynamicTarget DynamicTarget = True
-isDynamicTarget other        = False
+isDynamicTarget _             = False
 \end{code}
 
 
@@ -131,9 +131,11 @@ stdcall:   Caller allocates parameters, callee deallocates.
 ToDo: The stdcall calling convention is x86 (win32) specific,
 so perhaps we should emit a warning if it's being used on other
 platforms.
+See: http://www.programmersheaven.com/2/Calling-conventions
 
 \begin{code}
-data CCallConv = CCallConv | StdCallConv | CmmCallConv
+data CCallConv = CCallConv | StdCallConv | CmmCallConv | PrimCallConv
   deriving (Eq)
   {-! derive: Binary !-}
 
@@ -141,6 +143,7 @@ instance Outputable CCallConv where
   ppr StdCallConv = ptext (sLit "stdcall")
   ppr CCallConv   = ptext (sLit "ccall")
   ppr CmmCallConv = ptext (sLit "C--")
+  ppr PrimCallConv = ptext (sLit "prim")
 
 defaultCCallConv :: CCallConv
 defaultCCallConv = CCallConv
@@ -331,11 +334,14 @@ instance Binary CCallConv where
            putByte bh 0
     put_ bh StdCallConv = do
            putByte bh 1
+    put_ bh PrimCallConv = do
+           putByte bh 2
     get bh = do
            h <- getByte bh
            case h of
              0 -> do return CCallConv
-             _ -> do return StdCallConv
+             1 -> do return StdCallConv
+             _ -> do return PrimCallConv
 
 instance Binary DNCallSpec where
     put_ bh (DNCallSpec isStatic kind ass nm _ _) = do