Skip to content

Commit 3abbbad

Browse files
authored
Don't use CLOCK_UPTIME_RAW if it won't be defined
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.
1 parent 58c48fd commit 3abbbad

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/google/protobuf/map.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <type_traits>
2626
#include <utility>
2727

28-
#if !defined(GOOGLE_PROTOBUF_NO_RDTSC) && defined(__APPLE__)
28+
#if !defined(GOOGLE_PROTOBUF_NO_RDTSC) && defined(__APPLE__) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
2929
#include <time.h>
3030
#endif
3131

@@ -708,9 +708,9 @@ class PROTOBUF_EXPORT UntypedMapBase {
708708
map_index_t Seed() const {
709709
uint64_t s = 0;
710710
#if !defined(GOOGLE_PROTOBUF_NO_RDTSC)
711-
#if defined(__APPLE__)
711+
#if defined(__APPLE__) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
712712
// Use a commpage-based fast time function on Apple environments (MacOS,
713-
// iOS, tvOS, watchOS, etc).
713+
// iOS, tvOS, watchOS, etc), if we think the system headers expose it.
714714
s = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
715715
#elif defined(__x86_64__) && defined(__GNUC__)
716716
uint32_t hi, lo;

0 commit comments

Comments
 (0)