     while true {
         let res = try body()
         if res == -1 {
+#if os(Windows)
+            var err: CInt = 0
+            _get_errno(&err)
+#else
             let err = errno
+#endif
             switch err {
             case EINTR:
                 continue

    internal static func close(descriptor: CInt) throws {
        let res = sysClose(descriptor)
        if res == -1 {
            let err = errno

            // There is really nothing "sane" we can do when EINTR was reported on close.
            // So just ignore it and "assume" everything is fine == we closed the file descriptor.

    while true {
        let res = try body()
        if res == -1 {
#if os(Windows)
            var err: CInt = 0
            _get_errno(&err)
#else
            let err = errno
#endif
            switch (err, blocking) {
            case (EINTR, _):
                continue
