summaryrefslogtreecommitdiff
path: root/os
diff options
context:
space:
mode:
Diffstat (limited to 'os')
-rwxr-xr-xos/windows/posix.c23
-rw-r--r--os/windows/posix/include/sys/uio.h4
-rw-r--r--os/windows/posix/include/sys/wait.h2
3 files changed, 21 insertions, 8 deletions
diff --git a/os/windows/posix.c b/os/windows/posix.c
index 8153b455..d238c64a 100755
--- a/os/windows/posix.c
+++ b/os/windows/posix.c
@@ -19,6 +19,8 @@
#include <sys/uio.h>
#include <sys/resource.h>
#include <sys/poll.h>
+#include <sys/wait.h>
+#include <setjmp.h>
#include "../os-windows.h"
#include "../../lib/hweight.h"
@@ -707,9 +709,22 @@ ssize_t readv(int fildes, const struct iovec *iov, int iovcnt)
ssize_t writev(int fildes, const struct iovec *iov, int iovcnt)
{
- log_err("%s is not implemented\n", __func__);
- errno = ENOSYS;
- return -1;
+ int i;
+ DWORD bytes_written = 0;
+ for (i = 0; i < iovcnt; i++)
+ {
+ int len = send((SOCKET)fildes, iov[i].iov_base, iov[i].iov_len, 0);
+ if (len == SOCKET_ERROR)
+ {
+ DWORD err = GetLastError();
+ errno = win_to_posix_error(err);
+ bytes_written = -1;
+ break;
+ }
+ bytes_written += len;
+ }
+
+ return bytes_written;
}
long long strtoll(const char *restrict str, char **restrict endptr,
@@ -751,7 +766,6 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout)
FD_SET(fds[i].fd, &exceptfds);
}
-
rc = select(nfds, &readfds, &writefds, &exceptfds, to);
if (rc != SOCKET_ERROR) {
@@ -771,7 +785,6 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout)
fds[i].revents |= POLLHUP;
}
}
-
return rc;
}
diff --git a/os/windows/posix/include/sys/uio.h b/os/windows/posix/include/sys/uio.h
index 25f83d60..402e988b 100644
--- a/os/windows/posix/include/sys/uio.h
+++ b/os/windows/posix/include/sys/uio.h
@@ -4,8 +4,8 @@
#include <inttypes.h>
#include <unistd.h>
- struct iovec
- {
+struct iovec
+{
void *iov_base; /* Base address of a memory region for input or output */
size_t iov_len; /* The size of the memory pointed to by iov_base */
};
diff --git a/os/windows/posix/include/sys/wait.h b/os/windows/posix/include/sys/wait.h
index 5b8fd3ae..ac50aa86 100644
--- a/os/windows/posix/include/sys/wait.h
+++ b/os/windows/posix/include/sys/wait.h
@@ -5,7 +5,7 @@
#define WIFEXITED(a) 0
#define WTERMSIG(a) 0
#define WEXITSTATUS(a) 0
-#define WNOHANG 0
+#define WNOHANG 1
pid_t waitpid(pid_t, int *stat_loc, int options);