File 1426-Call-mach_clock_getres-only-on-initialized-clocks.patch of Package erlang

From 482bdee28fdd07d19c86744952498cdcef259107 Mon Sep 17 00:00:00 2001
From: Evan Miller <emmiller@gmail.com>
Date: Tue, 21 Jun 2022 09:09:07 -0400
Subject: [PATCH] Call mach_clock_getres only on initialized clocks

Mac OS X 10.6 and earlier produced a segmentation fault due to
a condition mismatch between calls to host_get_clock_service and
mach_clock_getres.
---
 erts/emulator/sys/unix/sys_time.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/erts/emulator/sys/unix/sys_time.c b/erts/emulator/sys/unix/sys_time.c
index 9da80e555f..aca2451bb4 100644
--- a/erts/emulator/sys/unix/sys_time.c
+++ b/erts/emulator/sys/unix/sys_time.c
@@ -219,7 +219,7 @@ sys_init_time(ErtsSysInitTimeResult *init_resp)
 #endif
 
     init_resp->os_monotonic_time_info.resolution = (Uint64) 1000*1000*1000;
-#if defined(ERTS_HAVE_MACH_CLOCK_GETRES) && defined(MONOTONIC_CLOCK_ID)
+#if defined(ERTS_HAVE_MACH_CLOCK_GETRES) && defined(OS_MONOTONIC_TIME_USING_MACH_CLOCK_GET_TIME)
     init_resp->os_monotonic_time_info.resolution
 	= mach_clock_getres(&internal_state.r.o.mach.clock.monotonic);
 #elif defined(HAVE_CLOCK_GETRES) && defined(MONOTONIC_CLOCK_ID)
@@ -379,7 +379,7 @@ sys_init_time(ErtsSysInitTimeResult *init_resp)
 
     init_resp->os_system_time_info.locked_use = 0;
     init_resp->os_system_time_info.resolution = (Uint64) 1000*1000*1000;
-#if defined(ERTS_HAVE_MACH_CLOCK_GETRES) && defined(WALL_CLOCK_ID)
+#if defined(ERTS_HAVE_MACH_CLOCK_GETRES) && defined(OS_SYSTEM_TIME_USING_MACH_CLOCK_GET_TIME)
     init_resp->os_system_time_info.resolution
 	= mach_clock_getres(&internal_state.r.o.mach.clock.wall);
 #elif defined(HAVE_CLOCK_GETRES) && defined(WALL_CLOCK_ID)
-- 
2.35.3

openSUSE Build Service is sponsored by