Skip to content

Commit

Permalink
remove use of mach_absolute_time (protocolbuffers#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 protocolbuffers#15029

Closes protocolbuffers#15554

COPYBARA_INTEGRATE_REVIEW=protocolbuffers#15554 from protocolbuffers:dmaclach-mach_absolute_time 295d831
PiperOrigin-RevId: 601370915
  • Loading branch information
dmaclach authored and zhangskz committed Jan 31, 2024
1 parent 4149baf commit 2db46b3
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 @@ -676,7 +676,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 2db46b3

Please sign in to comment.