From 4d7dc9c83a6056fd6c22f6770b6702ae53157e0f Mon Sep 17 00:00:00 2001 From: Brian McKeon Date: Tue, 5 Mar 2024 11:40:58 -0500 Subject: [PATCH] Prepare 0.1.0.3 release. Reformatted. Use new .github workflows. Updated package metadata. --- .github/CODEOWNERS | 1 + .github/workflows/build.yaml | 11 ++++ .github/workflows/release.yaml | 10 ++++ .gitignore | 1 + CHANGELOG.md | 6 ++- Setup.hs | 2 - build | 15 ------ fourmolu.yaml | 51 +++++++++++++++++++ primitive-addr.cabal | 45 ++++++++++------- src/Data/Primitive/Addr.hs | 91 ++++++++++++++++++++-------------- 10 files changed, 159 insertions(+), 74 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/release.yaml delete mode 100644 Setup.hs delete mode 100755 build create mode 100644 fourmolu.yaml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..f6c0b22 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +@byteverse/l3c diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..5626da3 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,11 @@ +name: build +on: + pull_request: + branches: + - "*" + +jobs: + call-workflow: + uses: byteverse/.github/.github/workflows/build-matrix.yaml@main + with: + cabal-file: primitive-addr.cabal diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..9411962 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,10 @@ +name: release +on: + push: + tags: + - "*" + +jobs: + call-workflow: + uses: byteverse/.github/.github/workflows/release.yaml@main + secrets: inherit diff --git a/.gitignore b/.gitignore index 28d589b..cde1485 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.vscode/ dist dist-* cabal-dev diff --git a/CHANGELOG.md b/CHANGELOG.md index ab5cd21..5396f2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/Setup.hs b/Setup.hs deleted file mode 100644 index 9a994af..0000000 --- a/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/build b/build deleted file mode 100755 index bc60e12..0000000 --- a/build +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -set -e - -# To use this script on Ubuntu, you will need to first run the following: -# -# sudo apt install ghc-7.4.2 ghc-7.6.3 ghc-7.8.4 ghc-7.10.3 ghc-8.0.2 ghc-8.2.2 ghc-8.4.3 ghc-8.6.1 - -declare -a ghcs=("7.4.2" "7.6.3" "7.8.4" "7.10.3" "8.0.2" "8.2.2" "8.4.4" "8.6.5") - -## now loop through the above array -for g in "${ghcs[@]}" -do - cabal new-build --builddir "dist-$g" -w "/opt/ghc/bin/ghc-$g" -done - diff --git a/fourmolu.yaml b/fourmolu.yaml new file mode 100644 index 0000000..40cd005 --- /dev/null +++ b/fourmolu.yaml @@ -0,0 +1,51 @@ +# Number of spaces per indentation step +indentation: 2 + +# Max line length for automatic line breaking +column-limit: 200 + +# Styling of arrows in type signatures (choices: trailing, leading, or leading-args) +function-arrows: trailing + +# How to place commas in multi-line lists, records, etc. (choices: leading or trailing) +comma-style: leading + +# Styling of import/export lists (choices: leading, trailing, or diff-friendly) +import-export-style: leading + +# Whether to full-indent or half-indent 'where' bindings past the preceding body +indent-wheres: false + +# Whether to leave a space before an opening record brace +record-brace-space: true + +# Number of spaces between top-level declarations +newlines-between-decls: 1 + +# How to print Haddock comments (choices: single-line, multi-line, or multi-line-compact) +haddock-style: multi-line + +# How to print module docstring +haddock-style-module: null + +# Styling of let blocks (choices: auto, inline, newline, or mixed) +let-style: auto + +# How to align the 'in' keyword with respect to the 'let' keyword (choices: left-align, right-align, or no-space) +in-style: right-align + +# Whether to put parentheses around a single constraint (choices: auto, always, or never) +single-constraint-parens: always + +# Output Unicode syntax (choices: detect, always, or never) +unicode: never + +# Give the programmer more choice on where to insert blank lines +respectful: true + +# Fixity information for operators +fixities: [] + +# Module reexports Fourmolu should know about +reexports: [] + diff --git a/primitive-addr.cabal b/primitive-addr.cabal index 64a0a81..3e569a7 100644 --- a/primitive-addr.cabal +++ b/primitive-addr.cabal @@ -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.10 - 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 diff --git a/src/Data/Primitive/Addr.hs b/src/Data/Primitive/Addr.hs index 94af576..c88783e 100644 --- a/src/Data/Primitive/Addr.hs +++ b/src/Data/Primitive/Addr.hs @@ -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 @@ module Data.Primitive.Addr -- * 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 @@ infixl 7 `remAddr` 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 @@ minusAddr (Addr a#) (Addr b#) = I# (minusAddr# a# b#) 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 @@ copyAddrToByteArray (MutableByteArray marr) (I# off) (Addr addr) (I# len) = 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 @@ setAddr (Addr addr#) (I# n#) x = primitive_ (setOffAddr# addr# 0# n# x) addrToInt :: Addr -> Int {-# INLINE addrToInt #-} addrToInt (Addr addr#) = I# (addr2Int# addr#) -