Add support for cpus_allowed_policy
[fio.git] / os / windows / posix.c
index 49bce43955465ca23483660005da8c2770489a5c..d238c64a16219607ced8eb7dd4807552361046e6 100755 (executable)
 #include <unistd.h>
 #include <dirent.h>
 #include <pthread.h>
+#include <time.h>
 #include <semaphore.h>
 #include <sys/shm.h>
 #include <sys/mman.h>
 #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"
@@ -706,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,
@@ -750,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) {
@@ -770,7 +785,6 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout)
                                fds[i].revents |= POLLHUP;
                }
        }
-
        return rc;
 }
 
@@ -872,6 +886,14 @@ uid_t geteuid(void)
        return -1;
 }
 
+in_addr_t inet_network(const char *cp)
+{
+       in_addr_t hbo;
+       in_addr_t nbo = inet_addr(cp);
+       hbo = ((nbo & 0xFF) << 24) + ((nbo & 0xFF00) << 8) + ((nbo & 0xFF0000) >> 8) + ((nbo & 0xFF000000) >> 24);
+       return hbo;
+}
+
 const char* inet_ntop(int af, const void *restrict src,
                char *restrict dst, socklen_t size)
 {