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 @@ -1009,6 +1009,12 @@ newtype StreamState = StreamState (Ptr StreamState)
1009
1009
-- So we define c_inflateInit2 and c_deflateInit2 here as wrappers around
1010
1010
-- their _ counterparts and pass the extra args.
1011
1011
1012
+ ##ifdef NON_BLOCKING_FFI
1013
+ ##define SAFTY safe
1014
+ ##else
1015
+ ##define SAFTY unsafe
1016
+ ##endif
1017
+
1012
1018
foreign import ccall unsafe " zlib.h inflateInit2_"
1013
1019
c_inflateInit2_ :: StreamState -> CInt -> Ptr CChar -> CInt -> IO CInt
1014
1020
@@ -1017,7 +1023,7 @@ c_inflateInit2 z n =
1017
1023
withCAString # {const_str ZLIB_VERSION } $ \ versionStr ->
1018
1024
c_inflateInit2_ z n versionStr (# {const sizeof(z_stream)} :: CInt )
1019
1025
1020
- foreign import ccall unsafe " zlib.h inflate"
1026
+ foreign import ccall SAFTY " zlib.h inflate"
1021
1027
c_inflate :: StreamState -> CInt -> IO CInt
1022
1028
1023
1029
foreign import ccall unsafe " zlib.h &inflateEnd"
@@ -1050,7 +1056,7 @@ foreign import ccall unsafe "zlib.h inflateSetDictionary"
1050
1056
-> CUInt
1051
1057
-> IO CInt
1052
1058
1053
- foreign import ccall unsafe " zlib.h deflate"
1059
+ foreign import ccall SAFTY " zlib.h deflate"
1054
1060
c_deflate :: StreamState -> CInt -> IO CInt
1055
1061
1056
1062
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