• R/O
  • SSH
  • HTTPS

avrdude: Commit


Commit MetaInfo

Revision1483 (tree)
Time2020-06-12 04:49:05
Authorgottfried

Log Message

fixed QueryPerformanceCounter

Change Summary

Incremental Difference

--- trunk/portable/msvc/unix2win.h (revision 1482)
+++ trunk/portable/msvc/unix2win.h (revision 1483)
@@ -5,7 +5,9 @@
55 #define NOMINMAX
66 #include <Windows.h>
77
8+#include <cstdint>
89
10+
911 //#include <winsock.h> // für struct timeval
1012 #include <winsock2.h> // für struct timeval
1113 #pragma comment(lib, "ws2_32.lib")
@@ -15,15 +17,26 @@
1517
1618 inline void usleep(int waitTime)
1719 {
18- LARGE_INTEGER time1, time2, freq;
20+ LARGE_INTEGER freq;
1921
20- QueryPerformanceCounter(&time1);
21- QueryPerformanceFrequency(&freq);
22+ if(QueryPerformanceFrequency(&freq))
23+ {
24+ LARGE_INTEGER time1, time2, countEnd;
25+ QueryPerformanceCounter(&time1);
26+ countEnd.QuadPart = time1.QuadPart + freq.QuadPart * waitTime / 1000000ll;
2227
23- do
28+ do
29+ {
30+ QueryPerformanceCounter(&time2);
31+ } while(time2.QuadPart < countEnd.QuadPart);
32+ }
33+ else
2434 {
25- QueryPerformanceCounter(&time2);
26- } while((time2.QuadPart - time1.QuadPart) < waitTime);
35+ uint32_t ms = waitTime / 1000;
36+ if(!ms)
37+ ms = 1;
38+ Sleep(ms);
39+ }
2740 }
2841
2942 #ifdef _MSC_VER
Show on old repository browser