qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Brad Smith <brad@comstyle.com>
Cc: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Add configure clock_gettime() monotonic time test
Date: Wed, 3 Apr 2013 16:00:51 -0400 (EDT)	[thread overview]
Message-ID: <561137880.56703.1365019251693.JavaMail.root@redhat.com> (raw)
In-Reply-To: <20130403192223.GC326@rox.home.comstyle.com>


> On Wed, Apr 03, 2013 at 10:18:51AM +0200, Paolo Bonzini wrote:
> > Il 03/04/2013 00:52, Peter Maydell ha scritto:
> > > On 2 April 2013 17:45, Paolo Bonzini <pbonzini@redhat.com> wrote:
> > >> Il 02/04/2013 17:42, Brad Smith ha scritto:
> > >>> Replace the hardcoded list of OS's utilizing clock_gettime() for
> > >>> monotonic
> > >>> time with a configure test. This is to fix the use of monotonic time on
> > >>> OpenBSD but allows for other POSIX compliant OS's such as NetBSD to
> > >>> also
> > >>> utilize clock_gettime().
> > >>
> > >> I thought the list of OSes was supposed to filter out those that somehow
> > >> had a broken CLOCK_MONOTONIC.
> > > 
> > > Judging from wading through git history, it's mostly just
> > > historic accretion from an initial #ifdef __linux__ which was
> > > put in by Fabrice way back when configure was barely doing
> > > compile-this-code checks at all.
> > > 
> > > Google does suggest that some OSes do provide a CLOCK_MONOTONIC
> > > but clock_gettime(CLOCK_MONOTONIC) always fails, eg Centos 3.
> > 
> > It would already fail, and no one reported it.
> > 
> > CentOS 3 has a 2.4 kernel.  I doubt anyone is using it with a recent QEMU.
> > 
> > Paolo
> > 
> > >> Otherwise, you might as well use "#ifdef CLOCK_MONOTONIC" and skip the
> > >> configure test completely.
> > > 
> > > Tempting.
> > > 
> > > -- PMM
> 
> Then how about the following? This looks like it should be good
> for Linux, *BSD's, Solaris.
> 
> 
> diff --git a/include/qemu/timer.h b/include/qemu/timer.h
> index 1766b2d..c363190 100644
> --- a/include/qemu/timer.h
> +++ b/include/qemu/timer.h
> @@ -117,8 +117,7 @@ extern int use_rt_clock;
>  
>  static inline int64_t get_clock(void)
>  {
> -#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >=
> 500000) \
> -    || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
> +#ifdef CLOCK_MONOTONIC
>      if (use_rt_clock) {
>          struct timespec ts;
>          clock_gettime(CLOCK_MONOTONIC, &ts);
> diff --git a/util/qemu-timer-common.c b/util/qemu-timer-common.c
> index 16f5e75..95e0847 100644
> --- a/util/qemu-timer-common.c
> +++ b/util/qemu-timer-common.c
> @@ -49,9 +49,7 @@ int use_rt_clock;
>  static void __attribute__((constructor)) init_get_clock(void)
>  {
>      use_rt_clock = 0;
> -#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >=
> 500000) \
> -    || defined(__DragonFly__) || defined(__FreeBSD_kernel__) \
> -    || defined(__OpenBSD__)
> +#ifdef CLOCK_MONOTONIC
>      {
>          struct timespec ts;
>          if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Paolo

  reply	other threads:[~2013-04-03 20:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-02 15:42 [Qemu-devel] [PATCH] Add configure clock_gettime() monotonic time test Brad Smith
2013-04-02 16:45 ` Paolo Bonzini
2013-04-02 22:28   ` Brad Smith
2013-04-02 22:52   ` Peter Maydell
2013-04-03  8:18     ` Paolo Bonzini
2013-04-03 19:22       ` Brad Smith
2013-04-03 20:00         ` Paolo Bonzini [this message]
2013-04-03 20:07         ` Brad Smith
2013-04-04 17:21         ` Brad Smith
2013-04-05  0:22           ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=561137880.56703.1365019251693.JavaMail.root@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=brad@comstyle.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).