[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-stable] [Qemu-devel] [PATCH for-1.6] qemu-timer: fix get_clock
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-stable] [Qemu-devel] [PATCH for-1.6] qemu-timer: fix get_clock() gettimeofday() fallback #ifdef |
Date: |
Wed, 7 Aug 2013 09:53:16 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Tue, Aug 06, 2013 at 08:26:16PM -0400, Brad Smith wrote:
> On 06/08/13 7:48 AM, Stefan Hajnoczi wrote:
> >If CLOCK_MONOTONIC is not defined by system headers we use
> >gettimeofday(2). Apparently this is not used very often since no one
> >noticed the #ifdef was actually broken and left the function definition
> >unterminated.
>
> Can you show what this supposedly fixes? This code built just fine on
> OpenBSD before d05ef160453e98546a4197496dc8a3cb2defac53.
Hi Brad, thanks for pointing this out. I misread the code:
static inline int64_t get_clock(void)
{
#ifdef CLOCK_MONOTONIC
if (use_rt_clock) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ts.tv_sec * 1000000000LL + ts.tv_nsec;
} else
#endif <--- thought this was #else
{
/* XXX: using gettimeofday leads to problems if the date
changes, so it should be avoided. */
return get_clock_realtime();
}
}
#endif <--- this is actually for #ifdef _WIN32
So I thought the function definition would not be terminated properly. But
after you mentioned it, my change makes no sense.
Dropping this patch.
Thanks,
Stefan