projects
/
ghc-base.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add a dummy implementation of System.Timeout.timeout for nhc98
[ghc-base.git]
/
Foreign
/
Marshal
/
Array.hs
diff --git
a/Foreign/Marshal/Array.hs
b/Foreign/Marshal/Array.hs
index
0799aa7
..
b347b3a
100644
(file)
--- a/
Foreign/Marshal/Array.hs
+++ b/
Foreign/Marshal/Array.hs
@@
-1,4
+1,4
@@
-{-# OPTIONS -fno-implicit-prelude #-}
+{-# OPTIONS_GHC -fno-implicit-prelude #-}
-----------------------------------------------------------------------------
-- |
-- Module : Foreign.Marshal.Array
-----------------------------------------------------------------------------
-- |
-- Module : Foreign.Marshal.Array
@@
-79,30
+79,32
@@
import GHC.Base
-- allocation
-- ----------
-- allocation
-- ----------
--- |Allocate storage for the given number of elements of a storable type.
+-- |Allocate storage for the given number of elements of a storable type
+-- (like 'Foreign.Marshal.Alloc.malloc', but for multiple elements).
--
mallocArray :: Storable a => Int -> IO (Ptr a)
mallocArray = doMalloc undefined
where
--
mallocArray :: Storable a => Int -> IO (Ptr a)
mallocArray = doMalloc undefined
where
- doMalloc :: Storable a => a -> Int -> IO (Ptr a)
+ doMalloc :: Storable a' => a' -> Int -> IO (Ptr a')
doMalloc dummy size = mallocBytes (size * sizeOf dummy)
doMalloc dummy size = mallocBytes (size * sizeOf dummy)
--- |Like 'mallocArray', but add an extra element to signal the end of the array
+-- |Like 'mallocArray', but add an extra position to hold a special
+-- termination element.
--
mallocArray0 :: Storable a => Int -> IO (Ptr a)
mallocArray0 size = mallocArray (size + 1)
--
mallocArray0 :: Storable a => Int -> IO (Ptr a)
mallocArray0 size = mallocArray (size + 1)
--- |Temporarily allocate space for the given number of elements.
---
--- * see 'Foreign.Marshal.Alloc.alloca' for the storage lifetime constraints
+-- |Temporarily allocate space for the given number of elements
+-- (like 'Foreign.Marshal.Alloc.alloca', but for multiple elements).
--
allocaArray :: Storable a => Int -> (Ptr a -> IO b) -> IO b
allocaArray = doAlloca undefined
where
--
allocaArray :: Storable a => Int -> (Ptr a -> IO b) -> IO b
allocaArray = doAlloca undefined
where
- doAlloca :: Storable a => a -> Int -> (Ptr a -> IO b) -> IO b
+ doAlloca :: Storable a' => a' -> Int -> (Ptr a' -> IO b') -> IO b'
doAlloca dummy size = allocaBytes (size * sizeOf dummy)
doAlloca dummy size = allocaBytes (size * sizeOf dummy)
--- |Like 'allocaArray', but add an extra element to signal the end of the array
+-- |Like 'allocaArray', but add an extra position to hold a special
+-- termination element.
--
allocaArray0 :: Storable a => Int -> (Ptr a -> IO b) -> IO b
allocaArray0 size = allocaArray (size + 1)
--
allocaArray0 :: Storable a => Int -> (Ptr a -> IO b) -> IO b
allocaArray0 size = allocaArray (size + 1)
@@
-112,10
+114,10
@@
allocaArray0 size = allocaArray (size + 1)
reallocArray :: Storable a => Ptr a -> Int -> IO (Ptr a)
reallocArray = doRealloc undefined
where
reallocArray :: Storable a => Ptr a -> Int -> IO (Ptr a)
reallocArray = doRealloc undefined
where
- doRealloc :: Storable a => a -> Ptr a -> Int -> IO (Ptr a)
+ doRealloc :: Storable a' => a' -> Ptr a' -> Int -> IO (Ptr a')
doRealloc dummy ptr size = reallocBytes ptr (size * sizeOf dummy)
doRealloc dummy ptr size = reallocBytes ptr (size * sizeOf dummy)
--- |Adjust the size of an array while adding an element for the end marker
+-- |Adjust the size of an array including an extra position for the end marker.
--
reallocArray0 :: Storable a => Ptr a -> Int -> IO (Ptr a)
reallocArray0 ptr size = reallocArray ptr (size + 1)
--
reallocArray0 :: Storable a => Ptr a -> Int -> IO (Ptr a)
reallocArray0 ptr size = reallocArray ptr (size + 1)
@@
-174,6
+176,7
@@
pokeArray0 marker ptr vals = go vals 0#
-- |Write a list of storable elements into a newly allocated, consecutive
-- sequence of storable values
-- |Write a list of storable elements into a newly allocated, consecutive
-- sequence of storable values
+-- (like 'Foreign.Marshal.Utils.new', but for multiple elements).
--
newArray :: Storable a => [a] -> IO (Ptr a)
newArray vals = do
--
newArray :: Storable a => [a] -> IO (Ptr a)
newArray vals = do
@@
-191,6
+194,7
@@
newArray0 marker vals = do
return ptr
-- |Temporarily store a list of storable values in memory
return ptr
-- |Temporarily store a list of storable values in memory
+-- (like 'Foreign.Marshal.Utils.with', but for multiple elements).
--
withArray :: Storable a => [a] -> (Ptr a -> IO b) -> IO b
withArray vals = withArrayLen vals . const
--
withArray :: Storable a => [a] -> (Ptr a -> IO b) -> IO b
withArray vals = withArrayLen vals . const
@@
-233,7
+237,7
@@
withArrayLen0 marker vals f =
copyArray :: Storable a => Ptr a -> Ptr a -> Int -> IO ()
copyArray = doCopy undefined
where
copyArray :: Storable a => Ptr a -> Ptr a -> Int -> IO ()
copyArray = doCopy undefined
where
- doCopy :: Storable a => a -> Ptr a -> Ptr a -> Int -> IO ()
+ doCopy :: Storable a' => a' -> Ptr a' -> Ptr a' -> Int -> IO ()
doCopy dummy dest src size = copyBytes dest src (size * sizeOf dummy)
-- |Copy the given number of elements from the second array (source) into the
doCopy dummy dest src size = copyBytes dest src (size * sizeOf dummy)
-- |Copy the given number of elements from the second array (source) into the
@@
-242,7
+246,7
@@
copyArray = doCopy undefined
moveArray :: Storable a => Ptr a -> Ptr a -> Int -> IO ()
moveArray = doMove undefined
where
moveArray :: Storable a => Ptr a -> Ptr a -> Int -> IO ()
moveArray = doMove undefined
where
- doMove :: Storable a => a -> Ptr a -> Ptr a -> Int -> IO ()
+ doMove :: Storable a' => a' -> Ptr a' -> Ptr a' -> Int -> IO ()
doMove dummy dest src size = moveBytes dest src (size * sizeOf dummy)
doMove dummy dest src size = moveBytes dest src (size * sizeOf dummy)
@@
-267,5
+271,5
@@
lengthArray0 marker ptr = loop 0
advancePtr :: Storable a => Ptr a -> Int -> Ptr a
advancePtr = doAdvance undefined
where
advancePtr :: Storable a => Ptr a -> Int -> Ptr a
advancePtr = doAdvance undefined
where
- doAdvance :: Storable a => a -> Ptr a -> Int -> Ptr a
+ doAdvance :: Storable a' => a' -> Ptr a' -> Int -> Ptr a'
doAdvance dummy ptr i = ptr `plusPtr` (i * sizeOf dummy)
doAdvance dummy ptr i = ptr `plusPtr` (i * sizeOf dummy)