X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=os%2Fwindows%2Fposix.c;h=d238c64a16219607ced8eb7dd4807552361046e6;hp=6a7841d5513d743b3451ec14dd94daf11f27b679;hb=c2acfbac7e9eb8ac5407ac024c0fd000614c77e2;hpb=10a6b3c67042914fe9d287027bf8792f69e84524 diff --git a/os/windows/posix.c b/os/windows/posix.c index 6a7841d5..d238c64a 100755 --- a/os/windows/posix.c +++ b/os/windows/posix.c @@ -12,12 +12,15 @@ #include #include #include +#include #include #include #include #include #include #include +#include +#include #include "../os-windows.h" #include "../../lib/hweight.h" @@ -421,6 +424,7 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp) { static LARGE_INTEGER freq = {{0,0}}; LARGE_INTEGER counts; + uint64_t t; QueryPerformanceCounter(&counts); if (freq.QuadPart == 0) @@ -429,7 +433,7 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp) tp->tv_sec = counts.QuadPart / freq.QuadPart; /* Get the difference between the number of ns stored * in 'tv_sec' and that stored in 'counts' */ - uint64_t t = tp->tv_sec * freq.QuadPart; + t = tp->tv_sec * freq.QuadPart; t = counts.QuadPart - t; /* 't' now contains the number of cycles since the last second. * We want the number of nanoseconds, so multiply out by 1,000,000,000 @@ -661,11 +665,6 @@ int getrusage(int who, struct rusage *r_usage) return 0; } -int posix_fadvise(int fd, off_t offset, off_t len, int advice) -{ - return 0; -} - int posix_madvise(void *addr, size_t len, int advice) { log_err("%s is not implemented\n", __func__); @@ -710,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, @@ -754,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) { @@ -774,7 +785,6 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout) fds[i].revents |= POLLHUP; } } - return rc; } @@ -876,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) {