Revert "[runtime] Use pthread_cond_timedwait_relative_np () function on osx if availa...
authorZoltan Varga <vargaz@gmail.com>
Thu, 29 Jun 2017 06:20:50 +0000 (02:20 -0400)
committerZoltan Varga <vargaz@gmail.com>
Thu, 29 Jun 2017 06:20:50 +0000 (02:20 -0400)
This reverts commit 616ea50718aba3af237637f77d9c58acdca9a61f.

Revert this as it fails to build on wrench.

configure.ac
mono/utils/mono-os-mutex.h

index b14ee03463ca4ae4dee7aba63fe7d58846d91a2c..a61341e306fb827cd252af0fb6c72bca98d4adb6 100644 (file)
@@ -1956,7 +1956,7 @@ if test x$host_win32 = xno; then
        AC_CHECK_HEADERS(pthread.h)
        AC_CHECK_HEADERS(pthread_np.h)
        AC_CHECK_FUNCS(pthread_mutex_timedlock)
-       AC_CHECK_FUNCS(pthread_getattr_np pthread_attr_get_np pthread_setname_np pthread_cond_timedwait_relative_np)
+       AC_CHECK_FUNCS(pthread_getattr_np pthread_attr_get_np pthread_setname_np)
        AC_CHECK_FUNCS(pthread_kill)
        AC_MSG_CHECKING(for PTHREAD_MUTEX_RECURSIVE)
        AC_TRY_COMPILE([ #include <pthread.h>], [
index 7bd79b03dbbb6804c8806edded96a17d7312fe1f..3888d26441df95cd34c10822cd70c8db0ee8bef8 100644 (file)
@@ -178,6 +178,9 @@ mono_os_cond_wait (mono_cond_t *cond, mono_mutex_t *mutex)
 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;
 
@@ -188,22 +191,7 @@ mono_os_cond_timedwait (mono_cond_t *cond, mono_mutex_t *mutex, guint32 timeout_
 
        /* ms = 10^-3, us = 10^-6, ns = 10^-9 */
 
-       /* This function only seems to be available on 64bit osx */
-#if defined(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP) && defined(TARGET_OSX) && defined(TARGET_AMD64)
-       memset (&ts, 0, sizeof (struct timespec));
-       ts.tv_sec = timeout_ms / 1000;
-       ts.tv_nsec = (timeout_ms % 1000) * 1000 * 1000;
-
-       res = pthread_cond_timedwait_relative_np (cond, mutex, &ts);
-       if (G_UNLIKELY (res != 0 && res != ETIMEDOUT)) {
-               g_print ("cond: %p mutex: %p\n", *(gpointer*)cond, *(gpointer*)mutex);
-               g_error ("%s: pthread_cond_timedwait_relative_np 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;
-#else
 #ifdef BROKEN_CLOCK_SOURCE
-       struct timeval tv;
-
        /* clock_gettime is not supported in MAC OS x */
        res = gettimeofday (&tv, NULL);
        if (G_UNLIKELY (res != 0))
@@ -226,12 +214,10 @@ mono_os_cond_timedwait (mono_cond_t *cond, mono_mutex_t *mutex, guint32 timeout_
        }
 
        res = pthread_cond_timedwait (cond, mutex, &ts);
-       if (G_UNLIKELY (res != 0 && res != ETIMEDOUT)) {
-               g_print ("cond: %p mutex: %p\n", *(gpointer*)cond, *(gpointer*)mutex);
+       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;
-#endif /* !HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP */
 }
 
 static inline void