Repository: apple/swift-nio
File: Sources/NIOPosix/System.swift (Swift)

Code before:
    }

    @inline(never)
    public static func symlink(pathname: String, destination: String) throws {
        _ = try syscall(blocking: true) {
            sysSymlink(destination, pathname)
        }
    }

    @inline(never)
    public static func readlink(pathname: String, outPath: UnsafeMutablePointer<CChar>, outPathSize: Int) throws {
        _ = try syscall(blocking: true) {
            sysReadlink(pathname, outPath, outPathSize)
        }
    }

    @inline(never)
    public static func unlink(pathname: String) throws {
        _ = try syscall(blocking: false) {
            sysUnlink(pathname)
        }
    }

    @inline(never)
    public static func mkdir(pathname: String, mode: mode_t) throws {
        _ = try syscall(blocking: true) {
            sysMkdir(pathname, mode)
        }
    }

#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
    @inline(never)
    public static func mkpath(pathname: String, mode: mode_t) throws {
        _ = try syscall(blocking: true) {
            sysMkpath(pathname, mode)
        }
    }
#endif

#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
    @inline(never)
    public static func opendir(pathname: String) throws -> UnsafeMutablePointer<DIR> {
        guard let result = sysOpendir(pathname) else {
            let err = errno
            throw IOError(errnoCode: err, reason: #function)
        }
        return result
    }

    @inline(never)
    public static func readdir(dir: UnsafeMutablePointer<DIR>) throws -> UnsafeMutablePointer<dirent>? {

Review comment (suggestion):
Blocking should be `false`, this cannot return `EAGAIN` or `EWOULDBLOCK`.

Code after:
        }
    }

    @inline(never)
    internal static func sendmmsg(sockfd: CInt, msgvec: UnsafeMutablePointer<MMsgHdr>, vlen: CUnsignedInt, flags: CInt) throws -> IOResult<Int> {
        return try syscall(blocking: true) {
            Int(sysSendMmsg(sockfd, msgvec, vlen, flags))
        }
    }

    @inline(never)
    internal static func recvmmsg(sockfd: CInt, msgvec: UnsafeMutablePointer<MMsgHdr>, vlen: CUnsignedInt, flags: CInt, timeout: UnsafeMutablePointer<timespec>?) throws -> IOResult<Int> {
        return try syscall(blocking: true) {
            Int(sysRecvMmsg(sockfd, msgvec, vlen, flags, timeout))
        }
    }

    @inline(never)
    internal static func getpeername(socket: CInt, address: UnsafeMutablePointer<sockaddr>, addressLength: UnsafeMutablePointer<socklen_t>) throws {
        _ = try syscall(blocking: false) {
            return sysGetpeername(socket, address, addressLength)
        }
    }

    @inline(never)
    internal static func getsockname(socket: CInt, address: UnsafeMutablePointer<sockaddr>, addressLength: UnsafeMutablePointer<socklen_t>) throws {
        _ = try syscall(blocking: false) {
            return sysGetsockname(socket, address, addressLength)
        }
    }
#endif

    @inline(never)
    internal static func if_nametoindex(_ name: UnsafePointer<CChar>?) throws -> CUnsignedInt {
        return try syscall(blocking: false) {
            sysIfNameToIndex(name)
        }.result
    }

#if !os(Windows)
    @inline(never)
    internal static func poll(fds: UnsafeMutablePointer<pollfd>, nfds: nfds_t, timeout: CInt) throws -> CInt {
        return try syscall(blocking: false) {
            sysPoll(fds, nfds, timeout)
        }.result
    }

    @inline(never)
    internal static func fstat(descriptor: CInt, outStat: UnsafeMutablePointer<stat>) throws {
        _ = try syscall(blocking: false) {
            sysFstat(descriptor, outStat)