@@ -43,32 +43,11 @@ void swift_get_time(
4343#elif defined(_WIN32)
4444 // This needs to match what swift-corelibs-libdispatch does
4545
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
6347 // units. We must divide the output by 10,000,000 to get a value in
6448 // seconds and multiply the remainder by 100 to get nanoseconds.
6549 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);
7251 continuous.tv_sec = interruptTime / 10'000'000 ;
7352 continuous.tv_nsec = (interruptTime % 10'000'000 ) * 100 ;
7453#else
@@ -91,32 +70,11 @@ void swift_get_time(
9170#elif defined(_WIN32)
9271 // This needs to match what swift-corelibs-libdispatch does
9372
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
11174 // units. We must divide the output by 10,000,000 to get a value in
11275 // seconds and multiply the remainder by 100 to get nanoseconds.
11376 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);
12078 suspending.tv_sec = unbiasedTime / 10'000'000 ;
12179 suspending.tv_nsec = (unbiasedTime % 10'000'000 ) * 100 ;
12280#else
0 commit comments