Skip to content

Commit 8a414d0

Browse files
Mistukekazu-yamamoto
authored andcommitted
Add initial scaffolding for WinIO support
1 parent c00be44 commit 8a414d0

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## Version 3.3.0.0
2+
3+
* Basic support for WINIO
4+
[#509](https://github.com/haskell/network/pull/509)
5+
16
## Version 3.2.7.0
27

38
* Using nested `bracket` for `gracefulClose`.

Network/Socket/Fcntl.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ getCloseOnExec fd = do
5151
-- Since 2.7.0.0.
5252
getNonBlock :: CInt -> IO Bool
5353
#if defined(mingw32_HOST_OS)
54+
-- | TODO: Query socket for async flag
5455
getNonBlock _ = return False
5556
#else
5657
getNonBlock fd = do

Network/Socket/Handle.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import Network.Socket.Types
1919
-- Haskell, e.g. merely performing 'hClose' on a TCP socket won't
2020
-- cooperate with peer's 'gracefulClose', i.e. proper shutdown
2121
-- sequence with appropriate handshakes specified by the protocol.
22+
-- TODO: WinIO doesn't use fd, add support
2223
socketToHandle :: Socket -> IOMode -> IO Handle
2324
socketToHandle s mode = invalidateSocket s err $ \oldfd -> do
2425
h <- fdToHandle' oldfd (Just GHC.IO.Device.Stream) True (show s) mode True {-bin-}

cbits/cmsg.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ WSASendMsg (SOCKET s, LPWSAMSG lpMsg, DWORD flags,
3838
DWORD len;
3939
if (WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER,
4040
&WSASendMsgGUID, sizeof(WSASendMsgGUID), &ptr_SendMsg,
41+
/* Sadly we can't perform this async for now as C code can't wait for
42+
completion events from the Haskell RTS. This needs to be moved to
43+
Haskell on a re-designed async Network. */
4144
sizeof(ptr_SendMsg), &len, NULL, NULL) != 0)
4245
return -1;
4346
}
@@ -58,6 +61,9 @@ WSARecvMsg (SOCKET s, LPWSAMSG lpMsg, LPDWORD lpdwNumberOfBytesRecvd,
5861
DWORD len;
5962
if (WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER,
6063
&WSARecvMsgGUID, sizeof(WSARecvMsgGUID), &ptr_RecvMsg,
64+
/* Sadly we can't perform this async for now as C code can't wait for
65+
completion events from the Haskell RTS. This needs to be moved to
66+
Haskell on a re-designed async Network. */
6167
sizeof(ptr_RecvMsg), &len, NULL, NULL) != 0)
6268
return -1;
6369
}

network.cabal

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ version: 3.2.7.0
44
license: BSD3
55
license-file: LICENSE
66
maintainer: Kazu Yamamoto, Tamar Christina
7-
87
tested-with:
98
GHC == 9.8.2
109
GHC == 9.6.4
@@ -169,12 +168,16 @@ library
169168
iphlpapi
170169
mswsock
171170

172-
if impl(ghc >=7.10)
171+
build-depends: temporary
172+
173+
if impl(ghc >=7.10 && <9.0)
173174
cpp-options: -D_WIN32_WINNT=0x0600
174175
cc-options: -D_WIN32_WINNT=0x0600
175176

176-
build-depends:
177-
temporary
177+
if impl(ghc >=9.0)
178+
cpp-options: -D_WIN32_WINNT=0x0601
179+
cc-options: -D_WIN32_WINNT=0x0601
180+
build-depends: Win32 >=2.12.0.1
178181

179182
if impl(ghc >=8)
180183
default-extensions: Strict StrictData
@@ -202,6 +205,9 @@ test-suite spec
202205
hspec >=2.6,
203206
QuickCheck
204207

208+
if os(windows) && impl(ghc >=9.0)
209+
ghc-options: -with-rtsopts=--io-manager=native
210+
205211
if flag(devel)
206212
cpp-options: -DDEVELOPMENT
207213

0 commit comments

Comments
 (0)