From 8311390f13177f3086ecdac875115d2d4cc2688b Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 4 Feb 2013 20:12:22 +0100 Subject: [PATCH] darwin: merge uv_cond_timedwait implementation Merge the OS X specific implementation of uv_cond_timedwait() with the generic one. The only difference is that it now uses mach_absolute_time instead of gettimeofday. --- src/unix/thread.c | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/src/unix/thread.c b/src/unix/thread.c index 4fd5d2f58..8d15c9b6f 100644 --- a/src/unix/thread.c +++ b/src/unix/thread.c @@ -323,31 +323,6 @@ 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; @@ -369,8 +344,6 @@ 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__)