From 097dcda8f2029f3a08ef487893e79410257cf7cf Mon Sep 17 00:00:00 2001 From: Adam Novak Date: Wed, 13 Nov 2024 13:29:14 -0800 Subject: [PATCH] Don't use CLOCK_UPTIME_RAW if it won't be defined (#16951) This will fix https://github.com/protocolbuffers/protobuf/issues/15957 by not trying to use CLOCK_UPTIME_RAW if the feature test macros are not currently set to make it available. Since the build system is in charge of the feature test macros, and since this header might be included under any end user program's build system, we can't just #define the macros we would like. Closes #16951 COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/16951 from adamnovak:patch-1 cebf44ed71470415c02b7d7788270c553c973660 PiperOrigin-RevId: 696251619 --- .../Reflection/FeatureSetDescriptor.g.cs | 17 ----------------- src/google/protobuf/map.h | 8 +++++--- 2 files changed, 5 insertions(+), 20 deletions(-) delete mode 100644 csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs diff --git a/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs b/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs deleted file mode 100644 index 208ce1fcb6319..0000000000000 --- a/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs +++ /dev/null @@ -1,17 +0,0 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file or at -// https://developers.google.com/open-source/licenses/bsd -#endregion - -namespace Google.Protobuf.Reflection; - -internal sealed partial class FeatureSetDescriptor -{ - // Canonical serialized form of the edition defaults, generated by embed_edition_defaults. - private const string DefaultsBase64 = - "ChMYhAciACoMCAEQAhgCIAMoATACChMY5wciACoMCAIQARgBIAIoATABChMY6AciDAgBEAEYASACKAEwASoAIOYHKOgH"; -} diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index 1f02abd21e776..3d65e7ca646a1 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -31,7 +31,8 @@ #include "absl/memory/memory.h" #include "google/protobuf/message_lite.h" -#if !defined(GOOGLE_PROTOBUF_NO_RDTSC) && defined(__APPLE__) +#if !defined(GOOGLE_PROTOBUF_NO_RDTSC) && defined(__APPLE__) && \ + (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) #include #endif @@ -728,9 +729,10 @@ class PROTOBUF_EXPORT UntypedMapBase { map_index_t Seed() const { uint64_t s = 0; #if !defined(GOOGLE_PROTOBUF_NO_RDTSC) -#if defined(__APPLE__) +#if defined(__APPLE__) && \ + (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) // Use a commpage-based fast time function on Apple environments (MacOS, - // iOS, tvOS, watchOS, etc). + // iOS, tvOS, watchOS, etc), if we think the system headers expose it. s = clock_gettime_nsec_np(CLOCK_UPTIME_RAW); #elif defined(__x86_64__) && defined(__GNUC__) uint32_t hi, lo;