patches/qt47/qt-qmutex_unix.cpp.diff
author jurikm
Sun, 12 Feb 2012 14:04:10 +0000
changeset 8245 383896da4129
parent 3064 6f76bdc54801
permissions -rw-r--r--
SFEsauerbraten.spec: add IPS package name

--- qt-4.4.1.orig/src/corelib/thread/qmutex_unix.cpp	2008-07-29 06:23:36.000000000 -0400
+++ qt-4.4.1/src/corelib/thread/qmutex_unix.cpp	2008-08-31 00:43:29.000000000 -0400
@@ -63,8 +63,47 @@
 QMutexPrivate::QMutexPrivate(QMutex::RecursionMode mode)
     : recursive(mode == QMutex::Recursive), contenders(0), owner(0), count(0), wakeup(false)
 {
+#if defined(Q_OS_SOLARIS)
+    pthread_mutexattr_t mutex_attr;
+    pthread_condattr_t cond_attr;
+    report_error(pthread_mutexattr_init(&mutex_attr),
+            "QMutex", "mutex attr init");
+    report_error(pthread_condattr_init(&cond_attr),
+            "QMutex", "cond attr init");
+    /* The default type for a pthread_mutexattr_t is
+     * PTHREAD_PROCESS_PRIVATE.
+     */
+    report_error(pthread_mutexattr_setpshared(&mutex_attr,
+                PTHREAD_PROCESS_SHARED),
+            "QMutex", "mutex attr setpshared");
+
+    /* The default type for a pthread_condattr_t is
+     * PTHREAD_PROCESS_PRIVATE.
+     */
+    report_error(pthread_condattr_setpshared(&cond_attr,
+                PTHREAD_PROCESS_SHARED),
+            "QMutex", "cond attr setpshared");
+
+    /* It is illegal to use a pthread_mutex_t with a type of
+     * PTHREAD_MUTEX_RECURSIVE in conjunction with a pthread_cond_t.
+     * A recursive pthread_mutex_t will not correctly perform the
+     * implicit atomic pthread_mutex_lock/pthread_mutex_unlock
+     * guaranteed by the implementation of pthread_cond_wait.
+     * Therfore we enforce a pthread_mutexattr_t type of
+     * PTHREAD_MUTEX_ERRORCHECK, and we do not use the default
+     * pthread_mutexattr_t attributes.
+     */
+    report_error(pthread_mutexattr_settype(&mutex_attr,
+                PTHREAD_MUTEX_ERRORCHECK),
+            "QMutex", "mutex attr setttype");
+    report_error(pthread_mutex_init(&mutex, &mutex_attr),
+            "QMutex", "mutex init");
+    report_error(pthread_cond_init(&cond, &cond_attr),
+            "QMutex", "cond init");
+#else
     report_error(pthread_mutex_init(&mutex, NULL), "QMutex", "mutex init");
     report_error(pthread_cond_init(&cond, NULL), "QMutex", "cv init");
+#endif
 }
 
 QMutexPrivate::~QMutexPrivate()