@@ -91,14 +91,12 @@ var (
91
91
_GetStdHandle ,
92
92
_GetSystemDirectoryA ,
93
93
_GetSystemInfo ,
94
- _GetSystemTimeAsFileTime ,
95
94
_GetThreadContext ,
96
95
_SetThreadContext ,
97
96
_LoadLibraryExW ,
98
97
_LoadLibraryW ,
99
98
_PostQueuedCompletionStatus ,
100
99
_QueryPerformanceCounter ,
101
- _QueryPerformanceFrequency ,
102
100
_RaiseFailFastException ,
103
101
_ResumeThread ,
104
102
_SetConsoleCtrlHandler ,
@@ -300,11 +298,6 @@ func loadOptionalSyscalls() {
300
298
if _WSAGetOverlappedResult == nil {
301
299
throw ("WSAGetOverlappedResult not found" )
302
300
}
303
-
304
- if windowsFindfunc (n32 , []byte ("wine_get_version\000 " )) != nil {
305
- // running on Wine
306
- initWine (k32 )
307
- }
308
301
}
309
302
310
303
func monitorSuspendResume () {
@@ -548,77 +541,6 @@ func osinit() {
548
541
stdcall2 (_SetProcessPriorityBoost , currentProcess , 1 )
549
542
}
550
543
551
- // useQPCTime controls whether time.now and nanotime use QueryPerformanceCounter.
552
- // This is only set to 1 when running under Wine.
553
- var useQPCTime uint8
554
-
555
- var qpcStartCounter int64
556
- var qpcMultiplier int64
557
-
558
- //go:nosplit
559
- func nanotimeQPC () int64 {
560
- var counter int64 = 0
561
- stdcall1 (_QueryPerformanceCounter , uintptr (unsafe .Pointer (& counter )))
562
-
563
- // returns number of nanoseconds
564
- return (counter - qpcStartCounter ) * qpcMultiplier
565
- }
566
-
567
- //go:nosplit
568
- func nowQPC () (sec int64 , nsec int32 , mono int64 ) {
569
- var ft int64
570
- stdcall1 (_GetSystemTimeAsFileTime , uintptr (unsafe .Pointer (& ft )))
571
-
572
- t := (ft - 116444736000000000 ) * 100
573
-
574
- sec = t / 1000000000
575
- nsec = int32 (t - sec * 1000000000 )
576
-
577
- mono = nanotimeQPC ()
578
- return
579
- }
580
-
581
- func initWine (k32 uintptr ) {
582
- _GetSystemTimeAsFileTime = windowsFindfunc (k32 , []byte ("GetSystemTimeAsFileTime\000 " ))
583
- if _GetSystemTimeAsFileTime == nil {
584
- throw ("could not find GetSystemTimeAsFileTime() syscall" )
585
- }
586
-
587
- _QueryPerformanceCounter = windowsFindfunc (k32 , []byte ("QueryPerformanceCounter\000 " ))
588
- _QueryPerformanceFrequency = windowsFindfunc (k32 , []byte ("QueryPerformanceFrequency\000 " ))
589
- if _QueryPerformanceCounter == nil || _QueryPerformanceFrequency == nil {
590
- throw ("could not find QPC syscalls" )
591
- }
592
-
593
- // We can not simply fallback to GetSystemTimeAsFileTime() syscall, since its time is not monotonic,
594
- // instead we use QueryPerformanceCounter family of syscalls to implement monotonic timer
595
- // https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx
596
-
597
- var tmp int64
598
- stdcall1 (_QueryPerformanceFrequency , uintptr (unsafe .Pointer (& tmp )))
599
- if tmp == 0 {
600
- throw ("QueryPerformanceFrequency syscall returned zero, running on unsupported hardware" )
601
- }
602
-
603
- // This should not overflow, it is a number of ticks of the performance counter per second,
604
- // its resolution is at most 10 per usecond (on Wine, even smaller on real hardware), so it will be at most 10 millions here,
605
- // panic if overflows.
606
- if tmp > (1 << 31 - 1 ) {
607
- throw ("QueryPerformanceFrequency overflow 32 bit divider, check nosplit discussion to proceed" )
608
- }
609
- qpcFrequency := int32 (tmp )
610
- stdcall1 (_QueryPerformanceCounter , uintptr (unsafe .Pointer (& qpcStartCounter )))
611
-
612
- // Since we are supposed to run this time calls only on Wine, it does not lose precision,
613
- // since Wine's timer is kind of emulated at 10 Mhz, so it will be a nice round multiplier of 100
614
- // but for general purpose system (like 3.3 Mhz timer on i7) it will not be very precise.
615
- // We have to do it this way (or similar), since multiplying QPC counter by 100 millions overflows
616
- // int64 and resulted time will always be invalid.
617
- qpcMultiplier = int64 (timediv (1000000000 , qpcFrequency , nil ))
618
-
619
- useQPCTime = 1
620
- }
621
-
622
544
//go:nosplit
623
545
func getRandomData (r []byte ) {
624
546
n := 0
0 commit comments