packages feed

primitive-addr 0.1.0.2 → 0.1.0.3

raw patch · 4 files changed

+85/−59 lines, 4 filesdep ~basesetup-changednew-uploader

Dependency ranges changed: base

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for primitive-addr +## 0.1.0.3 -- 2024-03-05++* Update package metadata.+ ## 0.1.0.2 -- 2019-07-18  * Allow building with `primitive-0.6.4.0`.@@ -10,4 +14,4 @@  ## 0.1.0.0 -- 2019-05-17 -* First version. Released on an unsuspecting world.+* First version.
− Setup.hs
@@ -1,2 +0,0 @@-import Distribution.Simple-main = defaultMain
primitive-addr.cabal view
@@ -1,24 +1,33 @@-cabal-version: 2.2-name: primitive-addr-version: 0.1.0.2-synopsis: Addresses to unmanaged memory+cabal-version:   3.0+name:            primitive-addr+version:         0.1.0.3+synopsis:        Addresses to unmanaged memory description:   This library provides the `Data.Primitive.Addr` module   that was a part of the `primitive` library before `primitive-0.7.0.0`.-homepage: https://github.com/andrewthad/primitive-addr-bug-reports: https://github.com/andrewthad/primitive-addr/issues-license: BSD-3-Clause-license-file: LICENSE-author: Andrew Martin-maintainer: andrew.thaddeus@gmail.com-copyright: 2019 Andrew Martin-category: Data-extra-source-files: CHANGELOG.md +homepage:        https://github.com/byteverse/primitive-addr+bug-reports:     https://github.com/byteverse/primitive-addr/issues+license:         BSD-3-Clause+license-file:    LICENSE+author:          Andrew Martin+maintainer:      amartin@layer3com.com+copyright:       2019 Andrew Martin+category:        Data+extra-doc-files: CHANGELOG.md+tested-with:     GHC ==9.4.8 || ==9.6.3 || ==9.8.1++common build-settings+  default-language: Haskell2010+  ghc-options:      -Wall -Wunused-packages+  build-depends:    base >=4.17.2.1 && <5+ library+  import:          build-settings+  hs-source-dirs:  src   exposed-modules: Data.Primitive.Addr-  build-depends:-    , base >=4.5.1.0 && <5-    , primitive >=0.6.4 && <0.8-  hs-source-dirs: src-  default-language: Haskell2010+  build-depends:   primitive >=0.6.4 && <0.10++source-repository head+  type:     git+  location: git://github.com/byteverse/primitive-addr.git
src/Data/Primitive/Addr.hs view
@@ -1,7 +1,8 @@-{-# language CPP #-}-{-# language MagicHash #-}-{-# language UnboxedTuples #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE MagicHash #-}+{-# LANGUAGE UnboxedTuples #-} +{- FOURMOLU_DISABLE -} -- | Primitive operations on machine addresses. module Data.Primitive.Addr   ( -- * Types@@ -25,15 +26,15 @@   -- * Conversion   , addrToInt ) where+{- FOURMOLU_ENABLE -} -import Numeric (showHex) import Control.Monad.Primitive-import Data.Primitive.Types (Prim(..)) import Data.Primitive.ByteArray+import Data.Primitive.Types (Prim (..))+import Numeric (showHex) -import GHC.Exts-import GHC.Ptr import Foreign.Marshal.Utils+import GHC.Exts  #if __GLASGOW_HASKELL__ < 708 toBool# :: Bool -> Bool@@ -71,8 +72,9 @@ plusAddr :: Addr -> Int -> Addr plusAddr (Addr a#) (I# i#) = Addr (plusAddr# a# i#) --- | Distance in bytes between two addresses. The result is only valid if the--- difference fits in an 'Int'.+{- | Distance in bytes between two addresses. The result is only valid if the+difference fits in an 'Int'.+-} minusAddr :: Addr -> Addr -> Int minusAddr (Addr a#) (Addr b#) = I# (minusAddr# a# b#) @@ -80,35 +82,43 @@ remAddr :: Addr -> Int -> Int remAddr (Addr a#) (I# i#) = I# (remAddr# a# i#) --- | Read a value from a memory position given by an address and an offset.--- The memory block the address refers to must be immutable. The offset is in--- elements of type @a@ rather than in bytes.-indexOffAddr :: Prim a => Addr -> Int -> a+{- | Read a value from a memory position given by an address and an offset.+The memory block the address refers to must be immutable. The offset is in+elements of type @a@ rather than in bytes.+-}+indexOffAddr :: (Prim a) => Addr -> Int -> a {-# INLINE indexOffAddr #-} indexOffAddr (Addr addr#) (I# i#) = indexOffAddr# addr# i# --- | Read a value from a memory position given by an address and an offset.--- The offset is in elements of type @a@ rather than in bytes.+{- | Read a value from a memory position given by an address and an offset.+The offset is in elements of type @a@ rather than in bytes.+-} readOffAddr :: (Prim a, PrimMonad m) => Addr -> Int -> m a {-# INLINE readOffAddr #-} readOffAddr (Addr addr#) (I# i#) = primitive (readOffAddr# addr# i#) --- | Write a value to a memory position given by an address and an offset.--- The offset is in elements of type @a@ rather than in bytes.+{- | Write a value to a memory position given by an address and an offset.+The offset is in elements of type @a@ rather than in bytes.+-} writeOffAddr :: (Prim a, PrimMonad m) => Addr -> Int -> a -> m () {-# INLINE writeOffAddr #-} writeOffAddr (Addr addr#) (I# i#) x = primitive_ (writeOffAddr# addr# i# x) --- | Copy the given number of bytes from the second 'Addr' to the first. The--- areas may not overlap.-copyAddr :: PrimMonad m-  => Addr -- ^ destination address-  -> Addr -- ^ source address-  -> Int -- ^ number of bytes-  -> m ()+{- | Copy the given number of bytes from the second 'Addr' to the first. The+areas may not overlap.+-}+copyAddr ::+  (PrimMonad m) =>+  -- | destination address+  Addr ->+  -- | source address+  Addr ->+  -- | number of bytes+  Int ->+  m () {-# INLINE copyAddr #-}-copyAddr (Addr dst#) (Addr src#) n-  = unsafePrimToPrim $ copyBytes (Ptr dst#) (Ptr src#) n+copyAddr (Addr dst#) (Addr src#) n =+  unsafePrimToPrim $ copyBytes (Ptr dst#) (Ptr src#) n  #if __GLASGOW_HASKELL__ >= 708 -- | Copy the given number of bytes from the 'Addr' to the 'MutableByteArray'.@@ -125,19 +135,25 @@   primitive_ $ copyAddrToByteArray# addr marr off len #endif --- | Copy the given number of bytes from the second 'Addr' to the first. The--- areas may overlap.-moveAddr :: PrimMonad m-  => Addr -- ^ destination address-  -> Addr -- ^ source address-  -> Int -- ^ number of bytes-  -> m ()+{- | Copy the given number of bytes from the second 'Addr' to the first. The+areas may overlap.+-}+moveAddr ::+  (PrimMonad m) =>+  -- | destination address+  Addr ->+  -- | source address+  Addr ->+  -- | number of bytes+  Int ->+  m () {-# INLINE moveAddr #-}-moveAddr (Addr dst#) (Addr src#) n-  = unsafePrimToPrim $ moveBytes (Ptr dst#) (Ptr src#) n+moveAddr (Addr dst#) (Addr src#) n =+  unsafePrimToPrim $ moveBytes (Ptr dst#) (Ptr src#) n --- | Fill a memory block of with the given value. The length is in--- elements of type @a@ rather than in bytes.+{- | Fill a memory block of with the given value. The length is in+elements of type @a@ rather than in bytes.+-} setAddr :: (Prim a, PrimMonad m) => Addr -> Int -> a -> m () {-# INLINE setAddr #-} setAddr (Addr addr#) (I# n#) x = primitive_ (setOffAddr# addr# 0# n# x)@@ -146,4 +162,3 @@ addrToInt :: Addr -> Int {-# INLINE addrToInt #-} addrToInt (Addr addr#) = I# (addr2Int# addr#)-