-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Add build-time check for QueryUnbiasedInterruptTime availability #126551
Description
Several places in the runtime call QueryUnbiasedInterruptTime as a higher-fidelity replacement for GetTickCount64. This API is only available for desktop and UWP apps per the documentation — it is not available in all Windows partitions (e.g. the GAMES partition).
Affected callsites
| File | Function |
|---|---|
src/coreclr/gc/windows/gcenv.windows.cpp |
GCToOSInterface::GetLowPrecisionTimeStamp |
src/native/minipal/time.c |
minipal_lowres_ticks |
src/libraries/.../System/Environment.Windows.cs |
Environment.TickCount64 |
Proposal
Add a CMake feature check (e.g. HAVE_QUERYUNBIASEDINTERRUPTTIME) that detects whether the API is available, and use it consistently across all callsites. For native code this would flow through minipalconfig.h; for managed code it could be an MSBuild property driving a conditional compilation symbol.
When the API is unavailable, GetTickCount64 is an appropriate fallback — it was the prior implementation at all three sites.
Note
This issue was drafted with the assistance of GitHub Copilot.