From 76d05d4cb9200c371c8894df21f37ba4060bdc8a Mon Sep 17 00:00:00 2001 From: dmaclach Date: Thu, 25 Jan 2024 01:12:35 -0800 Subject: [PATCH] remove use of mach_absolute_time (#15554) `mach_absolute_time` is one of Apple's required reason APIs (https://developer.apple.com/documentation/kernel/1462446-mach_absolute_time?language=objc). Replace it with the suggested `clock_gettime_nsec_np(CLOCK_UPTIME_RAW)` so that we don't need a RRA entry in a privacy manifest. issue #15029 Closes #15554 COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/15554 from protocolbuffers:dmaclach-mach_absolute_time 295d83178d5567743c720e7405ac974b0bcab832 PiperOrigin-RevId: 601370915 --- src/google/protobuf/map.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index e84ca694dd43..83a3cf20f6e7 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -25,7 +25,7 @@ #include #if !defined(GOOGLE_PROTOBUF_NO_RDTSC) && defined(__APPLE__) -#include +#include #endif #include "google/protobuf/stubs/common.h" @@ -691,7 +691,7 @@ class PROTOBUF_EXPORT UntypedMapBase { #if defined(__APPLE__) // Use a commpage-based fast time function on Apple environments (MacOS, // iOS, tvOS, watchOS, etc). - s += mach_absolute_time(); + s = clock_gettime_nsec_np(CLOCK_UPTIME_RAW); #elif defined(__x86_64__) && defined(__GNUC__) uint32_t hi, lo; asm volatile("rdtsc" : "=a"(lo), "=d"(hi));