From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=39739 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PyRve-0004GA-Kf for qemu-devel@nongnu.org; Sat, 12 Mar 2011 11:44:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PyRvd-0003wu-Eq for qemu-devel@nongnu.org; Sat, 12 Mar 2011 11:44:34 -0500 Received: from mail-wy0-f173.google.com ([74.125.82.173]:53088) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PyRvd-0003tD-8s for qemu-devel@nongnu.org; Sat, 12 Mar 2011 11:44:33 -0500 Received: by mail-wy0-f173.google.com with SMTP id 42so3523531wyb.4 for ; Sat, 12 Mar 2011 08:44:32 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Sat, 12 Mar 2011 17:43:54 +0100 Message-Id: <1299948248-30206-8-git-send-email-pbonzini@redhat.com> In-Reply-To: <1299948248-30206-1-git-send-email-pbonzini@redhat.com> References: <1299948248-30206-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH v4 upstream 07/21] 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 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 | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/qemu-thread-posix.c b/qemu-thread-posix.c index e307773..8b54cc0 100644 --- a/qemu-thread-posix.c +++ b/qemu-thread-posix.c @@ -28,8 +28,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