Sync to Wine-20041201

Alexandre Julliard <julliard@winehq.org>
- Avoid using gettimeofday.

svn path=/trunk/; revision=11978
This commit is contained in:
Gé van Geldorp 2004-12-07 22:32:28 +00:00
parent d50ca5db0b
commit 223a2d7ff7
3 changed files with 17 additions and 127 deletions

View file

@ -7,19 +7,5 @@
*.map *.map
*.tmp *.tmp
Makefile.ros Makefile.ros
idb_hist_large.bmp icmp.spec.def
idb_hist_small.bmp icmp.stubs.c
idb_std_small.bmp
idb_std_large.bmp
idb_view_large.bmp
idb_view_small.bmp
idc_copy.cur
idc_divider.cur
idc_divideropen.cur
idc_movebutton.cur
idi_dragarrow.ico
idi_tt_error_sm.ico
idi_tt_info_sm.ico
idi_tt_warn_sm.ico
idt_check.bmp
comctl32.spec.def

View file

@ -135,34 +135,6 @@ static int in_cksum(u_short *addr, int len)
return(answer); return(answer);
} }
/* A private gettimeofday without the timezone parameter
* to support building on Windows as well as Unix.
*/
#ifndef __GNUC__
#define EPOCHFILETIME (116444736000000000i64)
#else
#define EPOCHFILETIME (116444736000000000LL)
#endif
static int icmp_gettimeofday(struct timeval *tv)
{
FILETIME ft;
LARGE_INTEGER li;
__int64 t;
GetSystemTimeAsFileTime(&ft);
li.LowPart = ft.dwLowDateTime;
li.HighPart = ft.dwHighDateTime;
t = li.QuadPart; /* In 100-nanosecond intervals */
t -= EPOCHFILETIME; /* Offset to the Epoch time */
t /= 10; /* In microseconds */
tv->tv_sec = (long)(t / 1000000);
tv->tv_usec = (long)(t % 1000000);
return 0;
}
/* /*
* Exported Routines. * Exported Routines.
*/ */
@ -235,7 +207,8 @@ DWORD WINAPI IcmpSendEcho(
int ip_header_len; int ip_header_len;
int maxlen; int maxlen;
fd_set fdr; fd_set fdr;
struct timeval timeout,send_time,recv_time; struct timeval timeout;
DWORD send_time,recv_time;
struct sockaddr_in addr; struct sockaddr_in addr;
int addrlen; int addrlen;
unsigned short id,seq,cksum; unsigned short id,seq,cksum;
@ -338,7 +311,7 @@ DWORD WINAPI IcmpSendEcho(
} }
#endif #endif
icmp_gettimeofday(&send_time); send_time = GetTickCount();
res=sendto(icp->sid, reqbuf, reqsize, 0, (struct sockaddr*)&addr, sizeof(addr)); res=sendto(icp->sid, reqbuf, reqsize, 0, (struct sockaddr*)&addr, sizeof(addr));
HeapFree(GetProcessHeap (), 0, reqbuf); HeapFree(GetProcessHeap (), 0, reqbuf);
if (res<0) { if (res<0) {
@ -363,7 +336,7 @@ DWORD WINAPI IcmpSendEcho(
/* Get the reply */ /* Get the reply */
ip_header_len=0; /* because gcc was complaining */ ip_header_len=0; /* because gcc was complaining */
while ((res=select(icp->sid+1,&fdr,NULL,NULL,&timeout))>0) { while ((res=select(icp->sid+1,&fdr,NULL,NULL,&timeout))>0) {
icmp_gettimeofday(&recv_time); recv_time = GetTickCount();
res=recvfrom(icp->sid, (char*)ip_header, maxlen, 0, (struct sockaddr*)&addr,&addrlen); res=recvfrom(icp->sid, (char*)ip_header, maxlen, 0, (struct sockaddr*)&addr,&addrlen);
TRACE("received %d bytes from %s\n",res, inet_ntoa(addr.sin_addr)); TRACE("received %d bytes from %s\n",res, inet_ntoa(addr.sin_addr));
ier->Status=IP_REQ_TIMED_OUT; ier->Status=IP_REQ_TIMED_OUT;
@ -457,18 +430,16 @@ DWORD WINAPI IcmpSendEcho(
* Decrease the timeout so that we don't enter an endless loop even * Decrease the timeout so that we don't enter an endless loop even
* if we get flooded with ICMP packets that are not for us. * if we get flooded with ICMP packets that are not for us.
*/ */
timeout.tv_sec=Timeout/1000-(recv_time.tv_sec-send_time.tv_sec); int t = Timeout - (recv_time - send_time);
timeout.tv_usec=(Timeout % 1000)*1000+send_time.tv_usec-(recv_time.tv_usec-send_time.tv_usec); if (t < 0) t = 0;
if (timeout.tv_usec<0) { timeout.tv_sec = t / 1000;
timeout.tv_usec+=1000000; timeout.tv_usec = (t % 1000) * 1000;
timeout.tv_sec--;
}
continue; continue;
} else { } else {
/* This is a reply to our packet */ /* This is a reply to our packet */
memcpy(&ier->Address,&ip_header->ip_src,sizeof(IPAddr)); memcpy(&ier->Address,&ip_header->ip_src,sizeof(IPAddr));
/* Status is already set */ /* Status is already set */
ier->RoundTripTime=(recv_time.tv_sec-send_time.tv_sec)*1000+(recv_time.tv_usec-send_time.tv_usec)/1000; ier->RoundTripTime= recv_time - send_time;
ier->DataSize=res-ip_header_len-ICMP_MINLEN; ier->DataSize=res-ip_header_len-ICMP_MINLEN;
ier->Reserved=0; ier->Reserved=0;
ier->Data=endbuf-ier->DataSize; ier->Data=endbuf-ier->DataSize;

View file

@ -1,10 +1,10 @@
Index: dlls/icmp/Makefile.in Index: Makefile.in
=================================================================== ===================================================================
RCS file: /home/wine/wine/dlls/icmp/Makefile.in,v RCS file: /home/wine/wine/dlls/icmp/Makefile.in,v
retrieving revision 1.13 retrieving revision 1.13
diff -u -r1.13 Makefile.in diff -u -r1.13 Makefile.in
--- dlls/icmp/Makefile.in 11 Oct 2003 01:09:19 -0000 1.13 --- Makefile.in 11 Oct 2003 01:09:19 -0000 1.13
+++ dlls/icmp/Makefile.in 23 Sep 2004 02:56:40 -0000 +++ Makefile.in 7 Dec 2004 22:39:27 -0000
@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
VPATH = @srcdir@ VPATH = @srcdir@
MODULE = icmp.dll MODULE = icmp.dll
@ -13,80 +13,13 @@ diff -u -r1.13 Makefile.in
C_SRCS = icmp_main.c C_SRCS = icmp_main.c
Index: dlls/icmp/icmp_main.c Index: ip.h
===================================================================
RCS file: /home/wine/wine/dlls/icmp/icmp_main.c,v
retrieving revision 1.26
diff -u -r1.26 icmp_main.c
--- dlls/icmp/icmp_main.c 12 Apr 2004 23:15:12 -0000 1.26
+++ dlls/icmp/icmp_main.c 23 Sep 2004 03:53:26 -0000
@@ -95,7 +95,6 @@
#include "ip.h"
#include "ip_icmp.h"
-
WINE_DEFAULT_DEBUG_CHANNEL(icmp);
@@ -136,7 +135,33 @@
return(answer);
}
+/* A private gettimeofday without the timezone parameter
+ * to support building on Windows as well as Unix.
+ */
+
+#ifndef __GNUC__
+#define EPOCHFILETIME (116444736000000000i64)
+#else
+#define EPOCHFILETIME (116444736000000000LL)
+#endif
+static int icmp_gettimeofday(struct timeval *tv)
+{
+ FILETIME ft;
+ LARGE_INTEGER li;
+ __int64 t;
+
+ GetSystemTimeAsFileTime(&ft);
+ li.LowPart = ft.dwLowDateTime;
+ li.HighPart = ft.dwHighDateTime;
+ t = li.QuadPart; /* In 100-nanosecond intervals */
+ t -= EPOCHFILETIME; /* Offset to the Epoch time */
+ t /= 10; /* In microseconds */
+ tv->tv_sec = (long)(t / 1000000);
+ tv->tv_usec = (long)(t % 1000000);
+
+ return 0;
+}
/*
* Exported Routines.
@@ -313,7 +338,7 @@
}
#endif
- gettimeofday(&send_time,NULL);
+ icmp_gettimeofday(&send_time);
res=sendto(icp->sid, reqbuf, reqsize, 0, (struct sockaddr*)&addr, sizeof(addr));
HeapFree(GetProcessHeap (), 0, reqbuf);
if (res<0) {
@@ -338,7 +363,7 @@
/* Get the reply */
ip_header_len=0; /* because gcc was complaining */
while ((res=select(icp->sid+1,&fdr,NULL,NULL,&timeout))>0) {
- gettimeofday(&recv_time,NULL);
+ icmp_gettimeofday(&recv_time);
res=recvfrom(icp->sid, (char*)ip_header, maxlen, 0, (struct sockaddr*)&addr,&addrlen);
TRACE("received %d bytes from %s\n",res, inet_ntoa(addr.sin_addr));
ier->Status=IP_REQ_TIMED_OUT;
Index: dlls/icmp/ip.h
=================================================================== ===================================================================
RCS file: /home/wine/wine/dlls/icmp/ip.h,v RCS file: /home/wine/wine/dlls/icmp/ip.h,v
retrieving revision 1.3 retrieving revision 1.3
diff -u -r1.3 ip.h diff -u -r1.3 ip.h
--- dlls/icmp/ip.h 6 Jan 2004 22:08:34 -0000 1.3 --- ip.h 6 Jan 2004 22:08:34 -0000 1.3
+++ dlls/icmp/ip.h 23 Sep 2004 03:43:22 -0000 +++ ip.h 7 Dec 2004 22:39:27 -0000
@@ -39,6 +39,21 @@ @@ -39,6 +39,21 @@
*/ */
#define IPVERSION 4 #define IPVERSION 4