summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Oliver <richard@richard-oliver.co.uk>2017-10-28 16:38:30 +0100
committerSimon Horman <simon.horman@netronome.com>2019-03-15 19:06:44 +0100
commitf7c517e0c27e94565a01dc800de1e664eda0b6f0 (patch)
treeaa8ccef5830ad2c7e2baa5c7442f41d9e5463b34
parentb6925c6e24ade4d5dccdd681cc8d6c52bf7abf14 (diff)
downloadopenvswitch-f7c517e0c27e94565a01dc800de1e664eda0b6f0.tar.gz
timeval: Check for OS-provided clock_gettime on macOS
[Problem] Compilation error on newer versions of macOS (Sierra onwards) due to multiple declarations of clock_gettime. [Solution] Have configure check for clock_gettime and check this result in timeval to avoid incorrectly declaring/defining clock_gettime again. [Testing] Source code now successfully builds on macOS. Signed-off-by: Richard Oliver <richard@richard-oliver.co.uk> Signed-off-by: Simon Horman <simon.horman@netronome.com>
-rw-r--r--AUTHORS.rst1
-rw-r--r--configure.ac2
-rw-r--r--lib/timeval.c6
3 files changed, 5 insertions, 4 deletions
diff --git a/AUTHORS.rst b/AUTHORS.rst
index 7ec4f3425..ea4912f20 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -246,6 +246,7 @@ Raymond Burkholder ray@oneunified.net
Reid Price reid@nicira.com
Remko Tronçon git@el-tramo.be
Rich Lane rlane@bigswitch.com
+Richard Oliver richard@richard-oliver.co.uk
Rishi Bamba rishi.bamba@tcs.com
Rob Adams readams@readams.net
Robert Åkerblom-Andersson Robert.nr1@gmail.com
diff --git a/configure.ac b/configure.ac
index 330ecdf59..3ebb0a271 100644
--- a/configure.ac
+++ b/configure.ac
@@ -106,7 +106,7 @@ AC_CHECK_DECLS([sys_siglist], [], [], [[#include <signal.h>]])
AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec, struct stat.st_mtimensec],
[], [], [[#include <sys/stat.h>]])
AC_CHECK_MEMBERS([struct ifreq.ifr_flagshigh], [], [], [[#include <net/if.h>]])
-AC_CHECK_FUNCS([mlockall strnlen getloadavg statvfs getmntent_r])
+AC_CHECK_FUNCS([mlockall strnlen getloadavg statvfs getmntent_r clock_gettime])
AC_CHECK_HEADERS([mntent.h sys/statvfs.h linux/types.h linux/if_ether.h stdatomic.h])
AC_CHECK_HEADERS([net/if_mib.h], [], [], [[#include <sys/types.h>
#include <net/if.h>]])
diff --git a/lib/timeval.c b/lib/timeval.c
index dd63f0322..05a205d42 100644
--- a/lib/timeval.c
+++ b/lib/timeval.c
@@ -41,7 +41,7 @@
VLOG_DEFINE_THIS_MODULE(timeval);
-#if defined(_WIN32) || defined(__MACH__)
+#if !defined(HAVE_CLOCK_GETTIME)
typedef unsigned int clockid_t;
static int clock_gettime(clock_t id, struct timespec *ts);
@@ -52,7 +52,7 @@ static int clock_gettime(clock_t id, struct timespec *ts);
#ifndef CLOCK_REALTIME
#define CLOCK_REALTIME 2
#endif
-#endif /* defined(_WIN32) || defined(__MACH__) */
+#endif /* !defined(HAVE_CLOCK_GETTIME) */
#ifdef _WIN32
/* Number of 100 ns intervals from January 1, 1601 till January 1, 1970. */
@@ -420,7 +420,7 @@ clock_gettime(clock_t id, struct timespec *ts)
}
#endif /* _WIN32 */
-#ifdef __MACH__
+#if defined(__MACH__) && !defined(HAVE_CLOCK_GETTIME)
#include <mach/clock.h>
#include <mach/mach.h>
static int