Circumvent a bug in older glibc.

In glibc prior to 2.3.4 the return value from sem_timedwait is not -1
when it fails, but the actual error code.

Turned out that our ARM setup uses glibc 2.3.2.


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1530 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
sgjesse@chromium.org 2009-03-18 10:48:06 +00:00
parent a0a3388363
commit 75bfe56832

View File

@ -634,6 +634,11 @@ bool LinuxSemaphore::Wait(int timeout) {
while (true) {
int result = sem_timedwait(&sem_, &ts);
if (result == 0) return true; // Successfully got semaphore.
if (result > 0) {
// For glibc prior to 2.3.4 sem_timedwait returns the error instead of -1.
errno = result;
result = -1;
}
if (result == -1 && errno == ETIMEDOUT) return false; // Timeout.
CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup.
}