The following changes since commit 44462517234f07e03c4dc71e5b5460cd70feeb07:

  configure: add option to disable libnuma usage (2013-10-31 11:00:54 -0600)

are available in the git repository at:
  git://git.kernel.dk/fio.git master

Bruce Cran (3):
      Update Windows code to fix build breakage
      Implement writev on Windows
      server: ensure that fio_time_init() is called before option parsing

 backend.c                            |    7 ++++++-
 engines/net.c                        |   18 +++++++++---------
 os/os-windows.h                      |    9 ++++-----
 os/windows/posix.c                   |   32 +++++++++++++++++++++++++++-----
 os/windows/posix/include/arpa/inet.h |   13 +++++++++++++
 os/windows/posix/include/sys/uio.h   |    4 ++--
 os/windows/posix/include/sys/wait.h  |    2 +-
 7 files changed, 62 insertions(+), 23 deletions(-)

---

Diff of recent changes:

diff --git a/backend.c b/backend.c
index 180a487..00a23db 100644
--- a/backend.c
+++ b/backend.c
@@ -1129,6 +1129,11 @@ static void *thread_main(void *data)
        } else
                td->pid = gettid();
 
+       /*
+        * fio_time_init() may not have been called yet if running as a server
+        */
+       fio_time_init();
+
        fio_local_clock_init(o->use_thread);
 
        dprint(FD_PROCESS, "jobs pid=%d started\n", (int) td->pid);
@@ -1590,7 +1595,7 @@ static void run_threads(void)
 
        if (fio_gtod_offload && fio_start_gtod_thread())
                return;
-       
+
        fio_idle_prof_init();
 
        set_sig_handlers();
