[ovs-dev] [PATCH 16/16] ovs-benchmark: Compile for windows.

Gurucharan Shetty shettyg at nicira.com
Fri May 30 19:06:24 UTC 2014


This just makes ovs-benchmark compile on windows.
This lets us go ahead with just a 'make' instead of
picking and choosing executables that are tested to work on
windows as arguments for make.

This commit does not make ovs-benchmark a supported utility
on windows.

Signed-off-by: Gurucharan Shetty <gshetty at nicira.com>
---
 BUILD.Windows             |    8 ++------
 utilities/ovs-benchmark.c |   30 ++++++++++++++++++------------
 2 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/BUILD.Windows b/BUILD.Windows
index ca0d252..71fb38b 100644
--- a/BUILD.Windows
+++ b/BUILD.Windows
@@ -56,13 +56,9 @@ or from a distribution tar ball.
     --prefix="C:/openvswitch/usr" --localstatedir="C:/openvswitch/var" \
     --sysconfdir="C:/openvswitch/etc" --with-pthread="C:/pthread"
 
-* Run make for the ported executables in the top source directory, e.g.:
+* Run make in the top source directory.
 
-  % make lib/vswitch-idl.h lib/vtep-idl.h ofproto/ipfix-entities.def
-  % make ovsdb/ovsdb-server.exe ovsdb/ovsdb-tool.exe ovsdb/ovsdb-client.exe \
-         utilities/ovs-vsctl.exe utilities/ovs-ofctl.exe \
-         utilities/ovs-dpctl.exe vswitchd/ovs-vswitchd.exe \
-         utilities/ovs-appctl.exe
+  % make
 
 OpenSSL, Open vSwitch and Visual C++
 ------------------------------------
diff --git a/utilities/ovs-benchmark.c b/utilities/ovs-benchmark.c
index 0bb316f..386e654 100644
--- a/utilities/ovs-benchmark.c
+++ b/utilities/ovs-benchmark.c
@@ -54,14 +54,26 @@ static const struct command *get_all_commands(void);
 static void parse_options(int argc, char *argv[]);
 static void usage(void);
 
+static int
+do_poll(struct pollfd *fds, int nfds, int timeout)
+{
+    int retval;
+#ifndef _WIN32
+    do {
+        retval = poll(fds, nfds, timeout);
+    } while (retval < 0 && errno == EINTR);
+#else
+    retval = WSAPoll(fds, nfds, timeout);
+#endif
+    return retval;
+}
+
 static long long int
 time_in_msec(void)
 {
     struct timeval tv;
 
-    if (gettimeofday(&tv, NULL) < 0) {
-        ovs_fatal(errno, "gettimeofday");
-    }
+    xgettimeofday(&tv);
 
     return tv.tv_sec * 1000LL + tv.tv_usec / 1000;
 }
@@ -284,9 +296,7 @@ cmd_listen(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
     for (;;) {
         int retval;
 
-        do {
-            retval = poll(fds, n_fds, -1);
-        } while (retval < 0 && errno == EINTR);
+        retval = do_poll(fds, n_fds, -1);
         if (retval < 0) {
             ovs_fatal(errno, "poll failed");
         }
@@ -445,9 +455,7 @@ cmd_rate(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
             delay = 1000;
         }
 
-        do {
-            error = poll(fds, n_fds, delay) < 0 ? errno : 0;
-        } while (error == EINTR);
+        error = do_poll(fds, n_fds, delay);
         if (error) {
             ovs_fatal(errno, "poll");
         }
@@ -578,9 +586,7 @@ cmd_latency(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
         while (n_fds > 0) {
             int error;
 
-            do {
-                error = poll(fds, n_fds, -1) < 0 ? errno : 0;
-            } while (error == EINTR);
+            error = do_poll(fds, n_fds, -1);
             if (error) {
                 ovs_fatal(errno, "poll");
             }
-- 
1.7.9.5




More information about the dev mailing list