ref: 7da7a91bc8a0162bf0f21d298c1a356fc2cbce00
parent: e43dbe8cc89f1945b25b7fdbac45e8e61f8273c1
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Fri Mar 10 21:09:20 EST 2023
ios: plan 9 does not have errno, so stop pretending
--- a/llt/ios.c
+++ b/llt/ios.c
@@ -56,33 +56,14 @@
extern void *memrchr(const void *s, int c, size_t n);
#endif
-#if 0
-// poll for read, unless forwrite!=0
-static void _fd_poll(long fd, int forwrite)
-{
- fd_set set;
-
- FD_ZERO(&set);
- FD_SET(fd, &set);
- if (forwrite)
- select(fd+1, NULL, &set, NULL, NULL);
- else
- select(fd+1, &set, NULL, NULL, NULL);
-}
-#endif
-
+#ifndef PLAN9
static int _enonfatal(int err)
{
-#ifdef PLAN9
- USED(err);
- return 0;
-#else
return (err == EAGAIN || err == EINPROGRESS || err == EINTR ||
err == EWOULDBLOCK);
-#endif
}
-
#define SLEEP_TIME 5//ms
+#endif
// return error code, #bytes read in *nread
// these wrappers retry operations until success or a fatal error
@@ -96,11 +77,15 @@
*nread = (size_t)r;
break;
}
+#ifdef PLAN9
+ return r;
+#else
if (!_enonfatal(errno)) {
*nread = 0;
return errno;
}
sleep_ms(SLEEP_TIME);
+#endif
}
return 0;
}
@@ -132,11 +117,15 @@
*nwritten = (size_t)r;
break;
}
+#ifdef PLAN9
+ return r;
+#else
if (!_enonfatal(errno)) {
*nwritten = 0;
return errno;
}
sleep_ms(SLEEP_TIME);
+#endif
}
return 0;
}