Skip to content

Commit 826488b

Browse files
committed
Remove blockio:fcntl-nocache in favour of the unix package
File caching setter/getter functions are available since `unix-2.8.7.0`, so we use those in favour of `blockio:fctnl-nocache`.
1 parent 58b033d commit 826488b

File tree

7 files changed

+8
-129
lines changed

7 files changed

+8
-129
lines changed

blockio/blockio.cabal

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,15 @@ library
8282
if os(linux)
8383
hs-source-dirs: src-linux
8484
other-modules: System.FS.BlockIO.Internal
85-
build-depends:
86-
, blockio:fcntl-nocache
87-
, unix ^>=2.8
85+
build-depends: unix ^>=2.8.7
8886

8987
if !flag(serialblockio)
9088
other-modules: System.FS.BlockIO.Async
9189
build-depends: blockio-uring ^>=0.1
9290

9391
elif os(osx)
9492
hs-source-dirs: src-macos
95-
build-depends:
96-
, blockio:fcntl-nocache
97-
, unix ^>=2.8
98-
93+
build-depends: unix ^>=2.8.7
9994
other-modules: System.FS.BlockIO.Internal
10095

10196
elif os(windows)
@@ -106,24 +101,11 @@ library
106101
if flag(serialblockio)
107102
cpp-options: -DSERIALBLOCKIO
108103

109-
library fcntl-nocache
110-
import: language, warnings
111-
visibility: private
112-
hs-source-dirs: src-fcntl-nocache
113-
114-
if os(windows)
115-
buildable: False
116-
117-
exposed-modules: System.Posix.Fcntl.NoCache
118-
build-depends: base <5
119-
build-tool-depends: hsc2hs:hsc2hs
120-
121104
test-suite test
122105
import: language, warnings
123106
type: exitcode-stdio-1.0
124107
hs-source-dirs: test
125108
main-is: Main.hs
126-
other-modules: Test.System.Posix.Fcntl.NoCache
127109
build-depends:
128110
, async
129111
, base <5
@@ -138,9 +120,6 @@ test-suite test
138120
, temporary
139121
, vector
140122

141-
if !os(windows)
142-
build-depends: blockio:fcntl-nocache
143-
144123
ghc-options: -threaded
145124

146125
library sim

blockio/src-fcntl-nocache/System/Posix/Fcntl/NoCache.hsc

Lines changed: 0 additions & 47 deletions
This file was deleted.

blockio/src-linux/System/FS/BlockIO/Internal.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import System.FS.BlockIO.API (Advice (..), FileOffset, HasBlockIO,
1212
import System.FS.IO (HandleIO)
1313
import qualified System.FS.IO.Handle as FS
1414
import qualified System.Posix.Fcntl as Fcntl
15-
import qualified System.Posix.Fcntl.NoCache as Unix
1615
import qualified System.Posix.Files as Unix
1716
import qualified System.Posix.Unistd as Unix
1817

@@ -53,7 +52,7 @@ ioHasBlockIO hfs params =
5352

5453
hSetNoCache :: Handle HandleIO -> Bool -> IO ()
5554
hSetNoCache h b =
56-
FS.withOpenHandle "hSetNoCache" (handleRaw h) (flip Unix.writeFcntlNoCache b)
55+
FS.withOpenHandle "hSetNoCache" (handleRaw h) (flip Fcntl.fileSetCaching (not b))
5756

5857
hAdvise :: Handle HandleIO -> FileOffset -> FileOffset -> Advice -> IO ()
5958
hAdvise h off len advice = FS.withOpenHandle "hAdvise" (handleRaw h) $ \fd ->

blockio/src-macos/System/FS/BlockIO/Internal.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import System.FS.BlockIO.API (Advice (..), FileOffset, HasBlockIO,
1010
import qualified System.FS.BlockIO.Serial as Serial
1111
import System.FS.IO (HandleIO)
1212
import qualified System.FS.IO.Handle as FS
13-
import qualified System.Posix.Fcntl.NoCache as Unix
13+
import qualified System.Posix.Fcntl as Unix
1414
import qualified System.Posix.Files as Unix
1515
import qualified System.Posix.Unistd as Unix
1616

@@ -36,7 +36,7 @@ ioHasBlockIO hfs _params =
3636

3737
hSetNoCache :: Handle HandleIO -> Bool -> IO ()
3838
hSetNoCache h b =
39-
FS.withOpenHandle "hSetNoCache" (handleRaw h) (flip Unix.writeFcntlNoCache b)
39+
FS.withOpenHandle "hSetNoCache" (handleRaw h) (flip Unix.fileSetCaching (not b))
4040

4141
-- TODO: it is unclear if MacOS supports @posix_fadvise(2)@, and it's hard to
4242
-- check because there are no manual pages online. For now, it's just hardcoded

blockio/test/Main.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,12 @@ import Test.Tasty
3333
import Test.Tasty.HUnit
3434
import Test.Tasty.QuickCheck (testProperty)
3535

36-
import qualified Test.System.Posix.Fcntl.NoCache
37-
3836
main :: IO ()
3937
main = defaultMain tests
4038

4139
tests :: TestTree
4240
tests = testGroup "blockio:test" [
43-
Test.System.Posix.Fcntl.NoCache.tests
44-
, testCase "example_initClose" example_initClose
41+
testCase "example_initClose" example_initClose
4542
, testCase "example_closeIsIdempotent" example_closeIsIdempotent
4643
, testProperty "prop_readWrite" prop_readWrite
4744
, testProperty "prop_submitToClosedCtx" prop_submitToClosedCtx

blockio/test/Test/System/Posix/Fcntl/NoCache.hs

Lines changed: 0 additions & 49 deletions
This file was deleted.

cabal.project.release

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
index-state:
22
-- Bump this if you need newer packages from Hackage
3-
-- quickcheck-lockstep-0.7.0
4-
, hackage.haskell.org 2025-05-09T15:42:47Z
3+
-- unix-2.8.7.0
4+
, hackage.haskell.org 2025-05-10T14:12:28Z
55

66
packages:
77
.

0 commit comments

Comments
 (0)