From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=36413 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pyoee-0006WV-KO for qemu-devel@nongnu.org; Sun, 13 Mar 2011 13:00:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pyoec-0002jc-Te for qemu-devel@nongnu.org; Sun, 13 Mar 2011 13:00:32 -0400 Received: from moutng.kundenserver.de ([212.227.126.171]:51508) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pyoec-0002iN-Dg for qemu-devel@nongnu.org; Sun, 13 Mar 2011 13:00:30 -0400 Message-ID: <4D7CF828.6050608@mail.berlios.de> Date: Sun, 13 Mar 2011 18:00:24 +0100 From: Stefan Weil MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] win32: implement missing timersub References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: qemu-devel Am 13.03.2011 15:49, schrieb Blue Swirl: > Implement and wrap timersub() for Win32. > > Signed-off-by: Blue Swirl > --- > osdep.h | 19 +++++++++++++++++-- > ui/vnc.c | 6 +++--- > 2 files changed, 20 insertions(+), 5 deletions(-) > > diff --git a/osdep.h b/osdep.h > index 27eedcf..8c45000 100644 > --- a/osdep.h > +++ b/osdep.h > @@ -8,9 +8,7 @@ > #include > #endif > > -#ifndef _WIN32 > #include > -#endif > > #ifndef glue > #define xglue(x, y) x ## y > @@ -131,4 +129,21 @@ int qemu_madvise(void *addr, size_t len, int advice); > > int qemu_create_pidfile(const char *filename); > > +#ifdef _WIN32 > +static inline void qemu_timersub(const struct timeval *val1, > + const struct timeval *val2, > + struct timeval *res) > +{ > + res->tv_sec = val1->tv_sec - val2->tv_sec; > + if (val1->tv_usec - val2->tv_usec < 0) { shorter: if (val1->tv_usec < val2->tv_usec) { > + res->tv_sec--; > + res->tv_usec = val1->tv_usec - val2->tv_usec + 1000 * 1000; > + } else { > + res->tv_usec = val1->tv_usec - val2->tv_usec; > + } > +} > +#else > +#define qemu_timersub timersub > +#endif > + > #endif > diff --git a/ui/vnc.c b/ui/vnc.c > index 34dc0cd..1b68965 100644 > --- a/ui/vnc.c > +++ b/ui/vnc.c > @@ -2302,7 +2302,7 @@ static int vnc_update_stats(VncDisplay *vd, > struct timeval * tv) > } > } > > - timersub(tv, &VNC_REFRESH_STATS, &res); > + qemu_timersub(tv, &VNC_REFRESH_STATS, &res); > > if (timercmp(&vd->guest.last_freq_check, &res, >)) { > return has_dirty; > @@ -2320,7 +2320,7 @@ static int vnc_update_stats(VncDisplay *vd, > struct timeval * tv) > } > > max = rect->times[(rect->idx + count - 1) % count]; > - timersub(tv, &max, &res); > + qemu_timersub(tv, &max, &res); > > if (timercmp(&res, &VNC_REFRESH_LOSSY, >)) { > rect->freq = 0; > @@ -2331,7 +2331,7 @@ static int vnc_update_stats(VncDisplay *vd, > struct timeval * tv) > > min = rect->times[rect->idx]; > max = rect->times[(rect->idx + count - 1) % count]; > - timersub(&max, &min, &res); > + qemu_timersub(&max, &min, &res); > > rect->freq = res.tv_sec + res.tv_usec / 1000000.; > rect->freq /= count; Acked-by: Stefan Weil