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 Apr 22, 2024
1 parent 86e94ac commit 89f1657
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 @@ -51,7 +51,7 @@
#endif // defined(__cpp_lib_string_view)

#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 @@ -1088,7 +1088,7 @@ class Map {
#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 89f1657

Please sign in to comment.