qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] PATCH: enable -clock dynticks for non-linux hosts
@ 2008-12-20 23:55 Juergen Lock
  2009-01-07 17:59 ` Anthony Liguori
  0 siblings, 1 reply; 3+ messages in thread
From: Juergen Lock @ 2008-12-20 23:55 UTC (permalink / raw)
  To: qemu-devel

This does a configure check for posix timers instead of only enabling
them on linux (and w32) hosts, so that -clock dynticks also works on
FreeBSD >= 7.0 (and possibly others.)

Index: qemu/configure
@@ -1025,11 +1025,26 @@
   rt=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 2> /dev/null ; then
+  posixtimer=yes
+elif $cc $ARCH_CFLAGS -o $TMPE $TMPC -lrt 2> /dev/null ; then
+  posixtimer=yes
+  rt=yes
+fi
+
 if test "$rt" = "yes" ; then
   # Hack, we should have a general purpose LIBS for this sort of thing
   AIOLIBS="$AIOLIBS -lrt"
 fi
 
+
 if test "$mingw32" = "yes" ; then
   if test -z "$prefix" ; then
       prefix="c:\\\\Program Files\\\\Qemu"
@@ -1403,6 +1418,9 @@
   echo "#define HAVE_FDT 1" >> $config_h
   echo "FDT_LIBS=-lfdt" >> $config_mak
 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)
 {

Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] PATCH: enable -clock dynticks for non-linux hosts
  2008-12-20 23:55 [Qemu-devel] PATCH: enable -clock dynticks for non-linux hosts Juergen Lock
@ 2009-01-07 17:59 ` Anthony Liguori
  2009-01-18 23:30   ` Juergen Lock
  0 siblings, 1 reply; 3+ messages in thread
From: Anthony Liguori @ 2009-01-07 17:59 UTC (permalink / raw)
  To: qemu-devel

Juergen Lock wrote:
> This does a configure check for posix timers instead of only enabling
> them on linux (and w32) hosts, so that -clock dynticks also works on
> FreeBSD >= 7.0 (and possibly others.)
>
> Index: qemu/configure
> @@ -1025,11 +1025,26 @@
>    rt=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 2> /dev/null ; then
> +  posixtimer=yes
> +elif $cc $ARCH_CFLAGS -o $TMPE $TMPC -lrt 2> /dev/null ; then
> +  posixtimer=yes
> +  rt=yes
> +fi
> +
>  if test "$rt" = "yes" ; then
>    # Hack, we should have a general purpose LIBS for this sort of thing
>    AIOLIBS="$AIOLIBS -lrt"
>  fi
>   

Can you add a proper POSIXTIMERLIBS or something like that instead of 
doing the silliness with AIOLIBS?

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] PATCH: enable -clock dynticks for non-linux hosts
  2009-01-07 17:59 ` Anthony Liguori
@ 2009-01-18 23:30   ` Juergen Lock
  0 siblings, 0 replies; 3+ messages in thread
From: Juergen Lock @ 2009-01-18 23:30 UTC (permalink / raw)
  To: anthony; +Cc: qemu-devel

In article <4964ED91.5090906@codemonkey.ws> you write:
>Juergen Lock wrote:
>> This does a configure check for posix timers instead of only enabling
>> them on linux (and w32) hosts, so that -clock dynticks also works on
>> FreeBSD >= 7.0 (and possibly others.)
>>
>> Index: qemu/configure
>> @@ -1025,11 +1025,26 @@
>>    rt=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 2> /dev/null ; then
>> +  posixtimer=yes
>> +elif $cc $ARCH_CFLAGS -o $TMPE $TMPC -lrt 2> /dev/null ; then
>> +  posixtimer=yes
>> +  rt=yes
>> +fi
>> +
>>  if test "$rt" = "yes" ; then
>>    # Hack, we should have a general purpose LIBS for this sort of thing
>>    AIOLIBS="$AIOLIBS -lrt"
>>  fi
>>   
>
>Can you add a proper POSIXTIMERLIBS or something like that instead of 
>doing the silliness with AIOLIBS?

Actually that code was already in there from the `Do we need librt' check
above it, posix timers only add another reason that -lrt might be needed.
So maybe we want RTLIBS instead?

 Or at least I don't think we want to end up linking -lrt twice...

 (...I want my bikeshed blue :)
	Juergen

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-01-18 23:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-20 23:55 [Qemu-devel] PATCH: enable -clock dynticks for non-linux hosts Juergen Lock
2009-01-07 17:59 ` Anthony Liguori
2009-01-18 23:30   ` Juergen Lock

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).