NIO: repair the build after e3508b0d0 (#1636)

`ssize_t` is not a standard type and does not have a portable Swift
spelling.  Use `size_t` which is compatible in size, but is signed
instead.  This is needed in order to be compatible to more standard
conforming environments like Windows.
This commit is contained in:
Saleem Abdulrasool 2020-09-21 01:36:18 -07:00 committed by GitHub
parent 96db8838be
commit 36b19f98c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 13 deletions

View File

@ -376,11 +376,17 @@ protocol _BSDSocketProtocol {
buffer buf: UnsafeMutableRawPointer,
length len: size_t) throws -> IOResult<size_t>
static func recvmsg(descriptor: CInt, msgHdr: UnsafeMutablePointer<msghdr>, flags: CInt) throws -> IOResult<ssize_t>
static func sendmsg(descriptor: CInt,
msgHdr: UnsafePointer<msghdr>,
flags: CInt) throws -> IOResult<ssize_t>
// NOTE: this should return a `ssize_t`, however, that is not a standard
// type, and defining that type is difficult. Opt to return a `size_t`
// which is the same size, but is unsigned.
static func recvmsg(descriptor: CInt, msgHdr: UnsafeMutablePointer<msghdr>,
flags: CInt) throws -> IOResult<size_t>
// NOTE: this should return a `ssize_t`, however, that is not a standard
// type, and defining that type is difficult. Opt to return a `size_t`
// which is the same size, but is unsigned.
static func sendmsg(descriptor: CInt, msgHdr: UnsafePointer<msghdr>,
flags: CInt) throws -> IOResult<size_t>
static func send(socket s: NIOBSDSocket.Handle,
buffer buf: UnsafeRawPointer,

View File

@ -84,13 +84,13 @@ extension NIOBSDSocket {
return try Posix.read(descriptor: s, pointer: buf, size: len)
}
static func recvmsg(descriptor: CInt, msgHdr: UnsafeMutablePointer<msghdr>, flags: CInt) throws -> IOResult<ssize_t> {
static func recvmsg(descriptor: CInt, msgHdr: UnsafeMutablePointer<msghdr>, flags: CInt) throws -> IOResult<size_t> {
return try Posix.recvmsg(descriptor: descriptor, msgHdr: msgHdr, flags: flags)
}
static func sendmsg(descriptor: CInt,
msgHdr: UnsafePointer<msghdr>,
flags: CInt) throws -> IOResult<ssize_t> {
flags: CInt) throws -> IOResult<size_t> {
return try Posix.sendmsg(descriptor: descriptor, msgHdr: msgHdr, flags: flags)
}

View File

@ -161,14 +161,14 @@ extension NIOBSDSocket {
}
@inline(never)
static func recvmsg(descriptor: CInt, msgHdr: UnsafeMutablePointer<msghdr>, flags: CInt) throws -> IOResult<ssize_t> {
static func recvmsg(descriptor: CInt, msgHdr: UnsafeMutablePointer<msghdr>,
flags: CInt) throws -> IOResult<size_t> {
fatalError("recvmsg not yet implemented on Windows")
}
@inline(never)
static func sendmsg(descriptor: CInt,
msgHdr: UnsafePointer<msghdr>,
flags: CInt) throws -> IOResult<ssize_t> {
static func sendmsg(descriptor: CInt, msgHdr: UnsafePointer<msghdr>,
flags: CInt) throws -> IOResult<size_t> {
fatalError("recvmsg not yet implemented on Windows")
}