Skip to content

Commit 29e3133

Browse files
Mistukekazu-yamamoto
authored andcommitted
Add initial scaffolding for WinIO support
1 parent 9d29533 commit 29e3133

File tree

6 files changed

+35
-28
lines changed

6 files changed

+35
-28
lines changed

.github/workflows/haskell.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
fail-fast: false
6868
matrix:
6969
os: [ 'ubuntu-latest', 'macOS-latest', 'windows-latest' ]
70-
ghc: [ '8.10', '9.0', '9.2', '9.4', '9.6' ]
70+
ghc: [ '9.0', '9.2', '9.4', '9.6' ]
7171

7272
steps:
7373
- uses: actions/checkout@v3

CHANGELOG.md

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

38
* Install and use afunix_compat.h header.

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
@@ -20,6 +20,7 @@ import Network.Socket.Types
2020
-- cooperate with peer's 'gracefulClose', i.e. proper shutdown
2121
-- sequence with appropriate handshakes specified by the protocol.
2222

23+
-- TODO: WinIO doesn't use fd, add support
2324
socketToHandle :: Socket -> IOMode -> IO Handle
2425
socketToHandle s mode = invalidateSocket s err $ \oldfd -> do
2526
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: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
cabal-version: 1.18
22
name: network
3-
version: 3.1.4.0
3+
version: 3.2.0
44
license: BSD3
55
license-file: LICENSE
6-
maintainer: Kazu Yamamoto, Evan Borden
7-
8-
tested-with:
9-
GHC == 9.6.1
10-
GHC == 9.4.4
11-
GHC == 9.2.7
12-
GHC == 9.0.2
13-
GHC == 8.10.7
14-
GHC == 8.8.4
15-
GHC == 8.6.5
16-
GHC == 8.4.4
17-
GHC == 8.2.2
18-
GHC == 8.0.2
19-
6+
maintainer: Kazu Yamamoto, Tamar Christina
7+
tested-with: ghc ==9.6.2 ghc ==9.4.5 ghc ==9.2.7 ghc ==9.0.2
208
homepage: https://github.com/haskell/network
219
bug-reports: https://github.com/haskell/network/issues
2210
synopsis: Low-level networking interface
@@ -50,11 +38,6 @@ description:
5038

5139
category: Network
5240
build-type: Configure
53-
54-
extra-doc-files:
55-
README.md
56-
CHANGELOG.md
57-
5841
extra-source-files:
5942
examples/*.hs
6043
tests/*.hs
@@ -79,6 +62,10 @@ extra-tmp-files:
7962
network.buildinfo
8063
include/HsNetworkConfig.h
8164

65+
extra-doc-files:
66+
README.md
67+
CHANGELOG.md
68+
8269
source-repository head
8370
type: git
8471
location: https://github.com/haskell/network.git
@@ -124,17 +111,17 @@ library
124111
include-dirs: include
125112
includes: HsNet.h HsNetDef.h alignment.h win32defs.h
126113
install-includes: HsNet.h HsNetDef.h alignment.h win32defs.h
127-
if os(windows)
128-
includes: afunix_compat.h
129-
install-includes: afunix_compat.h
130-
131114
ghc-options: -Wall -fwarn-tabs
132115
build-depends:
133116
base >=4.9 && <5,
134117
bytestring >=0.10 && <0.12,
135118
deepseq,
136119
directory
137120

121+
if os(windows)
122+
includes: afunix_compat.h
123+
install-includes: afunix_compat.h
124+
138125
if !os(windows)
139126
other-modules:
140127
Network.Socket.ByteString.Lazy.Posix
@@ -168,12 +155,16 @@ library
168155
iphlpapi
169156
mswsock
170157

171-
if impl(ghc >=7.10)
158+
build-depends: temporary
159+
160+
if impl(ghc >=7.10 && <9.0)
172161
cpp-options: -D_WIN32_WINNT=0x0600
173162
cc-options: -D_WIN32_WINNT=0x0600
174163

175-
build-depends:
176-
temporary
164+
if impl(ghc >=9.0)
165+
cpp-options: -D_WIN32_WINNT=0x0601
166+
cc-options: -D_WIN32_WINNT=0x0601
167+
build-depends: Win32 >=2.12.0.1
177168

178169
if impl(ghc >=8)
179170
default-extensions: Strict StrictData
@@ -201,6 +192,9 @@ test-suite spec
201192
hspec >=2.6,
202193
QuickCheck
203194

195+
if os(windows) && impl(ghc >=9.0)
196+
ghc-options: -with-rtsopts=--io-manager=native
197+
204198
if flag(devel)
205199
cpp-options: -DDEVELOPMENT
206200

0 commit comments

Comments
 (0)