Skip to content

Commit

Permalink
Correct signatures for FinalizerPtrs
Browse files Browse the repository at this point in the history
  • Loading branch information
amesgen committed May 2, 2023
1 parent 7317b8a commit 6a9ce44
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Codec/Compression/Zlib/Stream.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ c_deflateInit2 z a b c d e =
foreign import ccall SAFTY "zlib.h inflate"
c_inflate :: StreamState -> CInt -> IO CInt

foreign import ccall unsafe "zlib.h &inflateEnd"
foreign import ccall unsafe "hs-zlib.h &hsInflateEnd"
c_inflateEnd :: FinalizerPtr StreamState

foreign import ccall unsafe "zlib.h inflateReset"
Expand All @@ -1091,7 +1091,7 @@ foreign import ccall unsafe "zlib.h inflateSetDictionary"
foreign import ccall SAFTY "zlib.h deflate"
c_deflate :: StreamState -> CInt -> IO CInt

foreign import ccall unsafe "zlib.h &deflateEnd"
foreign import ccall unsafe "hs-zlib.h &hsDeflateEnd"
c_deflateEnd :: FinalizerPtr StreamState

foreign import ccall unsafe "zlib.h zlibVersion"
Expand Down
22 changes: 22 additions & 0 deletions cabal.project.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
if os(wasi)
-- https://github.com/haskellari/splitmix/pull/73
source-repository-package
type: git
location: https://github.com/amesgen/splitmix
tag: ebd790e992a83fe1b16b6182677106295d9afba2

-- https://github.com/UnkindPartition/tasty/pull/365
source-repository-package
type: git
location: https://github.com/UnkindPartition/tasty
subdir: core
tag: 88a0258702e0784fc26e1c1db6c0bcb3bd49904a

package zlib
flags: +bundled-c-zlib

package splitmix
tests: False
benchmarks: False

allow-newer: zlib:tasty
9 changes: 9 additions & 0 deletions cbits-extra/hs-zlib.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "extras.h"

void hsInflateEnd(z_streamp strm) {
inflateEnd(strm);
}

void hsDeflateEnd(z_streamp strm) {
deflateEnd(strm);
}
8 changes: 8 additions & 0 deletions cbits-extra/hs-zlib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef HS_ZLIB_EXTRAS
#define HS_ZLIB_EXTRAS

#include "zlib.h"

void hsInflateEnd(z_streamp strm);
void hsDeflateEnd(z_streamp strm);
#endif
5 changes: 4 additions & 1 deletion zlib.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ library
if impl(ghc >= 7.0 && < 8.0.3)
build-depends: ghc-prim

includes: zlib.h
includes: zlib.h hs-zlib.h
install-includes: hs-zlib.h
include-dirs: cbits-extra
c-sources: cbits-extra/hs-zlib.c
ghc-options: -Wall -fwarn-tabs
if flag(non-blocking-ffi)
cpp-options: -DNON_BLOCKING_FFI
Expand Down

0 comments on commit 6a9ce44

Please sign in to comment.