From patchwork Wed Aug 3 10:50:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Torvald Riegel X-Patchwork-Id: 108110 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 0B150B71D0 for ; Wed, 3 Aug 2011 20:50:41 +1000 (EST) Received: (qmail 30820 invoked by alias); 3 Aug 2011 10:50:40 -0000 Received: (qmail 30811 invoked by uid 22791); 3 Aug 2011 10:50:39 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 03 Aug 2011 10:50:25 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p73AoP34008225 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 3 Aug 2011 06:50:25 -0400 Received: from [10.36.7.186] (vpn1-7-186.ams2.redhat.com [10.36.7.186]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p73AoNdZ010584; Wed, 3 Aug 2011 06:50:24 -0400 Subject: Re: [trans-mem] Beginning of refactoring From: Torvald Riegel To: Richard Henderson , Aldy Hernandez Cc: GCC Patches In-Reply-To: <4E31C065.1010907@redhat.com> References: <1306357828.13348.423.camel@triegel.csb> <1310221819.5106.1054.camel@triegel.csb> <1311031188.19033.1045.camel@triegel.csb> <1311031322.19033.1049.camel@triegel.csb> <4E31881D.9060000@redhat.com> <1311881779.3533.97.camel@triegel.csb> <4E31C065.1010907@redhat.com> Date: Wed, 03 Aug 2011 12:50:17 +0200 Message-ID: <1312368617.3533.221.camel@triegel.csb> Mime-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This small patch fixes the rollback of the transaction ID as well as queries for it. OK for branch? commit bd83b4594c1f6eee09e0fa7b369557f986291f9b Author: Torvald Riegel Date: Fri Jul 29 15:19:04 2011 +0200 Fix rollback and queries of transaction ID. * beginend.cc (GTM::gtm_transaction::rollback): Roll back tx id as well. * query.cc (_ITM_getTransactionId): There is no active transaction if the current nesting level is zero. diff --git a/libitm/beginend.cc b/libitm/beginend.cc index 9f84404..d336d60 100644 --- a/libitm/beginend.cc +++ b/libitm/beginend.cc @@ -298,6 +298,7 @@ GTM::gtm_transaction::rollback (gtm_transaction_cp *cp) if (parent_txns.size() > 0) { jb = parent_txns[0].jb; + id = parent_txns[0].id; prop = parent_txns[0].prop; } // Reset the transaction. Do not reset this->state, which is handled by diff --git a/libitm/query.cc b/libitm/query.cc index 4905fc6..9a95211 100644 --- a/libitm/query.cc +++ b/libitm/query.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2008, 2009 Free Software Foundation, Inc. +/* Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc. Contributed by Richard Henderson . This file is part of the GNU Transactional Memory Library (libitm). @@ -59,7 +59,7 @@ _ITM_transactionId_t ITM_REGPARM _ITM_getTransactionId (void) { struct gtm_transaction *tx = gtm_tx(); - return tx ? tx->id : _ITM_noTransactionId; + return (tx && (tx->nesting > 0)) ? tx->id : _ITM_noTransactionId; }