[commit: ghc] master: base: Add Foreign.ForeignPtr.plusForeignPtr. (226c535)
git at git.haskell.org
git at git.haskell.org
Tue Jan 10 19:22:06 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/226c5352bb63ab53b11a23484c8ec8f20a57d538/ghc
>---------------------------------------------------------------
commit 226c5352bb63ab53b11a23484c8ec8f20a57d538
Author: Shea Levy <shea at shealevy.com>
Date: Tue Jan 10 13:33:58 2017 -0500
base: Add Foreign.ForeignPtr.plusForeignPtr.
Reviewers: simonmar, austin, hvr, bgamari
Reviewed By: bgamari
Subscribers: RyanGlScott, thomie
Differential Revision: https://phabricator.haskell.org/D2900
>---------------------------------------------------------------
226c5352bb63ab53b11a23484c8ec8f20a57d538
libraries/base/Foreign/ForeignPtr.hs | 1 +
libraries/base/Foreign/ForeignPtr/Imp.hs | 1 +
libraries/base/GHC/ForeignPtr.hs | 7 +++++++
libraries/base/changelog.md | 2 ++
4 files changed, 11 insertions(+)
diff --git a/libraries/base/Foreign/ForeignPtr.hs b/libraries/base/Foreign/ForeignPtr.hs
index cedfba7..a684a8d 100644
--- a/libraries/base/Foreign/ForeignPtr.hs
+++ b/libraries/base/Foreign/ForeignPtr.hs
@@ -35,6 +35,7 @@ module Foreign.ForeignPtr (
-- ** Low-level operations
, touchForeignPtr
, castForeignPtr
+ , plusForeignPtr
-- ** Allocating managed memory
, mallocForeignPtr
diff --git a/libraries/base/Foreign/ForeignPtr/Imp.hs b/libraries/base/Foreign/ForeignPtr/Imp.hs
index 2c3f393..4824c30 100644
--- a/libraries/base/Foreign/ForeignPtr/Imp.hs
+++ b/libraries/base/Foreign/ForeignPtr/Imp.hs
@@ -38,6 +38,7 @@ module Foreign.ForeignPtr.Imp
, unsafeForeignPtrToPtr
, touchForeignPtr
, castForeignPtr
+ , plusForeignPtr
-- ** Allocating managed memory
, mallocForeignPtr
diff --git a/libraries/base/GHC/ForeignPtr.hs b/libraries/base/GHC/ForeignPtr.hs
index b9b29ea..6088084 100644
--- a/libraries/base/GHC/ForeignPtr.hs
+++ b/libraries/base/GHC/ForeignPtr.hs
@@ -39,6 +39,7 @@ module GHC.ForeignPtr
touchForeignPtr,
unsafeForeignPtrToPtr,
castForeignPtr,
+ plusForeignPtr,
newConcForeignPtr,
addForeignPtrConcFinalizer,
finalizeForeignPtr
@@ -434,6 +435,12 @@ castForeignPtr :: ForeignPtr a -> ForeignPtr b
-- parameterised by one type into another type.
castForeignPtr = coerce
+plusForeignPtr :: ForeignPtr a -> Int -> ForeignPtr b
+-- ^Advances the given address by the given offset in bytes.
+--
+-- @since 4.10.0.0
+plusForeignPtr (ForeignPtr addr c) (I# d) = ForeignPtr (plusAddr# addr d) c
+
-- | Causes the finalizers associated with a foreign pointer to be run
-- immediately.
finalizeForeignPtr :: ForeignPtr a -> IO ()
diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md
index e0cd384..b73e01e 100644
--- a/libraries/base/changelog.md
+++ b/libraries/base/changelog.md
@@ -35,6 +35,8 @@
* Raw buffer operations in `GHC.IO.FD` are now strict in the buffer, offset, and length operations (#9696)
+ * Add `plusForeignPtr` to `Foreign.ForeignPtr`.
+
## 4.9.0.0 *May 2016*
* Bundled with GHC 8.0
More information about the ghc-commits
mailing list