Commit 14ff73e6 authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Don't globally define HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC

It's used only in a single file, so define it there
(condition_variable_posix.cc).

Bug: None
Change-Id: Ia59b42486feee2920f77dbcbef40a0d801bd2b51
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2405416
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806374}
parent c5d09961
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "build/build_config.h" #include "build/build_config.h"
#if defined(OS_ANDROID) && __ANDROID_API__ < 21
#define HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC 1
#endif
namespace base { namespace base {
ConditionVariable::ConditionVariable(Lock* user_lock) ConditionVariable::ConditionVariable(Lock* user_lock)
...@@ -31,7 +35,7 @@ ConditionVariable::ConditionVariable(Lock* user_lock) ...@@ -31,7 +35,7 @@ ConditionVariable::ConditionVariable(Lock* user_lock)
// versions have pthread_condattr_setclock. // versions have pthread_condattr_setclock.
// Mac can use relative time deadlines. // Mac can use relative time deadlines.
#if !defined(OS_APPLE) && !defined(OS_NACL) && \ #if !defined(OS_APPLE) && !defined(OS_NACL) && \
!(defined(OS_ANDROID) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)) !defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)
pthread_condattr_t attrs; pthread_condattr_t attrs;
rv = pthread_condattr_init(&attrs); rv = pthread_condattr_init(&attrs);
DCHECK_EQ(0, rv); DCHECK_EQ(0, rv);
...@@ -120,12 +124,12 @@ void ConditionVariable::TimedWait(const TimeDelta& max_time) { ...@@ -120,12 +124,12 @@ void ConditionVariable::TimedWait(const TimeDelta& max_time) {
absolute_time.tv_nsec %= Time::kNanosecondsPerSecond; absolute_time.tv_nsec %= Time::kNanosecondsPerSecond;
DCHECK_GE(absolute_time.tv_sec, now.tv_sec); // Overflow paranoia DCHECK_GE(absolute_time.tv_sec, now.tv_sec); // Overflow paranoia
#if defined(OS_ANDROID) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC) #if defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)
int rv = pthread_cond_timedwait_monotonic_np( int rv = pthread_cond_timedwait_monotonic_np(
&condition_, user_mutex_, &absolute_time); &condition_, user_mutex_, &absolute_time);
#else #else
int rv = pthread_cond_timedwait(&condition_, user_mutex_, &absolute_time); int rv = pthread_cond_timedwait(&condition_, user_mutex_, &absolute_time);
#endif // OS_ANDROID && HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC #endif // HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC
#endif // OS_APPLE #endif // OS_APPLE
// On failure, we only expect the CV to timeout. Any other error value means // On failure, we only expect the CV to timeout. Any other error value means
......
...@@ -80,13 +80,6 @@ config("compiler") { ...@@ -80,13 +80,6 @@ config("compiler") {
cflags += [ "--target=$abi_target$compile_api_level" ] cflags += [ "--target=$abi_target$compile_api_level" ]
ldflags += [ "--target=$abi_target$compile_api_level" ] ldflags += [ "--target=$abi_target$compile_api_level" ]
# TODO(crbug.com/771171): Remove this define once code that uses it has been
# updated to no longer need it. This is leftover from older Android NDK
# versions.
if (compile_api_level < 21) {
cflags += [ "-DHAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC=1" ]
}
# Assign any flags set for the C compiler to asmflags so that they are sent # Assign any flags set for the C compiler to asmflags so that they are sent
# to the assembler. # to the assembler.
asmflags = cflags asmflags = cflags
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment