Commit c18e9c21 authored by sewardj's avatar sewardj
Browse files

[project @ 2002-02-21 14:08:57 by sewardj]

new-library-ise
parent 022ec942
......@@ -5,8 +5,8 @@ include ($confdir ++ "/../vanilla-test.T")
-- extra run flags
-- expected process return value, if not zero
test "fed001" { vtr("-fglasgow-exts -package lang", "", "") }
test "ffi001" { vtr("-fglasgow-exts -package lang", "", "") }
test "fed001" { vtr("-fglasgow-exts", "", "") }
test "ffi001" { vtr("-fglasgow-exts", "", "") }
-- skip this test for now: we don't have the machinery to compile the .c file
-- separately.
......
import Foreign
import Monad
import Addr
newtype XPtr a = XPtr Addr
unXPtr (XPtr (A# x)) = x
import Foreign.Ptr
type CInt = Int32
type CSize = Word32
foreign export dynamic
mkComparator :: (XPtr Int -> XPtr Int -> IO CInt)
-> IO (XPtr (XPtr Int -> XPtr Int -> IO CInt))
mkComparator :: (Ptr Int -> Ptr Int -> IO CInt)
-> IO (Ptr (Ptr Int -> Ptr Int -> IO CInt))
foreign import
qsort :: Ptr Int -> CSize -> CSize -> XPtr (XPtr Int -> XPtr Int -> IO CInt)
qsort :: Ptr Int -> CSize -> CSize -> Ptr (Ptr Int -> Ptr Int -> IO CInt)
-> IO ()
compareInts :: XPtr Int -> XPtr Int -> IO CInt
compareInts :: Ptr Int -> Ptr Int -> IO CInt
compareInts a1 a2 = do
i1 <- peek (Ptr (unXPtr a1))
i2 <- peek (Ptr (unXPtr a2))
i1 <- peek a1
i2 <- peek a2
return (fromIntegral (i1 - i2 :: Int))
main :: IO ()
......
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