From: Ethan Jackson <ethan@nicira.com>
Date: Wed, 17 Oct 2012 01:16:16 +0000 (-0700)
Subject: timeval: Optionally enable cached timing at configure time.
X-Git-Tag: sliver-openvswitch-1.9.90-1~3^2~37
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=3d7cab5fe02a7c7181d1479f3b41f4b6d3fa0264;p=sliver-openvswitch.git

timeval: Optionally enable cached timing at configure time.

Often when developing, it would be convenient to force OVS to
either enable or disable cached timing so that a feature can be
tested under both strategies.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
---

diff --git a/configure.ac b/configure.ac
index ef513aa35..2b20f40a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,6 +75,7 @@ OVS_CHECK_XENSERVER_VERSION
 OVS_CHECK_GROFF
 OVS_CHECK_BRCOMPAT
 OVS_CHECK_GNU_MAKE
+OVS_CHECK_CACHE_TIME
 
 OVS_ENABLE_OPTION([-Wall])
 OVS_ENABLE_OPTION([-Wno-sign-compare])
diff --git a/lib/timeval.h b/lib/timeval.h
index cb5191c5e..0f7d15c6c 100644
--- a/lib/timeval.h
+++ b/lib/timeval.h
@@ -54,11 +54,13 @@ BUILD_ASSERT_DECL(TYPE_IS_SIGNED(time_t));
  *
  * Also false on systems (e.g. ESX) that don't support setting up timers based
  * on a monotonically increasing clock. */
+#ifndef CACHE_TIME
 #if defined ESX || (defined __x86_64__ && defined LINUX_DATAPATH)
 #define CACHE_TIME 0
 #else
 #define CACHE_TIME 1
 #endif
+#endif /* ifndef CACHE_TIME */
 
 void time_disable_restart(void);
 void time_enable_restart(void);
diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
index dc99cd043..74690115d 100644
--- a/m4/openvswitch.m4
+++ b/m4/openvswitch.m4
@@ -46,6 +46,22 @@ AC_DEFUN([OVS_CHECK_NDEBUG],
      [ndebug=false])
    AM_CONDITIONAL([NDEBUG], [test x$ndebug = xtrue])])
 
+dnl Checks for --enable-cache-time and defines CACHE_TIME if it is specified.
+AC_DEFUN([OVS_CHECK_CACHE_TIME],
+  [AC_ARG_ENABLE(
+     [cache-time],
+     [AC_HELP_STRING([--enable-cache-time],
+                     [Override time caching default (for testing only)])],
+     [case "${enableval}" in
+        (yes) cache_time=1;;
+        (no)  cache_time=0;;
+        (*) AC_MSG_ERROR([bad value ${enableval} for --enable-cache-time]) ;;
+      esac
+      AC_DEFINE_UNQUOTED([CACHE_TIME], [$cache_time],
+          [Define to 1 to enable time caching, to 0 to disable time caching, or
+           leave undefined to use the default (as one should
+           ordinarily do).])])])
+
 dnl Checks for ESX.
 AC_DEFUN([OVS_CHECK_ESX],
   [AC_CHECK_HEADER([vmware.h],