1 {-# LANGUAGE ForeignFunctionInterface #-}
4 module Mate.GarbageAlloc where
12 -- unified place for allocating Memory
13 -- TODO: implement GC stuff ;-)
15 mallocClassData :: Int -> IO (Ptr a)
16 mallocClassData size = do
17 printfStr "mallocClassData: %d\n" size
20 mallocString :: Int -> IO (Ptr a)
21 mallocString size = do
22 printfStr "mallocString: %d\n" size
25 foreign export ccall mallocObject :: Int -> IO CPtrdiff
26 mallocObject :: Int -> IO CPtrdiff
27 mallocObject size = do
28 ptr <- mallocBytes size
29 printfStr "mallocObject: %d\n" size
30 return $ fromIntegral $ ptrToIntPtr ptr
33 foreign export ccall demoInterfaceCall :: CUInt -> IO ()
34 demoInterfaceCall :: CUInt -> IO ()
35 demoInterfaceCall val = do
36 printf "demoInterfaceCall: 0x%08x\n" (fromIntegral val :: Word32)