aboutsummaryrefslogtreecommitdiff
path: root/slirp
diff options
context:
space:
mode:
authorEd Swierk <eswierk@aristanetworks.com>2009-07-23 14:13:34 -0700
committerAnthony Liguori <aliguori@us.ibm.com>2009-07-29 11:38:07 -0500
commitf833ef2133d8f80bc236e98467d6baf43b377a8c (patch)
tree6df5077da786f42581139728fcacd5d26ff9add6 /slirp
parent8568d307a7db11a176a5b97270cc905a20feafa3 (diff)
slirp: Use monotonic clock if available (v2)
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. Also remove some useless macros. Signed-off-by: Ed Swierk <eswierk@aristanetworks.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'slirp')
-rw-r--r--slirp/slirp.c27
-rw-r--r--slirp/slirp.h4
-rw-r--r--slirp/slirp_config.h3
3 files changed, 2 insertions, 32 deletions
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 9be8553130..e883f8263d 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"
@@ -244,29 +245,6 @@ void slirp_cleanup(Slirp *slirp)
#define CONN_CANFRCV(so) (((so)->so_state & (SS_FCANTRCVMORE|SS_ISFCONNECTED)) == SS_ISFCONNECTED)
#define UPD_NFDS(x) if (nfds < (x)) nfds = (x)
-/*
- * curtime kept to an accuracy of 1ms
- */
-#ifdef _WIN32
-static void updtime(void)
-{
- struct _timeb tb;
-
- _ftime(&tb);
-
- curtime = tb.time * 1000 + tb.millitm;
-}
-#else
-static void updtime(void)
-{
- struct timeval tv;
-
- gettimeofday(&tv, NULL);
-
- curtime = tv.tv_sec * 1000 + tv.tv_usec / 1000;
-}
-#endif
-
void slirp_select_fill(int *pnfds,
fd_set *readfds, fd_set *writefds, fd_set *xfds)
{
@@ -405,8 +383,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds,
global_writefds = writefds;
global_xfds = xfds;
- /* Update time */
- updtime();
+ curtime = qemu_get_clock(rt_clock);
TAILQ_FOREACH(slirp, &slirp_instances, entry) {
/*
diff --git a/slirp/slirp.h b/slirp/slirp.h
index 22058cd05e..020412caf3 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -108,10 +108,6 @@ typedef unsigned char u_int8_t;
#include <arpa/inet.h>
#endif
-#ifdef GETTIMEOFDAY_ONE_ARG
-#define gettimeofday(x, y) gettimeofday(x)
-#endif
-
/* Systems lacking strdup() definition in <string.h>. */
#if defined(ultrix)
char *strdup(const char *);
diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h
index dbc8dfd428..5a0e6c1137 100644
--- a/slirp/slirp_config.h
+++ b/slirp/slirp_config.h
@@ -190,9 +190,6 @@
#define NO_UNIX_SOCKETS
#endif
-/* Define if gettimeofday only takes one argument */
-#undef GETTIMEOFDAY_ONE_ARG
-
/* Define if you have revoke() */
#undef HAVE_REVOKE