Commit 226c5352 authored by shlevy's avatar shlevy Committed by Ben Gamari
Browse files

base: Add Foreign.ForeignPtr.plusForeignPtr.

Reviewers: simonmar, austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: RyanGlScott, thomie

Differential Revision: https://phabricator.haskell.org/D2900
parent 12ad4d41
...@@ -35,6 +35,7 @@ module Foreign.ForeignPtr ( ...@@ -35,6 +35,7 @@ module Foreign.ForeignPtr (
-- ** Low-level operations -- ** Low-level operations
, touchForeignPtr , touchForeignPtr
, castForeignPtr , castForeignPtr
, plusForeignPtr
-- ** Allocating managed memory -- ** Allocating managed memory
, mallocForeignPtr , mallocForeignPtr
......
...@@ -38,6 +38,7 @@ module Foreign.ForeignPtr.Imp ...@@ -38,6 +38,7 @@ module Foreign.ForeignPtr.Imp
, unsafeForeignPtrToPtr , unsafeForeignPtrToPtr
, touchForeignPtr , touchForeignPtr
, castForeignPtr , castForeignPtr
, plusForeignPtr
-- ** Allocating managed memory -- ** Allocating managed memory
, mallocForeignPtr , mallocForeignPtr
......
...@@ -39,6 +39,7 @@ module GHC.ForeignPtr ...@@ -39,6 +39,7 @@ module GHC.ForeignPtr
touchForeignPtr, touchForeignPtr,
unsafeForeignPtrToPtr, unsafeForeignPtrToPtr,
castForeignPtr, castForeignPtr,
plusForeignPtr,
newConcForeignPtr, newConcForeignPtr,
addForeignPtrConcFinalizer, addForeignPtrConcFinalizer,
finalizeForeignPtr finalizeForeignPtr
...@@ -434,6 +435,12 @@ castForeignPtr :: ForeignPtr a -> ForeignPtr b ...@@ -434,6 +435,12 @@ castForeignPtr :: ForeignPtr a -> ForeignPtr b
-- parameterised by one type into another type. -- parameterised by one type into another type.
castForeignPtr = coerce 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 -- | Causes the finalizers associated with a foreign pointer to be run
-- immediately. -- immediately.
finalizeForeignPtr :: ForeignPtr a -> IO () finalizeForeignPtr :: ForeignPtr a -> IO ()
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
* Raw buffer operations in `GHC.IO.FD` are now strict in the buffer, offset, and length operations (#9696) * 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* ## 4.9.0.0 *May 2016*
* Bundled with GHC 8.0 * Bundled with GHC 8.0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment