10000 Don't use CLOCK_UPTIME_RAW if it won't be defined (#16951) · protocolbuffers/protobuf@097dcda · GitHub
[go: up one dir, main page]

Skip to content

Commit 097dcda

Browse files
adamnovakcopybara-github
authored andcommitted
Don't use CLOCK_UPTIME_RAW if it won't be defined (#16951)
This will fix #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=#16951 from adamnovak:patch-1 cebf44e PiperOrigin-RevId: 696251619
1 parent f836d10 commit 097dcda

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/google/protobuf/map.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
#include "absl/memory/memory.h"
3232
#include "google/protobuf/message_lite.h"
3333

34-
#if !defined(GOOGLE_PROTOBUF_NO_RDTSC) && defined(__APPLE__)
34+
#if !defined(GOOGLE_PROTOBUF_NO_RDTSC) && defined(__APPLE__) && \
35+
(!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
3536
#include <time.h>
3637
#endif
3738

@@ -728,9 +729,10 @@ class PROTOBUF_EXPORT UntypedMapBase {
728729
map_index_t Seed() const {
729730
uint64_t s = 0;
730731
#if !defined(GOOGLE_PROTOBUF_NO_RDTSC)
731-
#if defined(__APPLE__)
732+
#if defined(__APPLE__) && \
733+
(!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
732734
// Use a commpage-based fast time function on Apple environments (MacOS,
733-
// iOS, tvOS, watchOS, etc).
735+
// iOS, tvOS, watchOS, etc), if we think the system headers expose it.
734736
s = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
735737
#elif defined(__x86_64__) && defined(__GNUC__)
736738
uint32_t hi, lo;

0 commit comments

Comments
 (0)
0