File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -1010,6 +1010,12 @@ newtype StreamState = StreamState (Ptr StreamState)
1010
1010
-- So we define c_inflateInit2 and c_deflateInit2 here as wrappers around
1011
1011
-- their _ counterparts and pass the extra args.
1012
1012
1013
+ ##ifdef NON_BLOCKING_FFI
1014
+ ##define SAFTY safe
1015
+ ##else
1016
+ ##define SAFTY unsafe
1017
+ ##endif
1018
+
1013
1019
foreign import ccall unsafe " zlib.h inflateInit2_"
1014
1020
c_inflateInit2_ :: StreamState -> CInt -> Ptr CChar -> CInt -> IO CInt
1015
1021
@@ -1018,7 +1024,7 @@ c_inflateInit2 z n =
1018
1024
withCAString # {const_str ZLIB_VERSION } $ \ versionStr ->
1019
1025
c_inflateInit2_ z n versionStr (# {const sizeof(z_stream)} :: CInt )
1020
1026
1021
- foreign import ccall unsafe " zlib.h inflate"
1027
+ foreign import ccall SAFTY " zlib.h inflate"
1022
1028
c_inflate :: StreamState -> CInt -> IO CInt
1023
1029
1024
1030
foreign import ccall unsafe " zlib.h &inflateEnd"
@@ -1051,7 +1057,7 @@ foreign import ccall unsafe "zlib.h inflateSetDictionary"
1051
1057
-> CUInt
1052
1058
-> IO CInt
1053
1059
1054
- foreign import ccall unsafe " zlib.h deflate"
1060
+ foreign import ccall SAFTY " zlib.h deflate"
1055
1061
c_deflate :: StreamState -> CInt -> IO CInt
1056
1062
1057
1063
foreign import ccall unsafe " zlib.h &deflateEnd"
Original file line number Diff line number Diff line change @@ -36,6 +36,12 @@ source-repository head
36
36
type : darcs
37
37
location : http://code.haskell.org/zlib/
38
38
39
+ flag non-blocking-ffi
40
+ default : False
41
+ description : The (de)compression calls can sometimes take a long time, which
42
+ prevents other Haskell threads running. Enabling this flag
43
+ avoids this unfairness, but with greater overall cost.
44
+
39
45
library
40
46
exposed-modules : Codec.Compression.GZip,
41
47
Codec.Compression.Zlib,
@@ -57,6 +63,8 @@ library
57
63
build-depends : ghc-prim
58
64
includes : zlib.h
59
65
ghc-options : -Wall -fwarn-tabs
66
+ if flag(non-blocking-ffi)
67
+ cpp-options : -DNON_BLOCKING_FFI
60
68
if !os(windows)
61
69
-- Normally we use the the standard system zlib:
62
70
extra-libraries : z
You can’t perform that action at this time.
0 commit comments