File 1506-erts-Fix-retrieval-of-OS-monotonic-time-on-Windows.patch of Package erlang

From bfb9af51fa29ed2f42b2c136487aa9f2951b31d5 Mon Sep 17 00:00:00 2001
From: Rickard Green <rickard@erlang.org>
Date: Tue, 2 Apr 2024 16:04:17 +0200
Subject: [PATCH 1/2] [erts] Fix retrieval of OS monotonic time on Windows

---
 erts/emulator/sys/win32/sys_time.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/erts/emulator/sys/win32/sys_time.c b/erts/emulator/sys/win32/sys_time.c
index 1502ea57e2..1febfee829 100644
--- a/erts/emulator/sys/win32/sys_time.c
+++ b/erts/emulator/sys/win32/sys_time.c
@@ -86,7 +86,7 @@ static int days_in_month[2][13] = {
 struct sys_time_internal_state_read_only__ {
     ULONGLONG (WINAPI *pGetTickCount64)(void);
     BOOL (WINAPI *pQueryPerformanceCounter)(LARGE_INTEGER *);
-    Sint32 pcf;
+    Uint32 pcf;
     int using_get_tick_count_time_unit;
 };
 
@@ -170,16 +170,10 @@ os_times_qpc(ErtsMonotonicTime *mtimep, ErtsSystemTime *stimep)
     LARGE_INTEGER pc;
     SYSTEMTIME st;
     ErtsSystemTime stime;
-    BOOL qpcr;
 
-    qpcr = (*internal_state.r.o.pQueryPerformanceCounter)(&pc);
+    *mtimep = os_monotonic_time_qpc();
     GetSystemTime(&st);
 
-    if (!qpcr)
-	erts_exit(ERTS_ABORT_EXIT, "QueryPerformanceCounter() failed\n");
-
-    *mtimep = (ErtsMonotonicTime) pc.QuadPart;
-
     stime = SystemTime2MilliSec(&st);
 
     *stimep = ((ErtsSystemTime)
@@ -372,7 +366,7 @@ sys_init_time(ErtsSysInitTimeResult *init_resp)
 	    if (!internal_state.r.o.pQueryPerformanceCounter)
 		goto get_tick_count64;
 
-	    if (pf.QuadPart > (((LONGLONG) 1) << 32))
+	    if (pf.QuadPart >= (((LONGLONG) 1) << 32))
 		goto get_tick_count64;
 
 	    internal_state.r.o.pcf = (Uint32) pf.QuadPart;
-- 
2.35.3

openSUSE Build Service is sponsored by