]> git.proxmox.com Git - mirror_ovs.git/commitdiff
timeval: Check for OS-provided clock_gettime on macOS
authorRichard Oliver <richard@richard-oliver.co.uk>
Sat, 28 Oct 2017 15:38:30 +0000 (16:38 +0100)
committerBen Pfaff <blp@ovn.org>
Mon, 30 Oct 2017 16:56:27 +0000 (09:56 -0700)
[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: Ben Pfaff <blp@ovn.org>
AUTHORS.rst
configure.ac
lib/timeval.c

index 4a80802dd6259adf06c53e2c354b2ba792b22ee5..ff1cd370142d0c027e1642852cce61da196f6032 100644 (file)
@@ -263,6 +263,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
index 27425991aa68740292a2f38f8d99592f0c5f1df0..9e00818327a911e7f5a46b009d1f71dfd4c891f9 100644 (file)
@@ -112,7 +112,7 @@ AC_CHECK_MEMBERS([struct mmsghdr.msg_len], [], [], [[#include <sys/socket.h>]])
 AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id], [], [],
   [[#include <sys/socket.h>
 #include <netinet/in.h>]])
-AC_CHECK_FUNCS([mlockall strnlen getloadavg statvfs getmntent_r sendmmsg])
+AC_CHECK_FUNCS([mlockall strnlen getloadavg statvfs getmntent_r sendmmsg 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>]])
index b50ff85a5e534b69d47407007fbd678b7a0a5d04..b60bf306712f7b92c195c24b98ea78873b927a4f 100644 (file)
@@ -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. */
@@ -453,7 +453,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