qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: malc <av1474@comtv.ru>
To: Ed Swierk <eswierk@aristanetworks.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] slirp: Use monotonic clock if available
Date: Thu, 23 Jul 2009 03:38:13 +0400 (MSD)	[thread overview]
Message-ID: <Pine.LNX.4.64.0907230330310.2198@linmac.oyster.ru> (raw)
In-Reply-To: <1248302945.14831.4.camel@localhost.localdomain>

On Wed, 22 Jul 2009, Ed Swierk wrote:

[..snip..]

> -static void updtime(void)
> -{
> +#ifdef CLOCK_MONOTONIC
> +    struct timespec tv;
> +
> +    clock_gettime(CLOCK_MONOTONIC, &tv);
> +
> +    curtime = tv.tv_sec * 1000 + tv.tv_nsec / 1000000;
> +#else
>      struct timeval tv;
>  
>      gettimeofday(&tv, NULL);
>  
>      curtime = tv.tv_sec * 1000 + tv.tv_usec / 1000;
> -}
>  #endif
> +#endif
> +}

This is wrong on many levels.

Suppose CLOCK_MONOTONIC(which is wrong _POSIX_MONOTONIC_CLOCK ought to
be checked) is defined and you compile your binary on, say, Linux 2.6
and then try to run it on 2.4 (without any fancy RHEL patches for
instance), things wouldn't work, what's worse they wouldn't work
silently, giving no indication what's wrong all because nobody checks
clock_gettime result for failures.

The CLOCK_MONOTONIC presence ought to be checked at runtime
(see sysconf(3) and _POSIX_MONOTONIC_CLOCK)

[..snip..]

-- 
mailto:av1474@comtv.ru

  reply	other threads:[~2009-07-22 23:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-22 22:49 [Qemu-devel] [PATCH] slirp: Use monotonic clock if available Ed Swierk
2009-07-22 23:38 ` malc [this message]
2009-07-23  0:57   ` Ed Swierk
2009-07-23  6:40     ` [Qemu-devel] " Jan Kiszka

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=Pine.LNX.4.64.0907230330310.2198@linmac.oyster.ru \
    --to=av1474@comtv.ru \
    --cc=eswierk@aristanetworks.com \
    --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).