From patchwork Sat Mar 12 16:43:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 86540 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C1826B6EDD for ; Sun, 13 Mar 2011 04:04:00 +1100 (EST) Received: from localhost ([127.0.0.1]:54742 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PySEQ-00057C-2T for incoming@patchwork.ozlabs.org; Sat, 12 Mar 2011 12:03:58 -0500 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:to:cc:subject:date:message-id :x-mailer:in-reply-to:references; bh=5iT64K33/ZxX4u8pajdrZ+wOPJSlwcZk1c02k89Tc8k=; b=HVNWuZVRXrP6aW1ItzcHNmnljTgeHis4EIjQRtic9USrtWbSF3jtAxMzU+na3IGyjf 28b/a1OZiGT+2r8Gmmy28OKLtdA6gqJ5z1/hFmyFqWYsn9n7s+9f0AQGaq8fRW1Tn1xe 23yLjmnaOw5uQrl8z+sjDPgTsriqepyxNN+AQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=DC0FaCJgaFiC7jxNHvoLPb9okRvjSkHE6mosbuC3RQjzfuDHZkjBCIPfs8Rae73X4S WLZrqIvP5pPPRlfJBpndPVUyFlzUOU64LLx5jzUxKKuJ8dcuF1Lx6F/OBX+w8QREOaxR 0SIc5HImPIfSYcznIEcp1d4Po/QzbMgJECiU4= Received: by 10.227.58.72 with SMTP id f8mr9536346wbh.181.1299948272791; Sat, 12 Mar 2011 08:44:32 -0800 (PST) Received: from localhost.localdomain (93-34-197-200.ip51.fastwebnet.it [93.34.197.200]) by mx.google.com with ESMTPS id y29sm1643003wbd.16.2011.03.12.08.44.31 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 12 Mar 2011 08:44:31 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sat, 12 Mar 2011 17:43:54 +0100 Message-Id: <1299948248-30206-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.4 In-Reply-To: <1299948248-30206-1-git-send-email-pbonzini@redhat.com> References: <1299948248-30206-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.173 Cc: blauwirbel@gmail.com Subject: [Qemu-devel] [PATCH v4 upstream 07/21] add assertions on the owner of a QemuMutex X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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__); }