[commit: packages/primitive] ghc-head: Move internal operations to a separate module (e2ec9ae)

git at git.haskell.org git at git.haskell.org
Thu Sep 26 11:44:50 CEST 2013


Repository : ssh://git@git.haskell.org/primitive

On branch  : ghc-head
Link       : http://git.haskell.org/packages/primitive.git/commitdiff/e2ec9aec8d36b8c8dde701697841059e21c1de09

>---------------------------------------------------------------

commit e2ec9aec8d36b8c8dde701697841059e21c1de09
Author: Roman Leshchinskiy <rl at cse.unsw.edu.au>
Date:   Thu Jan 26 15:47:15 2012 -0700

    Move internal operations to a separate module


>---------------------------------------------------------------

e2ec9aec8d36b8c8dde701697841059e21c1de09
 Data/Primitive/Internal/Operations.hs |   53 +++++++++++++++++++++++++++++++++
 Data/Primitive/Types.hs               |   34 ++-------------------
 primitive.cabal                       |    1 +
 3 files changed, 56 insertions(+), 32 deletions(-)

diff --git a/Data/Primitive/Internal/Operations.hs b/Data/Primitive/Internal/Operations.hs
new file mode 100644
index 0000000..9516090
--- /dev/null
+++ b/Data/Primitive/Internal/Operations.hs
@@ -0,0 +1,53 @@
+{-# LANGUAGE MagicHash, ForeignFunctionInterface, UnliftedFFITypes #-}
+
+-- |
+-- Module      : Data.Primitive.Internal.Operations
+-- Copyright   : (c) Roman Leshchinskiy 2011
+-- License     : BSD-style
+--
+-- Maintainer  : Roman Leshchinskiy <rl at cse.unsw.edu.au>
+-- Portability : non-portable
+-- 
+-- Internal operations
+--
+
+
+module Data.Primitive.Internal.Operations (
+  setWord8Array#, setWord16Array#, setWord32Array#,
+  setWord64Array#, setWordArray#,
+  setInt8Array#, setInt16Array#, setInt32Array#,
+  setInt64Array#, setIntArray#,
+  setAddrArray#, setFloatArray#, setDoubleArray#, setWideCharArray#
+) where
+
+import GHC.Prim
+
+foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word8"
+  setWord8Array# :: MutableByteArray# s -> Int# -> Int# -> Word# -> IO ()
+foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word16"
+  setWord16Array# :: MutableByteArray# s -> Int# -> Int# -> Word# -> IO ()
+foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word32"
+  setWord32Array# :: MutableByteArray# s -> Int# -> Int# -> Word# -> IO ()
+foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word64"
+  setWord64Array# :: MutableByteArray# s -> Int# -> Int# -> Word64# -> IO ()
+foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word"
+  setWordArray# :: MutableByteArray# s -> Int# -> Int# -> Word# -> IO ()
+foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word8"
+  setInt8Array# :: MutableByteArray# s -> Int# -> Int# -> Int# -> IO ()
+foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word16"
+  setInt16Array# :: MutableByteArray# s -> Int# -> Int# -> Int# -> IO ()
+foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word32"
+  setInt32Array# :: MutableByteArray# s -> Int# -> Int# -> Int# -> IO ()
+foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word64"
+  setInt64Array# :: MutableByteArray# s -> Int# -> Int# -> Int64# -> IO ()
+foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word"
+  setIntArray# :: MutableByteArray# s -> Int# -> Int# -> Int# -> IO ()
+foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Ptr"
+  setAddrArray# :: MutableByteArray# s -> Int# -> Int# -> Addr# -> IO ()
+foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Float"
+  setFloatArray# :: MutableByteArray# s -> Int# -> Int# -> Float# -> IO ()
+foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Double"
+  setDoubleArray# :: MutableByteArray# s -> Int# -> Int# -> Double# -> IO ()
+foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Char"
+  setWideCharArray# :: MutableByteArray# s -> Int# -> Int# -> Char# -> IO ()
+
diff --git a/Data/Primitive/Types.hs b/Data/Primitive/Types.hs
index 07b267b..4c84d93 100644
--- a/Data/Primitive/Types.hs
+++ b/Data/Primitive/Types.hs
@@ -1,5 +1,4 @@
-{-# LANGUAGE UnboxedTuples, MagicHash, DeriveDataTypeable,
-             ForeignFunctionInterface, UnliftedFFITypes #-}
+{-# LANGUAGE UnboxedTuples, MagicHash, DeriveDataTypeable #-}
 
 -- |
 -- Module      : Data.Primitive.Types
@@ -20,6 +19,7 @@ module Data.Primitive.Types (
 
 import Control.Monad.Primitive
 import Data.Primitive.MachDeps
+import Data.Primitive.Internal.Operations
 
 import GHC.Base (
     unsafeCoerce#,
@@ -171,33 +171,3 @@ derivePrim(Addr, Addr, sIZEOF_PTR, aLIGNMENT_PTR,
            indexAddrArray#, readAddrArray#, writeAddrArray#, setAddrArray#,
            indexAddrOffAddr#, readAddrOffAddr#, writeAddrOffAddr#)
 
-foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word8"
-  setWord8Array# :: MutableByteArray# s -> Int# -> Int# -> Word# -> IO ()
-foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word16"
-  setWord16Array# :: MutableByteArray# s -> Int# -> Int# -> Word# -> IO ()
-foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word32"
-  setWord32Array# :: MutableByteArray# s -> Int# -> Int# -> Word# -> IO ()
-foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word64"
-  setWord64Array# :: MutableByteArray# s -> Int# -> Int# -> Word64# -> IO ()
-foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word"
-  setWordArray# :: MutableByteArray# s -> Int# -> Int# -> Word# -> IO ()
-foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word8"
-  setInt8Array# :: MutableByteArray# s -> Int# -> Int# -> Int# -> IO ()
-foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word16"
-  setInt16Array# :: MutableByteArray# s -> Int# -> Int# -> Int# -> IO ()
-foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word32"
-  setInt32Array# :: MutableByteArray# s -> Int# -> Int# -> Int# -> IO ()
-foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word64"
-  setInt64Array# :: MutableByteArray# s -> Int# -> Int# -> Int64# -> IO ()
-foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Word"
-  setIntArray# :: MutableByteArray# s -> Int# -> Int# -> Int# -> IO ()
-foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Ptr"
-  setAddrArray# :: MutableByteArray# s -> Int# -> Int# -> Addr# -> IO ()
-foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Float"
-  setFloatArray# :: MutableByteArray# s -> Int# -> Int# -> Float# -> IO ()
-foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Double"
-  setDoubleArray# :: MutableByteArray# s -> Int# -> Int# -> Double# -> IO ()
-foreign import ccall unsafe "primitive-memops.h hsprimitive_memset_Char"
-  setWideCharArray# :: MutableByteArray# s -> Int# -> Int# -> Char# -> IO ()
-
-
diff --git a/primitive.cabal b/primitive.cabal
index bbf55de..86ac338 100644
--- a/primitive.cabal
+++ b/primitive.cabal
@@ -55,6 +55,7 @@ Library
 
   Other-Modules:
         Data.Primitive.Internal.Compat
+        Data.Primitive.Internal.Operations
 
   Build-Depends: base >= 4 && < 5, ghc-prim
 




More information about the ghc-commits mailing list