From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17135 invoked by alias); 29 Dec 2014 03:53:34 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 16879 invoked by uid 89); 29 Dec 2014 03:53:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 29 Dec 2014 03:53:27 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id D8A8311621A; Sun, 28 Dec 2014 22:53:24 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id S5OE9KElkNey; Sun, 28 Dec 2014 22:53:24 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 71F3D116219; Sun, 28 Dec 2014 22:53:24 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id D34124100E; Mon, 29 Dec 2014 07:53:19 +0400 (RET) Date: Mon, 29 Dec 2014 03:53:00 -0000 From: Joel Brobecker To: Yao Qi Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Clear upper bits during sign extension Message-ID: <20141229035319.GC2123@adacore.com> References: <1419815569-21854-1-git-send-email-yao@codesourcery.com> <20141229030659.GB2123@adacore.com> <87d273w2gl.fsf@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87d273w2gl.fsf@codesourcery.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2014-12/txt/msg00653.txt.bz2 > Yeah, that is better, or even we can left shift signbit by one. Indeed! > 2014-12-29 Yao Qi > > * utils.c (gdb_sign_extend): Clear bits from BIT in VALUE. Looks good to me. > diff --git a/gdb/utils.c b/gdb/utils.c > index 47adb67..61873f7 100644 > --- a/gdb/utils.c > +++ b/gdb/utils.c > @@ -3032,6 +3032,9 @@ gdb_sign_extend (LONGEST value, int bit) > { > LONGEST signbit = ((LONGEST) 1) << (bit - 1); > > + /* Clear upper bits from bit BIT. */ > + value &= (signbit << 1) - 1; > + > value = (value ^ signbit) - signbit; > } -- Joel