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

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

Issue 23494020: We can't use pthread_condattr_setclock() in NaCl. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 23 matching lines...) Expand all
34 34
35 namespace v8 { 35 namespace v8 {
36 namespace internal { 36 namespace internal {
37 37
38 #if V8_OS_POSIX 38 #if V8_OS_POSIX
39 39
40 ConditionVariable::ConditionVariable() { 40 ConditionVariable::ConditionVariable() {
41 // TODO(bmeurer): The test for V8_LIBRT_NOT_AVAILABLE is a temporary 41 // TODO(bmeurer): The test for V8_LIBRT_NOT_AVAILABLE is a temporary
42 // hack to support cross-compiling Chrome for Android in AOSP. Remove 42 // hack to support cross-compiling Chrome for Android in AOSP. Remove
43 // this once AOSP is fixed. 43 // this once AOSP is fixed.
44 #if (V8_OS_FREEBSD || V8_OS_NETBSD || V8_OS_OPENBSD || V8_LIBC_GLIBC) && \ 44 #if (V8_OS_FREEBSD || V8_OS_NETBSD || V8_OS_OPENBSD || \
45 !V8_LIBRT_NOT_AVAILABLE 45 (V8_OS_LINUX && V8_LIBC_GLIBC)) && !V8_LIBRT_NOT_AVAILABLE
46 // On Free/Net/OpenBSD and Linux with glibc we can change the time 46 // On Free/Net/OpenBSD and Linux with glibc we can change the time
47 // source for pthread_cond_timedwait() to use the monotonic clock. 47 // source for pthread_cond_timedwait() to use the monotonic clock.
48 pthread_condattr_t attr; 48 pthread_condattr_t attr;
49 int result = pthread_condattr_init(&attr); 49 int result = pthread_condattr_init(&attr);
50 ASSERT_EQ(0, result); 50 ASSERT_EQ(0, result);
51 result = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); 51 result = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
52 ASSERT_EQ(0, result); 52 ASSERT_EQ(0, result);
53 result = pthread_cond_init(&native_handle_, &attr); 53 result = pthread_cond_init(&native_handle_, &attr);
54 ASSERT_EQ(0, result); 54 ASSERT_EQ(0, result);
55 result = pthread_condattr_destroy(&attr); 55 result = pthread_condattr_destroy(&attr);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // not depend on the real time clock, which is what you really WANT here! 100 // not depend on the real time clock, which is what you really WANT here!
101 ts = rel_time.ToTimespec(); 101 ts = rel_time.ToTimespec();
102 ASSERT_GE(ts.tv_sec, 0); 102 ASSERT_GE(ts.tv_sec, 0);
103 ASSERT_GE(ts.tv_nsec, 0); 103 ASSERT_GE(ts.tv_nsec, 0);
104 result = pthread_cond_timedwait_relative_np( 104 result = pthread_cond_timedwait_relative_np(
105 &native_handle_, &mutex->native_handle(), &ts); 105 &native_handle_, &mutex->native_handle(), &ts);
106 #else 106 #else
107 // TODO(bmeurer): The test for V8_LIBRT_NOT_AVAILABLE is a temporary 107 // TODO(bmeurer): The test for V8_LIBRT_NOT_AVAILABLE is a temporary
108 // hack to support cross-compiling Chrome for Android in AOSP. Remove 108 // hack to support cross-compiling Chrome for Android in AOSP. Remove
109 // this once AOSP is fixed. 109 // this once AOSP is fixed.
110 #if (V8_OS_FREEBSD || V8_OS_NETBSD || V8_OS_OPENBSD || V8_LIBC_GLIBC) && \ 110 #if (V8_OS_FREEBSD || V8_OS_NETBSD || V8_OS_OPENBSD || \
111 !V8_LIBRT_NOT_AVAILABLE 111 (V8_OS_LINUX && V8_LIBC_GLIBC)) && !V8_LIBRT_NOT_AVAILABLE
112 // On Free/Net/OpenBSD and Linux with glibc we can change the time 112 // On Free/Net/OpenBSD and Linux with glibc we can change the time
113 // source for pthread_cond_timedwait() to use the monotonic clock. 113 // source for pthread_cond_timedwait() to use the monotonic clock.
114 result = clock_gettime(CLOCK_MONOTONIC, &ts); 114 result = clock_gettime(CLOCK_MONOTONIC, &ts);
115 ASSERT_EQ(0, result); 115 ASSERT_EQ(0, result);
116 Time now = Time::FromTimespec(ts); 116 Time now = Time::FromTimespec(ts);
117 #else 117 #else
118 // The timeout argument to pthread_cond_timedwait() is in absolute time. 118 // The timeout argument to pthread_cond_timedwait() is in absolute time.
119 Time now = Time::NowFromSystemTime(); 119 Time now = Time::NowFromSystemTime();
120 #endif 120 #endif
121 Time end_time = now + rel_time; 121 Time end_time = now + rel_time;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 // Release the wait event. 336 // Release the wait event.
337 ASSERT(!result || event->notified_); 337 ASSERT(!result || event->notified_);
338 native_handle_.Post(event, result); 338 native_handle_.Post(event, result);
339 339
340 return result; 340 return result;
341 } 341 }
342 342
343 #endif // V8_OS_POSIX 343 #endif // V8_OS_POSIX
344 344
345 } } // namespace v8::internal 345 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698