diff --git a/configure.ac b/configure.ac index fd50ff80e2..342db894df 100644 --- a/configure.ac +++ b/configure.ac @@ -2524,6 +2524,15 @@ AC_CHECK_MEMBERS([struct if_data.ifi_oqdrops], [#include ]) +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 + #include + ]) + # Check if we need to look for ifconfig if test "$want_ifconfig" = "yes"; then AC_PATH_PROG([IFCONFIG_PATH], [ifconfig]) diff --git a/tests/eventtest.c b/tests/eventtest.c index 011bedc33f..03ab318472 100644 --- a/tests/eventtest.c +++ b/tests/eventtest.c @@ -26,6 +26,11 @@ #include #include +#if HAVE_MACH_CLOCK_ROUTINES +# include +# include +#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; +#else clock_gettime(CLOCK_REALTIME, &waitTime); +#endif waitTime.tv_sec += 5; rc = 0; while (!eventThreadJobDone && rc == 0)