diff --git a/engines/net.c b/engines/net.c
index 0c90e1c..52cc8a7 100644
--- a/engines/net.c
+++ b/engines/net.c
@@ -38,7 +38,7 @@ struct netio_options {
        unsigned int pingpong;
        unsigned int nodelay;
        unsigned int ttl;
-       char * interface;
+       char *intfc;
 };
 
 struct udp_close_msg {
@@ -134,7 +134,7 @@ static struct fio_option options[] = {
                .name   = "interface",
                .lname  = "net engine interface",
                .type   = FIO_OPT_STR_STORE,
-               .off1   = offsetof(struct netio_options, interface),
+               .off1   = offsetof(struct netio_options, intfc),
                .help   = "Network interface to use",
                .category = FIO_OPT_C_ENGINE,
                .group  = FIO_OPT_G_NETIO,
@@ -557,20 +557,20 @@ static int fio_netio_connect(struct thread_data *td, 
struct fio_file *f)
                if (!fio_netio_is_multicast(td->o.filename))
                        return 0;
 
-               if (o->interface) {
+               if (o->intfc) {
                        struct in_addr interface_addr;
-                       if (inet_aton(o->interface, &interface_addr) == 0) {
+                       if (inet_aton(o->intfc, &interface_addr) == 0) {
                                log_err("fio: interface not valid interface 
IP\n");
                                close(f->fd);
                                return 1;
                        }
-                       if (setsockopt(f->fd, IPPROTO_IP, IP_MULTICAST_IF, 
&interface_addr, sizeof(interface_addr)) < 0) {
+                       if (setsockopt(f->fd, IPPROTO_IP, IP_MULTICAST_IF, 
(const char*)&interface_addr, sizeof(interface_addr)) < 0) {
                                td_verror(td, errno, "setsockopt 
IP_MULTICAST_IF");
                                close(f->fd);
                                return 1;
                        }
                }
-               if (setsockopt(f->fd, IPPROTO_IP, IP_MULTICAST_TTL, &o->ttl, 
sizeof(o->ttl)) < 0) {
+               if (setsockopt(f->fd, IPPROTO_IP, IP_MULTICAST_TTL, (const 
char*)&o->ttl, sizeof(o->ttl)) < 0) {
                        td_verror(td, errno, "setsockopt IP_MULTICAST_TTL");
                        close(f->fd);
                        return 1;
@@ -884,8 +884,8 @@ static int fio_netio_setup_listen_inet(struct thread_data 
*td, short port)
                inet_aton(td->o.filename, &sin.sin_addr);
 
                mr.imr_multiaddr = sin.sin_addr;
-               if (o->interface) {
-                       if (inet_aton(o->interface, &mr.imr_interface) == 0) {
+               if (o->intfc) {
+                       if (inet_aton(o->intfc, &mr.imr_interface) == 0) {
                                log_err("fio: interface not valid interface 
IP\n");
                                close(fd);
                                return 1;
@@ -893,7 +893,7 @@ static int fio_netio_setup_listen_inet(struct thread_data 
*td, short port)
                } else {
                        mr.imr_interface.s_addr = htonl(INADDR_ANY);
                }
-               if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mr, 
sizeof(mr)) < 0) {
+               if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const 
char*)&mr, sizeof(mr)) < 0) {
                        td_verror(td, errno, "setsockopt IP_ADD_MEMBERSHIP");
                        close(fd);
                        return 1;
diff --git a/os/os-windows.h b/os/os-windows.h
index 4f4e2bb..de120b6 100644
--- a/os/os-windows.h
+++ b/os/os-windows.h
@@ -18,6 +18,10 @@
 
 #include "windows/posix.h"
 
+#ifndef PTHREAD_STACK_MIN
+#define PTHREAD_STACK_MIN 65535
+#endif
+
 #define FIO_HAVE_ODIRECT
 #define FIO_HAVE_CPU_AFFINITY
 #define FIO_HAVE_CHARDEV_SIZE
@@ -38,9 +42,6 @@
 
 typedef DWORD_PTR os_cpu_mask_t;
 
-#define CLOCK_REALTIME 1
-#define CLOCK_MONOTONIC        2
-
 #define _SC_PAGESIZE                   0x1
 #define _SC_NPROCESSORS_ONLN   0x2
 #define _SC_PHYS_PAGES                 0x4
@@ -115,7 +116,6 @@ static inline int blockdev_size(struct fio_file *f, 
unsigned long long *bytes)
        HANDLE hFile;
        GET_LENGTH_INFORMATION info;
        DWORD outBytes;
-       LARGE_INTEGER size;
 
        if (f->hFile == NULL) {
                hFile = CreateFile(f->file_name, GENERIC_READ, FILE_SHARE_READ 
| FILE_SHARE_WRITE,
@@ -124,7 +124,6 @@ static inline int blockdev_size(struct fio_file *f, 
unsigned long long *bytes)
                hFile = f->hFile;
        }
 
-       size.QuadPart = 0;
        if (DeviceIoControl(hFile, IOCTL_DISK_GET_LENGTH_INFO, NULL, 0, &info, 
sizeof(info), &outBytes, NULL))
                *bytes = info.Length.QuadPart;
        else
diff --git a/os/windows/posix.c b/os/windows/posix.c
index 49bce43..d238c64 100755
--- a/os/windows/posix.c
+++ b/os/windows/posix.c
@@ -12,12 +12,15 @@
 #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)
 {
diff --git a/os/windows/posix/include/arpa/inet.h 
b/os/windows/posix/include/arpa/inet.h
index 7e3bfb7..59c50ad 100644
--- a/os/windows/posix/include/arpa/inet.h
+++ b/os/windows/posix/include/arpa/inet.h
@@ -5,6 +5,19 @@
 #include <inttypes.h>
 
 typedef int socklen_t;
+typedef int in_addr_t;
+
+#define IP_MULTICAST_IF 2
+#define IP_MULTICAST_TTL 3
+#define IP_ADD_MEMBERSHIP 5
+
+struct ip_mreq
+{
+       struct in_addr imr_multiaddr;
+       struct in_addr imr_interface;
+};
+
+in_addr_t inet_network(const char *cp);
 
 const char *inet_ntop(int af, const void *restrict src,
         char *restrict dst, socklen_t size);
diff --git a/os/windows/posix/include/sys/uio.h 
b/os/windows/posix/include/sys/uio.h
index 25f83d6..402e988 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 5b8fd3a..ac50aa8 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);
 
--
To unsubscribe from this list: send the line "unsubscribe fio" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to