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 cebf44ed71
PiperOrigin-RevId: 696251619
pull/19252/head
Adam Novak 4 months ago committed by Copybara-Service
parent f836d10681
commit 097dcda8f2
  1. 17
      csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs
  2. 8
      src/google/protobuf/map.h

@ -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";
}

@ -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 <time.h>
#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;

Loading…
Cancel
Save