From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=50663 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ptz89-0003Jn-7R for qemu-devel@nongnu.org; Mon, 28 Feb 2011 04:11:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ptz82-0004gx-Ul for qemu-devel@nongnu.org; Mon, 28 Feb 2011 04:10:55 -0500 Received: from mail-yw0-f45.google.com ([209.85.213.45]:36867) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ptz82-0004gt-R1 for qemu-devel@nongnu.org; Mon, 28 Feb 2011 04:10:54 -0500 Received: by ywl41 with SMTP id 41so1468101ywl.4 for ; Mon, 28 Feb 2011 01:10:54 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 28 Feb 2011 10:10:09 +0100 Message-Id: <1298884224-19734-8-git-send-email-pbonzini@redhat.com> In-Reply-To: <1298884224-19734-1-git-send-email-pbonzini@redhat.com> References: <1298884224-19734-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH v3 uq/master 07/22] add assertions on the owner of a QemuMutex List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: blauwirbel@gmail.com, jan.kiszka@siemes.com, aurelien@aurel32.net, kvm@vger.kernel.org, mtosatti@redhat.com These are already present in the Win32 implementation, add them to the pthread wrappers as well. Use PTHREAD_MUTEX_ERRORCHECK for mutex operations. Later we'll add tracking of the owner for cond_signal/broadcast. Signed-off-by: Paolo Bonzini --- qemu-thread-posix.c | 23 ++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/qemu-thread-posix.c b/qemu-thread-posix.c index e307773..a4c6e25 100644 --- a/qemu-thread-posix.c +++ b/qemu-thread-posix.c @@ -28,8 +31,12 @@ static void error_exit(int err, const char *msg) void qemu_mutex_init(QemuMutex *mutex) { int err; + pthread_mutexattr_t mutexattr; - err = pthread_mutex_init(&mutex->lock, NULL); + pthread_mutexattr_init(&mutexattr); + pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_ERRORCHECK); + err = pthread_mutex_init(&mutex->lock, &mutexattr); + pthread_mutexattr_destroy(&mutexattr); if (err) error_exit(err, __func__); } -- 1.7.4