g_error ("%s: pthread_cond_wait failed with \"%s\" (%d)", __func__, g_strerror (res), res);
}
-static inline int
-mono_os_cond_timedwait (mono_cond_t *cond, mono_mutex_t *mutex, guint32 timeout_ms)
-{
-#ifdef BROKEN_CLOCK_SOURCE
- struct timeval tv;
-#endif
- struct timespec ts;
- int res;
-
- if (timeout_ms == MONO_INFINITE_WAIT) {
- mono_os_cond_wait (cond, mutex);
- return 0;
- }
-
- /* ms = 10^-3, us = 10^-6, ns = 10^-9 */
-
-#ifdef BROKEN_CLOCK_SOURCE
- /* clock_gettime is not supported in MAC OS x */
- res = gettimeofday (&tv, NULL);
- if (G_UNLIKELY (res != 0))
- g_error ("%s: gettimeofday failed with \"%s\" (%d)", __func__, g_strerror (errno), errno);
-
- ts.tv_sec = tv.tv_sec;
- ts.tv_nsec = tv.tv_usec * 1000;
-#else
- /* cond is using CLOCK_MONOTONIC as time source */
- res = clock_gettime (CLOCK_MONOTONIC, &ts);
- if (G_UNLIKELY (res != 0))
- g_error ("%s: clock_gettime failed with \"%s\" (%d)", __func__, g_strerror (errno), errno);
-#endif
-
- ts.tv_sec += timeout_ms / 1000;
- ts.tv_nsec += (timeout_ms % 1000) * 1000 * 1000;
- if (ts.tv_nsec >= 1000 * 1000 * 1000) {
- ts.tv_nsec -= 1000 * 1000 * 1000;
- ts.tv_sec ++;
- }
-
- res = pthread_cond_timedwait (cond, mutex, &ts);
- if (G_UNLIKELY (res != 0 && res != ETIMEDOUT))
- g_error ("%s: pthread_cond_timedwait failed with \"%s\" (%d) %ld %ld %d", __func__, g_strerror (res), res, ts.tv_sec, ts.tv_nsec, timeout_ms);
-
- return res != 0 ? -1 : 0;
-}
+int
+mono_os_cond_timedwait (mono_cond_t *cond, mono_mutex_t *mutex, guint32 timeout_ms);
static inline void
mono_os_cond_signal (mono_cond_t *cond)