From patchwork Thu Jul 13 12:34:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 21587 Received: (qmail 67891 invoked by alias); 13 Jul 2017 12:34:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 67859 invoked by uid 89); 13 Jul 2017 12:34:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=H*F:U*tom, peel X-HELO: gproxy8.mail.unifiedlayer.com Received: from gproxy8-pub.mail.unifiedlayer.com (HELO gproxy8.mail.unifiedlayer.com) (67.222.33.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 12:34:09 +0000 Received: from cmgw2 (unknown [10.0.90.83]) by gproxy8.mail.unifiedlayer.com (Postfix) with ESMTP id 3451E1AB539 for ; Thu, 13 Jul 2017 06:34:08 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id kCa51v0032f2jeq01Ca82J; Thu, 13 Jul 2017 06:34:08 -0600 X-Authority-Analysis: v=2.2 cv=UvYTD64B c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=G3gG6ho9WtcA:10 a=zstS-IiYAAAA:8 a=TzraOAgZVeCxqgaKX8EA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 174-29-39-24.hlrn.qwest.net ([174.29.39.24]:47644 helo=pokyo.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1dVdJk-001NlA-Tf; Thu, 13 Jul 2017 06:34:05 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 2/2] Remove BITS_IN_BYTES define Date: Thu, 13 Jul 2017 06:34:00 -0600 Message-Id: <20170713123400.28917-3-tom@tromey.com> In-Reply-To: <20170713123400.28917-1-tom@tromey.com> References: <20170713123400.28917-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1dVdJk-001NlA-Tf X-Source-Sender: 174-29-39-24.hlrn.qwest.net (pokyo.Home) [174.29.39.24]:47644 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== While working on the previous patch, I noticed that BITS_IN_BYTES can be replaced by HOST_CHAR_BIT, which is used more widely in gdb. 2017-07-13 Tom Tromey * valprint.c (print_octal_chars): Use HOST_CHAR_BIT. (print_binary_chars): Likewise. (BITS_IN_BYTES): Remove. --- gdb/ChangeLog | 6 ++++++ gdb/printcmd.c | 4 ++-- gdb/valprint.c | 9 +++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5ac5bab..bc68b67 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2017-07-13 Tom Tromey + * valprint.c (print_octal_chars): Use HOST_CHAR_BIT. + (print_binary_chars): Likewise. + (BITS_IN_BYTES): Remove. + +2017-07-13 Tom Tromey + PR gdb/21675 * valprint.c (LOW_ZERO): Change value to 034. (print_octal_chars): Add static_asserts for octal constants. diff --git a/gdb/printcmd.c b/gdb/printcmd.c index cd615ec..179c22c 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -432,8 +432,8 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type, case 'd': case 'u': { - bool is_signed = options->format != 'u' || !TYPE_UNSIGNED (type); - print_decimal_chars (stream, valaddr, len, is_signed, byte_order); + bool is_unsigned = options->format == 'u' || TYPE_UNSIGNED (type); + print_decimal_chars (stream, valaddr, len, !is_unsigned, byte_order); } break; case 0: diff --git a/gdb/valprint.c b/gdb/valprint.c index 9e216cf..eef99b1 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -1490,9 +1490,6 @@ void print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr, unsigned len, enum bfd_endian byte_order, bool zero_pad) { - -#define BITS_IN_BYTES 8 - const gdb_byte *p; unsigned int i; int b; @@ -1512,7 +1509,7 @@ print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr, /* Every byte has 8 binary characters; peel off and print from the MSB end. */ - for (i = 0; i < (BITS_IN_BYTES * sizeof (*p)); i++) + for (i = 0; i < (HOST_CHAR_BIT * sizeof (*p)); i++) { if (*p & (mask >> i)) b = '1'; @@ -1532,7 +1529,7 @@ print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr, p >= valaddr; p--) { - for (i = 0; i < (BITS_IN_BYTES * sizeof (*p)); i++) + for (i = 0; i < (HOST_CHAR_BIT * sizeof (*p)); i++) { if (*p & (mask >> i)) b = '1'; @@ -1612,7 +1609,7 @@ print_octal_chars (struct ui_file *stream, const gdb_byte *valaddr, /* For 32 we start in cycle 2, with two bits and one bit carry; for 64 in cycle in cycle 1, with one bit and a two bit carry. */ - cycle = (len * BITS_IN_BYTES) % BITS_IN_OCTAL; + cycle = (len * HOST_CHAR_BIT) % BITS_IN_OCTAL; carry = 0; fputs_filtered ("0", stream);