From patchwork Mon Feb 28 09:10:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 84748 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 D8EAEB70A6 for ; Mon, 28 Feb 2011 20:22:33 +1100 (EST) Received: from localhost ([127.0.0.1]:59762 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PtzJG-0006Ge-0N for incoming@patchwork.ozlabs.org; Mon, 28 Feb 2011 04:22:30 -0500 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) 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=4RL6ww4LokCZg6iN0W/coaUECOIlh6nSthi3GxX5Saw=; b=t+2ez9Jw3Y+tAzEWASCPPPY0t5QU1AyFOAwO99B9XXemCSTWUsZDM0VRCiyB1FRX11 uPPs96pOfARtfUklRKTlz1Hb3CNprFiVKU0lbhLJvp97W/pO5qtYUq8K7Xe/CDTHj1C3 bYu8B9cq2qQYG8uhsy8t8DKpoN7pRT6sIgZbg= 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=gZd/u/MN5LY4NpKEU1P7IHfRDkyhG5WWNE05frwhANYzqdBhZ+Am2gvekcnCFdMkHk zAw5/5q7RJOwGF0mSCtfuYzTkzI1oYx1IcJvDkNiF/dQQdv/FeqUc/DF239PpGK/JUP6 jJ6Z1OjF468KrUDk2k4RIU42BKtMUjc3iMaw4= Received: by 10.150.49.17 with SMTP id w17mr6829445ybw.377.1298884254596; Mon, 28 Feb 2011 01:10:54 -0800 (PST) Received: from localhost.localdomain (93-34-149-100.ip50.fastwebnet.it [93.34.149.100]) by mx.google.com with ESMTPS id 1sm2037209yhl.11.2011.02.28.01.10.52 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 28 Feb 2011 01:10:54 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 28 Feb 2011 10:10:09 +0100 Message-Id: <1298884224-19734-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.4 In-Reply-To: <1298884224-19734-1-git-send-email-pbonzini@redhat.com> References: <1298884224-19734-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.213.45 Cc: blauwirbel@gmail.com, jan.kiszka@siemes.com, aurelien@aurel32.net, kvm@vger.kernel.org, mtosatti@redhat.com Subject: [Qemu-devel] [PATCH v3 uq/master 07/22] 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 | 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__); }