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

Side by Side Diff: src/base/platform/semaphore.cc

Issue 527273003: Fix NaCl build. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | « src/base/bits-unittest.cc ('k') | 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 // 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/semaphore.h" 5 #include "src/base/platform/semaphore.h"
6 6
7 #if V8_OS_MACOSX 7 #if V8_OS_MACOSX
8 #include <mach/mach_init.h> 8 #include <mach/mach_init.h>
9 #include <mach/task.h> 9 #include <mach/task.h>
10 #endif 10 #endif
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 108
109 bool Semaphore::WaitFor(const TimeDelta& rel_time) { 109 bool Semaphore::WaitFor(const TimeDelta& rel_time) {
110 #if V8_OS_NACL 110 #if V8_OS_NACL
111 // PNaCL doesn't support sem_timedwait, do ugly busy waiting. 111 // PNaCL doesn't support sem_timedwait, do ugly busy waiting.
112 ElapsedTimer timer; 112 ElapsedTimer timer;
113 timer.Start(); 113 timer.Start();
114 do { 114 do {
115 int result = sem_trywait(&native_handle_); 115 int result = sem_trywait(&native_handle_);
116 if (result == 0) return true; 116 if (result == 0) return true;
117 DCHECK(errno == EAGAIN || error == EINTR); 117 DCHECK(errno == EAGAIN || errno == EINTR);
118 } while (!timer.HasExpired(rel_time)); 118 } while (!timer.HasExpired(rel_time));
119 return false; 119 return false;
120 #else 120 #else
121 // Compute the time for end of timeout. 121 // Compute the time for end of timeout.
122 const Time time = Time::NowFromSystemTime() + rel_time; 122 const Time time = Time::NowFromSystemTime() + rel_time;
123 const struct timespec ts = time.ToTimespec(); 123 const struct timespec ts = time.ToTimespec();
124 124
125 // Wait for semaphore signalled or timeout. 125 // Wait for semaphore signalled or timeout.
126 while (true) { 126 while (true) {
127 int result = sem_timedwait(&native_handle_, &ts); 127 int result = sem_timedwait(&native_handle_, &ts);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 195 }
196 DCHECK(result == WAIT_OBJECT_0); 196 DCHECK(result == WAIT_OBJECT_0);
197 return true; 197 return true;
198 } 198 }
199 } 199 }
200 } 200 }
201 201
202 #endif // V8_OS_MACOSX 202 #endif // V8_OS_MACOSX
203 203
204 } } // namespace v8::base 204 } } // namespace v8::base
OLDNEW
« no previous file with comments | « src/base/bits-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698