dbus-marshal-validate: Check brackets in signature nest correctly
[platform/upstream/dbus.git] / dbus / dbus-sysdeps-pthread.c
index 2180c37..e1c14f9 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <sys/time.h>
 #include <pthread.h>
+#include <stdio.h>
 #include <string.h>
 
 #ifdef HAVE_ERRNO_H
@@ -72,7 +73,7 @@ struct DBusCondVar {
 #define PTHREAD_CHECK(func_name, result_or_call) do {                                  \
     int tmp = (result_or_call);                                                        \
     if (tmp != 0) {                                                                    \
-      _dbus_warn_check_failed ("pthread function %s failed with %d %s in %s\n",        \
+      _dbus_warn_check_failed ("pthread function %s failed with %d %s in %s",          \
                                func_name, tmp, strerror(tmp), _DBUS_FUNCTION_NAME);    \
     }                                                                                  \
 } while (0)
@@ -301,49 +302,19 @@ _dbus_threads_unlock_platform_specific (void)
   pthread_mutex_unlock (&init_mutex);
 }
 
-#ifdef DBUS_HAVE_STATIC_RECURSIVE_MUTEXES
-
-static pthread_mutex_t global_locks[] = {
-    /* 0-4 */
-    PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
-    PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
-    PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
-    PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
-    PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
-    /* 5-9 */
-    PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
-    PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
-    PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
-    PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
-    PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
-    /* 10-11 */
-    PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
-    PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
-};
-
-_DBUS_STATIC_ASSERT (_DBUS_N_ELEMENTS (global_locks) == _DBUS_N_GLOBAL_LOCKS);
-
-dbus_bool_t
-_dbus_lock (DBusGlobalLock lock)
-{
-  /* No initialization is needed. */
-  _dbus_assert (lock >= 0);
-  _dbus_assert (lock < _DBUS_N_GLOBAL_LOCKS);
-
-  PTHREAD_CHECK ("pthread_mutex_lock",
-      pthread_mutex_lock (&(global_locks[lock])));
-  return TRUE;
-}
-
+#ifdef DBUS_ENABLE_VERBOSE_MODE
+/*
+ * If we can identify the current process and/or thread, print them to stderr followed by a colon.
+ */
 void
-_dbus_unlock (DBusGlobalLock lock)
+_dbus_print_thread (void)
 {
-  /* No initialization is needed. */
-  _dbus_assert (lock >= 0);
-  _dbus_assert (lock < _DBUS_N_GLOBAL_LOCKS);
-
-  PTHREAD_CHECK ("pthread_mutex_unlock",
-      pthread_mutex_unlock (&(global_locks[lock])));
+#ifdef __linux__
+  /* we know a pthread_t is numeric on Linux */
+  fprintf (stderr, "%lu: 0x%lx: ", _dbus_pid_for_log (), (unsigned long) pthread_self ());
+#else
+  /* in principle pthread_t isn't required to be printable */
+  fprintf (stderr, "%lu: ", _dbus_pid_for_log ());
+#endif
 }
-
 #endif