From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MUeWP-0003LW-Az for qemu-devel@nongnu.org; Sat, 25 Jul 2009 06:30:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MUeWK-0003KU-ID for qemu-devel@nongnu.org; Sat, 25 Jul 2009 06:30:32 -0400 Received: from [199.232.76.173] (port=47219 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MUeWK-0003KR-CD for qemu-devel@nongnu.org; Sat, 25 Jul 2009 06:30:28 -0400 Received: from fmmailgate02.web.de ([217.72.192.227]:39225) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MUeWJ-0008Ij-II for qemu-devel@nongnu.org; Sat, 25 Jul 2009 06:30:28 -0400 Message-ID: <4A6ADEC1.4090200@web.de> Date: Sat, 25 Jul 2009 12:30:25 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <1248383614.14831.40.camel@localhost.localdomain> In-Reply-To: <1248383614.14831.40.camel@localhost.localdomain> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig3583E64B8C09931BD580CB6C" Sender: jan.kiszka@web.de Subject: [Qemu-devel] Re: [PATCH] slirp: Use monotonic clock if available (v2) List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ed Swierk Cc: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig3583E64B8C09931BD580CB6C Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Ed Swierk wrote: > Calling gettimeofday() to compute a time interval can cause problems if= > the system clock jumps forwards or backwards; replace updtime() with > qemu_get_clock(rt_clock), which calls clock_gettime(CLOCK_MONOTONIC) if= > it is available. >=20 > Also remove some useless macros. >=20 > Signed-off-by: Ed Swierk >=20 Nice fix & cleanup. Acked-by: Jan Kiszka > --- > diff --git a/slirp/slirp.c b/slirp/slirp.c > index c68c6ab..3798780 100644 > --- a/slirp/slirp.c > +++ b/slirp/slirp.c > @@ -22,6 +22,7 @@ > * THE SOFTWARE. > */ > #include "qemu-common.h" > +#include "qemu-timer.h" > #include "qemu-char.h" > #include "slirp.h" > #include "hw/hw.h" > @@ -238,29 +239,6 @@ void slirp_cleanup(Slirp *slirp) > #define CONN_CANFRCV(so) (((so)->so_state & (SS_FCANTRCVMORE|SS_ISFCON= NECTED)) =3D=3D SS_ISFCONNECTED) > #define UPD_NFDS(x) if (nfds < (x)) nfds =3D (x) > =20 > -/* > - * curtime kept to an accuracy of 1ms > - */ > -#ifdef _WIN32 > -static void updtime(void) > -{ > - struct _timeb tb; > - > - _ftime(&tb); > - > - curtime =3D tb.time * 1000 + tb.millitm; > -} > -#else > -static void updtime(void) > -{ > - struct timeval tv; > - > - gettimeofday(&tv, NULL); > - > - curtime =3D tv.tv_sec * 1000 + tv.tv_usec / 1000; > -} > -#endif > - > void slirp_select_fill(int *pnfds, > fd_set *readfds, fd_set *writefds, fd_set *xfds= ) > { > @@ -399,8 +377,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *wri= tefds, fd_set *xfds, > global_writefds =3D writefds; > global_xfds =3D xfds; > =20 > - /* Update time */ > - updtime(); > + curtime =3D qemu_get_clock(rt_clock); > =20 > TAILQ_FOREACH(slirp, &slirp_instances, entry) { > /* > diff --git a/slirp/slirp.h b/slirp/slirp.h > index 22058cd..020412c 100644 > --- a/slirp/slirp.h > +++ b/slirp/slirp.h > @@ -108,10 +108,6 @@ typedef unsigned char u_int8_t; > #include > #endif > =20 > -#ifdef GETTIMEOFDAY_ONE_ARG > -#define gettimeofday(x, y) gettimeofday(x) > -#endif > - > /* Systems lacking strdup() definition in . */ > #if defined(ultrix) > char *strdup(const char *); > diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h > index ebaa99c..e977e77 100644 > --- a/slirp/slirp_config.h > +++ b/slirp/slirp_config.h > @@ -187,9 +187,6 @@ > #define NO_UNIX_SOCKETS > #endif > =20 > -/* Define if gettimeofday only takes one argument */ > -#undef GETTIMEOFDAY_ONE_ARG > - > /* Define if you have revoke() */ > #undef HAVE_REVOKE > =20 --------------enig3583E64B8C09931BD580CB6C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkpq3sEACgkQniDOoMHTA+lx+ACdGyzT0Iq00wxPvK0U/M+JpRBX EmYAnjMNFawnXkHVnkmjcNeXbrwDuCKx =bCRW -----END PGP SIGNATURE----- --------------enig3583E64B8C09931BD580CB6C--