On Sat, 2016-11-19 at 21:16 +0300, Roman Bogorodskiy wrote: > macOS doesn't support clock_gettime(2), at least versions prior 10.12 > (I didn't actually check 10.12 though). So, use its own routines in > eventtest. > > * configure.ac: check for requires symbols and define > HAVE_MACH_CLOCK_ROUTINES if found > * tests/eventtest.c: add clock_get_time() based implementation > * tests/Makefile.am: don't explicitly LDADD -lrt, use > $(LIB_CLOCK_GETTIME) > --- > configure.ac | 9 +++++++++ > tests/Makefile.am | 2 +- > tests/eventtest.c | 16 ++++++++++++++++ > 3 files changed, 26 insertions(+), 1 deletion(-) > > diff --git a/configure.ac b/configure.ac > index 66d88c4..c1b0ca0 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -2522,6 +2522,15 @@ AC_CHECK_MEMBERS([struct if_data.ifi_oqdrops], > [#include <net/if.h> > ]) > > +AC_CHECK_DECLS([clock_serv_t, host_get_clock_service, clock_get_time], > + [AC_DEFINE([HAVE_MACH_CLOCK_ROUTINES], > + [1], > + [whether Mach clock routines are available])], > + [], > + [#include <mach/clock.h> > + #include <mach/mach.h> > + ]) > + > # Check if we need to look for ifconfig > if test "$want_ifconfig" = "yes"; then > AC_PATH_PROG([IFCONFIG_PATH], [ifconfig]) > diff --git a/tests/Makefile.am b/tests/Makefile.am > index 924029a..6a24861 100644 > --- a/tests/Makefile.am > +++ b/tests/Makefile.am > @@ -1310,7 +1310,7 @@ endif WITH_DRIVER_MODULES > if WITH_LIBVIRTD > eventtest_SOURCES = \ > eventtest.c testutils.h testutils.c > -eventtest_LDADD = -lrt $(LDADDS) > +eventtest_LDADD = $(LIB_CLOCK_GETTIME) $(LDADDS) > endif WITH_LIBVIRTD This is really a separate bugfix, please move this hunk to its own commit. > libshunload_la_SOURCES = shunloadhelper.c > diff --git a/tests/eventtest.c b/tests/eventtest.c > index 011bedc..ed1089e 100644 > --- a/tests/eventtest.c > +++ b/tests/eventtest.c > @@ -26,6 +26,11 @@ > #include <signal.h> > #include <time.h> > > +#if HAVE_MACH_CLOCK_ROUTINES > +#include <mach/clock.h> > +#include <mach/mach.h> These two includes trip 'make syntax-check'. > +#endif > + > #include "testutils.h" > #include "internal.h" > #include "virfile.h" > @@ -262,7 +267,18 @@ finishJob(const char *name, int handle, int timer) > { > struct timespec waitTime; > int rc; > +#if HAVE_MACH_CLOCK_ROUTINES > + clock_serv_t cclock; > + mach_timespec_t mts; > + > + host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); > + clock_get_time(cclock, &mts); > + mach_port_deallocate(mach_task_self(), cclock); > + waitTime.tv_sec = mts.tv_sec; > + waitTime.tv_nsec = mts.tv_nsec; I'll assume the macOS code is doing what it's supposed to do, as I have no way of verifying that myself. It looks reasonable enough :) > +#else > clock_gettime(CLOCK_REALTIME, &waitTime); > +#endif > waitTime.tv_sec += 5; > rc = 0; > while (!eventThreadJobDone && rc == 0) ACK if you move the LIB_CLOCK_GETTIME fix to its own commit and tweak includes to make syntax-check happy. -- Andrea Bolognani / Red Hat / Virtualization -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list