Skip to content

Commit

Permalink
remove use of mach_absolute_time (#15554)
Browse files Browse the repository at this point in the history
`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=#15554 from protocolbuffers:dmaclach-mach_absolute_time 295d831
PiperOrigin-RevId: 601370915
  • Loading branch information
dmaclach authored and zhangskz committed Feb 12, 2024
1 parent 971fbf6 commit 76d05d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/google/protobuf/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <utility>

#if !defined(GOOGLE_PROTOBUF_NO_RDTSC) && defined(__APPLE__)
#include <mach/mach_time.h>
#include <time.h>
#endif

#include "google/protobuf/stubs/common.h"
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 76d05d4

Please sign in to comment.