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