mirror of https://gitee.com/openkylin/libvirt.git
tests: eventtest: fix build on macOS
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
This commit is contained in:
parent
0d1c147f60
commit
a42342912b
|
@ -2524,6 +2524,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])
|
||||
|
|
|
@ -26,6 +26,11 @@
|
|||
#include <signal.h>
|
||||
#include <time.h>
|
||||
|
||||
#if HAVE_MACH_CLOCK_ROUTINES
|
||||
# include <mach/clock.h>
|
||||
# include <mach/mach.h>
|
||||
#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)
|
||||
|
|
Loading…
Reference in New Issue