[project @ 2000-07-14 13:28:35 by simonmar]
[ghc-hetmet.git] / ghc / tests / ccall / should_compile / cc005.hs
1 -- !!! cc005 -- foreign export declarations
2 module ShouldCompile (d8) where
3
4 import Foreign
5 import GlaExts
6 import Int
7 import Word
8
9 foreign export ccall dynamic d8  :: (Int -> IO ())  -> IO Addr
10
11 -- exporting functions
12 {-
13 m_stdcall :: Int -> IO Int
14 m_stdcall x = return x
15
16 x = putChar
17
18 foreign export ccall "m1" doo :: Int -> IO Int
19
20 doo :: Eq a => a -> IO Int
21 doo _ = return 2
22
23 foreign export ccall "listAppend" plusplus :: StablePtr [a] -> StablePtr [a] -> IO (StablePtr [a])
24
25 plusplus :: StablePtr [a] -> StablePtr [a] -> IO (StablePtr [a])
26 plusplus x y = do
27   l1 <- deRefStablePtr x
28   l2 <- deRefStablePtr y
29   makeStablePtr (l1 ++ l2)
30
31 foreign export ccall "m11" m_stdcall :: Int -> IO Int
32
33 m_ccall :: Int -> Int -> IO Int
34 m_ccall x y = return (x-y)
35
36 foreign export ccall   "m2" m_ccall   :: Int -> Int -> IO Int
37
38 foreign export ccall   "putcha" putChar :: Char -> IO ()
39
40 foreign export stdcall "Math" "sin" my_sin :: Double -> IO Double
41 foreign export stdcall "Math" "cos" my_cos :: Double -> IO Double
42
43 my_sin = undefined
44 my_cos = undefined
45
46 foreign export stdcall "m111" m8  :: IO Int8
47 foreign export stdcall "m22" m16 :: IO Int16
48 foreign export stdcall "m3" m32 :: IO Int32
49 foreign export stdcall "m4" m64 :: IO Int64
50
51 m8 = undefined
52 m16 = undefined
53 m32 = undefined
54 m64 = undefined
55
56 foreign export stdcall dynamic d8  :: (Addr -> IO Int8)  -> IO Addr
57 foreign export stdcall dynamic d16 :: (Addr -> IO Int16) -> IO Addr
58 foreign export stdcall dynamic d32 :: (Addr -> IO Int32) -> IO Addr
59 foreign export stdcall dynamic d64 :: (Addr -> IO Int64) -> IO Addr
60
61
62 d8 = undefined
63 d16 = undefined
64 d32 = undefined
65 d64 = undefined
66
67
68 foreign export ccall "kitchen"
69    sink :: --ForeignObj 
70 --        -> ByteArray Int 
71 --      -> MutableByteArray Int RealWorld
72            Int
73         -> Int8
74         -> Int16
75         -> Int32
76         -> Int64
77         -> Word8
78         -> Word16
79         -> Word32
80         -> Word64
81         -> Float
82         -> Double
83         -> IO Int
84
85 sink  = undefined
86 sink2 = undefined
87
88 foreign export ccall dynamic
89   sink2 :: (--ForeignObj 
90 --        -> ByteArray Int 
91 --      -> MutableByteArray Int RealWorld
92            StablePtr a
93         -> Int
94         -> Int8
95         -> Int16
96         -> Int32
97         -> Int64
98         -> Word8
99         -> Word16
100         -> Word32
101         -> Word64
102         -> Float
103         -> Double
104         -> IO ())
105         -> IO Addr
106
107
108 -}