mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 11:48:06 +02:00
util/os_time: Safe os_time_get_nano for Windows
Avoid small possibility of reading torn write on 32-bit platforms. If frequency caching is desired, it's probably better to initialize from C++ and extern "C" instead. It's not a tremendous optimization though. Reviewed-by: Jose Fonseca <jfonseca@vmware.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7138>
This commit is contained in:
parent
192d721e3b
commit
4a94527ca1
1 changed files with 2 additions and 3 deletions
|
|
@ -67,11 +67,10 @@ os_time_get_nano(void)
|
|||
|
||||
#elif DETECT_OS_WINDOWS
|
||||
|
||||
static LARGE_INTEGER frequency;
|
||||
LARGE_INTEGER frequency;
|
||||
LARGE_INTEGER counter;
|
||||
int64_t secs, nanosecs;
|
||||
if(!frequency.QuadPart)
|
||||
QueryPerformanceFrequency(&frequency);
|
||||
QueryPerformanceFrequency(&frequency);
|
||||
QueryPerformanceCounter(&counter);
|
||||
/* Compute seconds and nanoseconds parts separately to
|
||||
* reduce severity of precision loss.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue