Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: src/base/platform/condition-variable.cc

Issue 1036133005: Fix libdl dependency on Android and remove librt hack. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « BUILD.gn ('k') | src/base/platform/time.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/base/platform/condition-variable.h" 5 #include "src/base/platform/condition-variable.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <time.h> 8 #include <time.h>
9 9
10 #include "src/base/platform/time.h" 10 #include "src/base/platform/time.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace base { 13 namespace base {
14 14
15 #if V8_OS_POSIX 15 #if V8_OS_POSIX
16 16
17 ConditionVariable::ConditionVariable() { 17 ConditionVariable::ConditionVariable() {
18 // TODO(bmeurer): The test for V8_LIBRT_NOT_AVAILABLE is a temporary
19 // hack to support cross-compiling Chrome for Android in AOSP. Remove
20 // this once AOSP is fixed.
21 #if (V8_OS_FREEBSD || V8_OS_NETBSD || V8_OS_OPENBSD || \ 18 #if (V8_OS_FREEBSD || V8_OS_NETBSD || V8_OS_OPENBSD || \
22 (V8_OS_LINUX && V8_LIBC_GLIBC)) && !V8_LIBRT_NOT_AVAILABLE 19 (V8_OS_LINUX && V8_LIBC_GLIBC))
23 // On Free/Net/OpenBSD and Linux with glibc we can change the time 20 // On Free/Net/OpenBSD and Linux with glibc we can change the time
24 // source for pthread_cond_timedwait() to use the monotonic clock. 21 // source for pthread_cond_timedwait() to use the monotonic clock.
25 pthread_condattr_t attr; 22 pthread_condattr_t attr;
26 int result = pthread_condattr_init(&attr); 23 int result = pthread_condattr_init(&attr);
27 DCHECK_EQ(0, result); 24 DCHECK_EQ(0, result);
28 result = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); 25 result = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
29 DCHECK_EQ(0, result); 26 DCHECK_EQ(0, result);
30 result = pthread_cond_init(&native_handle_, &attr); 27 result = pthread_cond_init(&native_handle_, &attr);
31 DCHECK_EQ(0, result); 28 DCHECK_EQ(0, result);
32 result = pthread_condattr_destroy(&attr); 29 result = pthread_condattr_destroy(&attr);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 mutex->AssertHeldAndUnmark(); 71 mutex->AssertHeldAndUnmark();
75 #if V8_OS_MACOSX 72 #if V8_OS_MACOSX
76 // Mac OS X provides pthread_cond_timedwait_relative_np(), which does 73 // Mac OS X provides pthread_cond_timedwait_relative_np(), which does
77 // not depend on the real time clock, which is what you really WANT here! 74 // not depend on the real time clock, which is what you really WANT here!
78 ts = rel_time.ToTimespec(); 75 ts = rel_time.ToTimespec();
79 DCHECK_GE(ts.tv_sec, 0); 76 DCHECK_GE(ts.tv_sec, 0);
80 DCHECK_GE(ts.tv_nsec, 0); 77 DCHECK_GE(ts.tv_nsec, 0);
81 result = pthread_cond_timedwait_relative_np( 78 result = pthread_cond_timedwait_relative_np(
82 &native_handle_, &mutex->native_handle(), &ts); 79 &native_handle_, &mutex->native_handle(), &ts);
83 #else 80 #else
84 // TODO(bmeurer): The test for V8_LIBRT_NOT_AVAILABLE is a temporary
85 // hack to support cross-compiling Chrome for Android in AOSP. Remove
86 // this once AOSP is fixed.
87 #if (V8_OS_FREEBSD || V8_OS_NETBSD || V8_OS_OPENBSD || \ 81 #if (V8_OS_FREEBSD || V8_OS_NETBSD || V8_OS_OPENBSD || \
88 (V8_OS_LINUX && V8_LIBC_GLIBC)) && !V8_LIBRT_NOT_AVAILABLE 82 (V8_OS_LINUX && V8_LIBC_GLIBC))
89 // On Free/Net/OpenBSD and Linux with glibc we can change the time 83 // On Free/Net/OpenBSD and Linux with glibc we can change the time
90 // source for pthread_cond_timedwait() to use the monotonic clock. 84 // source for pthread_cond_timedwait() to use the monotonic clock.
91 result = clock_gettime(CLOCK_MONOTONIC, &ts); 85 result = clock_gettime(CLOCK_MONOTONIC, &ts);
92 DCHECK_EQ(0, result); 86 DCHECK_EQ(0, result);
93 Time now = Time::FromTimespec(ts); 87 Time now = Time::FromTimespec(ts);
94 #else 88 #else
95 // The timeout argument to pthread_cond_timedwait() is in absolute time. 89 // The timeout argument to pthread_cond_timedwait() is in absolute time.
96 Time now = Time::NowFromSystemTime(); 90 Time now = Time::NowFromSystemTime();
97 #endif 91 #endif
98 Time end_time = now + rel_time; 92 Time end_time = now + rel_time;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 // Release the wait event. 307 // Release the wait event.
314 DCHECK(!result || event->notified_); 308 DCHECK(!result || event->notified_);
315 native_handle_.Post(event, result); 309 native_handle_.Post(event, result);
316 310
317 return result; 311 return result;
318 } 312 }
319 313
320 #endif // V8_OS_POSIX 314 #endif // V8_OS_POSIX
321 315
322 } } // namespace v8::base 316 } } // namespace v8::base
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/base/platform/time.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698