Revert "darwin: merge uv_cond_timedwait implementation"
Using mach_absolute_time() for the pthread_cond_timedwait() timeout
breaks a number of tests on OS X 10.8.2.
This reverts commit 8311390f13.
This commit is contained in:
parent
8311390f13
commit
60dd395a5b
@ -323,6 +323,31 @@ void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) {
|
||||
abort();
|
||||
}
|
||||
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
|
||||
int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) {
|
||||
int r;
|
||||
struct timeval tv;
|
||||
struct timespec ts;
|
||||
uint64_t abstime;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
abstime = tv.tv_sec * 1e9 + tv.tv_usec * 1e3 + timeout;
|
||||
ts.tv_sec = abstime / NANOSEC;
|
||||
ts.tv_nsec = abstime % NANOSEC;
|
||||
r = pthread_cond_timedwait(cond, mutex, &ts);
|
||||
|
||||
if (r == 0)
|
||||
return 0;
|
||||
|
||||
if (r == ETIMEDOUT)
|
||||
return -1;
|
||||
|
||||
abort();
|
||||
return -1; /* Satisfy the compiler. */
|
||||
}
|
||||
|
||||
#else /* !(defined(__APPLE__) && defined(__MACH__)) */
|
||||
|
||||
int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) {
|
||||
int r;
|
||||
@ -344,6 +369,8 @@ int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) {
|
||||
return -1; /* Satisfy the compiler. */
|
||||
}
|
||||
|
||||
#endif /* defined(__APPLE__) && defined(__MACH__) */
|
||||
|
||||
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user