Here comes the dynticks patch (files/patch-dynticks), it assumes that
NetBSD either always has posix timers, or -lrt is not needed otherwise
there. (FreeBSD before 7.x doesn't have -lrt.)
--- qemu/Makefile.target.orig 2008-11-21 11:49:37.000000000 -0500
+++ qemu/Makefile.target 2008-12-03 15:46:24.000000000 -0500
@@ -598,7 +598,7 @@
OBJS+=block-raw-posix.o
endif
-LIBS+=-lz
+LIBS += $(RTLIBS) -lz
ifdef CONFIG_ALSA
LIBS += -lasound
endif
Index: qemu/configure
@@ -99,6 +99,7 @@
fmod_lib=""
fmod_inc=""
oss_lib=""
+rt_lib=""
vnc_tls="yes"
bsd="no"
linux="no"
@@ -157,13 +158,15 @@
if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
kqemu="yes"
fi
+rt_lib="-lrt"
;;
NetBSD)
bsd="yes"
audio_drv_list="oss"
audio_possible_drivers="oss sdl esd"
oss_lib="-lossaudio"
-aio_lib="-lrt -lpthread"
+aio_lib="-lpthread"
+rt_lib="-lrt"
;;
OpenBSD)
bsd="yes"
@@ -231,6 +234,7 @@
kqemu="yes"
audio_possible_drivers="$audio_possible_drivers fmod"
fi
+rt_lib="-lrt"
;;
esac
@@ -1053,6 +1057,20 @@
iovec=yes
fi
+##########################################
+# posix timer probe
+cat > $TMPC <<EOF
+#include <time.h>
+int main(void) { timer_create(CLOCK_REALTIME, (struct sigevent *)NULL,
(timer_t *)NULL); return 0; }
+EOF
+posixtimer=no
+if $cc $ARCH_CFLAGS -o $TMPE $TMPC $rt_lib 2> /dev/null ; then
+ posixtimer=yes
+else
+ rt_lib=""
+fi
+RTLIBS="$rt_lib"
+
# Check if tools are available to build documentation.
if [ "x$NOPORTDOCS" != "x" -o -x "`which texi2html 2>/dev/null`" ] && \
[ -x "`which pod2man 2>/dev/null`" ]; then
@@ -1174,6 +1192,7 @@
echo "LDFLAGS=$LDFLAGS" >> $config_mak
echo "EXESUF=$EXESUF" >> $config_mak
echo "AIOLIBS=$AIOLIBS" >> $config_mak
+echo "RTLIBS=$RTLIBS" >> $config_mak
case "$cpu" in
i386)
echo "ARCH=i386" >> $config_mak
@@ -1425,6 +1444,9 @@
if test "$iovec" = "yes" ; then
echo "#define HAVE_IOVEC 1" >> $config_h
fi
+if test "$posixtimer" = "yes" ; then
+ echo "#define HAVE_POSIX_TIMER 1" >> $config_h
+fi
# XXX: suppress that
if [ "$bsd" = "yes" ] ; then
Index: qemu/vl.c
@@ -918,12 +918,16 @@
static int unix_start_timer(struct qemu_alarm_timer *t);
static void unix_stop_timer(struct qemu_alarm_timer *t);
-#ifdef __linux__
+#ifdef HAVE_POSIX_TIMER
static int dynticks_start_timer(struct qemu_alarm_timer *t);
static void dynticks_stop_timer(struct qemu_alarm_timer *t);
static void dynticks_rearm_timer(struct qemu_alarm_timer *t);
+#endif
+
+#ifdef __linux__
+
static int hpet_start_timer(struct qemu_alarm_timer *t);
static void hpet_stop_timer(struct qemu_alarm_timer *t);
@@ -1001,9 +1005,11 @@
static struct qemu_alarm_timer alarm_timers[] = {
#ifndef _WIN32
-#ifdef __linux__
+#ifdef HAVE_POSIX_TIMER
{"dynticks", ALARM_FLAG_DYNTICKS, dynticks_start_timer,
dynticks_stop_timer, dynticks_rearm_timer, NULL},
+#endif
+#ifdef __linux__
/* HPET - if available - is preferred */
{"hpet", 0, hpet_start_timer, hpet_stop_timer, NULL, NULL},
/* ...otherwise try RTC */
@@ -1361,7 +1367,7 @@
return delta;
}
-#if defined(__linux__) || defined(_WIN32)
+#if defined(HAVE_POSIX_TIMER) || defined(_WIN32)
static uint64_t qemu_next_deadline_dyntick(void)
{
int64_t delta;
@@ -1506,6 +1512,10 @@
close(rtc_fd);
}
+#endif /* defined(__linux__) */
+
+#ifdef HAVE_POSIX_TIMER
+
static int dynticks_start_timer(struct qemu_alarm_timer *t)
{
struct sigevent ev;
@@ -1577,7 +1587,7 @@
}
}
-#endif /* defined(__linux__) */
+#endif /* defined(HAVE_POSIX_TIMER) */
static int unix_start_timer(struct qemu_alarm_timer *t)
{