@@ -267,6 +267,20 @@ win32_compute_revents_socket (SOCKET h, int sought, long lNetworkEvents)
267
267
return happened ;
268
268
}
269
269
270
+ #include <windows.h>
271
+ #include "compat/win32/lazyload.h"
272
+
273
+ static ULONGLONG CompatGetTickCount64 (void )
274
+ {
275
+ DECLARE_PROC_ADDR (kernel32 .dll , ULONGLONG , GetTickCount64 , void );
276
+
277
+ if (!INIT_PROC_ADDR (GetTickCount64 ))
278
+ return (ULONGLONG )GetTickCount ();
279
+
280
+ return GetTickCount64 ();
281
+ }
282
+ #define GetTickCount64 CompatGetTickCount64
283
+
270
284
#else /* !MinGW */
271
285
272
286
/* Convert select(2) returned fd_sets into poll(2) revents values. */
@@ -450,7 +464,8 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
450
464
static HANDLE hEvent ;
451
465
WSANETWORKEVENTS ev ;
452
466
HANDLE h , handle_array [FD_SETSIZE + 2 ];
453
- DWORD ret , wait_timeout , nhandles , start = 0 , elapsed , orig_timeout = 0 ;
467
+ DWORD ret , wait_timeout , nhandles , elapsed , orig_timeout = 0 ;
468
+ ULONGLONG start = 0 ;
454
469
fd_set rfds , wfds , xfds ;
455
470
BOOL poll_again ;
456
471
MSG msg ;
@@ -466,7 +481,7 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
466
481
if (timeout != INFTIM )
467
482
{
468
483
orig_timeout = timeout ;
469
- start = GetTickCount ();
484
+ start = GetTickCount64 ();
470
485
}
471
486
472
487
if (!hEvent )
@@ -615,7 +630,7 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
615
630
616
631
if (!rc && orig_timeout && timeout != INFTIM )
617
632
{
618
- elapsed = GetTickCount () - start ;
633
+ elapsed = ( DWORD )( GetTickCount64 () - start ) ;
619
634
timeout = elapsed >= orig_timeout ? 0 : orig_timeout - elapsed ;
620
635
}
621
636
0 commit comments