From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31603 invoked by alias); 28 Jun 2013 17:40:43 -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 31566 invoked by uid 89); 28 Jun 2013 17:40:42 -0000 X-Spam-SWARE-Status: No, score=-7.4 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 28 Jun 2013 17:40:42 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5SHeeGu030642 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 28 Jun 2013 13:40:40 -0400 Received: from barimba.redhat.com (ovpn-113-102.phx2.redhat.com [10.3.113.102]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r5SHea0Q010167; Fri, 28 Jun 2013 13:40:40 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 01/16] use the libiberty crc code Date: Fri, 28 Jun 2013 17:40:00 -0000 Message-Id: <1372441229-305-2-git-send-email-tromey@redhat.com> In-Reply-To: <1372441229-305-1-git-send-email-tromey@redhat.com> References: <1372441229-305-1-git-send-email-tromey@redhat.com> X-SW-Source: 2013-06/txt/msg00899.txt.bz2 gdb has a copy of some CRC code that also appears in libiberty. This patch just removes the local copy. You may notice that "crc32" returns unsigned long but "xcrc32" returns unsigned int. However, this does not matter, because crc32 actually does all its operations in unsigned int type, and only the return result is widened. So, the difference does not matter. * remote.c (crc32_table, crc32): Remove. (remote_verify_memory): Use xcrc32. --- gdb/remote.c | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index a29fe23..e40dc4e 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -8526,36 +8526,6 @@ remote_remove_hw_breakpoint (struct gdbarch *gdbarch, _("remote_remove_hw_breakpoint: reached end of function")); } -/* Table used by the crc32 function to calcuate the checksum. */ - -static unsigned long crc32_table[256] = -{0, 0}; - -static unsigned long -crc32 (const unsigned char *buf, int len, unsigned int crc) -{ - if (!crc32_table[1]) - { - /* Initialize the CRC table and the decoding table. */ - int i, j; - unsigned int c; - - for (i = 0; i < 256; i++) - { - for (c = i << 24, j = 8; j > 0; --j) - c = c & 0x80000000 ? (c << 1) ^ 0x04c11db7 : (c << 1); - crc32_table[i] = c; - } - } - - while (len--) - { - crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ *buf) & 255]; - buf++; - } - return crc; -} - /* Verify memory using the "qCRC:" request. */ static int @@ -8576,7 +8546,7 @@ remote_verify_memory (struct target_ops *ops, /* Be clever; compute the host_crc before waiting for target reply. */ - host_crc = crc32 (data, size, 0xffffffff); + host_crc = xcrc32 (data, size, 0xffffffff); getpkt (&rs->buf, &rs->buf_size, 0); if (rs->buf[0] == 'E') -- 1.8.1.4