@@ -43,32 +43,11 @@ void swift_get_time(
43
43
#elif defined(_WIN32)
44
44
// This needs to match what swift-corelibs-libdispatch does
45
45
46
- // QueryInterruptTimePrecise() was added in Windows 10 and is, as
47
- // the name suggests, more precise than QueryInterruptTime().
48
- // Unfortunately, the symbol is not listed in any .lib file in the SDK and
49
- // must be looked up dynamically at runtime even if our minimum deployment
50
- // target is Windows 10.
51
- typedef decltype (QueryInterruptTimePrecise) *QueryITP_FP;
52
- static QueryITP_FP queryITP = nullptr ;
53
- static swift::once_t onceToken;
54
- swift::once (onceToken, [] {
55
- if (HMODULE hKernelBase = GetModuleHandleW (L" KernelBase.dll" )) {
56
- queryITP = reinterpret_cast <QueryITP_FP>(
57
- GetProcAddress (hKernelBase, " QueryInterruptTimePrecise" )
58
- );
59
- }
60
- });
61
-
62
- // Call whichever API is available. Both output a value measured in 100ns
46
+ // QueryInterruptTimePrecise() outputs a value measured in 100ns
63
47
// units. We must divide the output by 10,000,000 to get a value in
64
48
// seconds and multiply the remainder by 100 to get nanoseconds.
65
49
ULONGLONG interruptTime;
66
- if (queryITP) {
67
- (* queryITP)(&interruptTime);
68
- } else {
69
- // Fall back to the older, less precise API.
70
- (void )QueryInterruptTime (&interruptTime);
71
- }
50
+ (void )QueryInterruptTimePrecise (&interruptTime);
72
51
continuous.tv_sec = interruptTime / 10'000'000 ;
73
52
continuous.tv_nsec = (interruptTime % 10'000'000 ) * 100 ;
74
53
#else
@@ -91,32 +70,11 @@ void swift_get_time(
91
70
#elif defined(_WIN32)
92
71
// This needs to match what swift-corelibs-libdispatch does
93
72
94
- // QueryUnbiasedInterruptTimePrecise() was added in Windows 10 and is, as
95
- // the name suggests, more precise than QueryUnbiasedInterruptTime().
96
- // Unfortunately, the symbol is not listed in any .lib file in the SDK and
97
- // must be looked up dynamically at runtime even if our minimum deployment
98
- // target is Windows 10.
99
- typedef decltype (QueryUnbiasedInterruptTimePrecise) *QueryUITP_FP;
100
- static QueryUITP_FP queryUITP = nullptr ;
101
- static swift::once_t onceToken;
102
- swift::once (onceToken, [] {
103
- if (HMODULE hKernelBase = GetModuleHandleW (L" KernelBase.dll" )) {
104
- queryUITP = reinterpret_cast <QueryUITP_FP>(
105
- GetProcAddress (hKernelBase, " QueryUnbiasedInterruptTimePrecise" )
106
- );
107
- }
108
- });
109
-
110
- // Call whichever API is available. Both output a value measured in 100ns
73
+ // QueryUnbiasedInterruptTimePrecise() outputs a value measured in 100ns
111
74
// units. We must divide the output by 10,000,000 to get a value in
112
75
// seconds and multiply the remainder by 100 to get nanoseconds.
113
76
ULONGLONG unbiasedTime;
114
- if (queryUITP) {
115
- (* queryUITP)(&unbiasedTime);
116
- } else {
117
- // Fall back to the older, less precise API.
118
- (void )QueryUnbiasedInterruptTime (&unbiasedTime);
119
- }
77
+ (void )QueryUnbiasedInterruptTimePrecise (&unbiasedTime);
120
78
suspending.tv_sec = unbiasedTime / 10'000'000 ;
121
79
suspending.tv_nsec = (unbiasedTime % 10'000'000 ) * 100 ;
122
80
#else
0 commit comments