diff options
author | Tom Tromey <tromey@redhat.com> | 2013-08-14 17:57:09 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2013-08-14 17:57:09 +0000 |
commit | 85ec6ce7d58c48d6474981c428a4f0d92e447173 (patch) | |
tree | ec31227f3cf5c77091cff5cb42aff3cbd7e3597b | |
parent | 62c34db3dc2a5a77d28853a650182a26f00896bb (diff) | |
download | gdb-85ec6ce7d58c48d6474981c428a4f0d92e447173.zip gdb-85ec6ce7d58c48d6474981c428a4f0d92e447173.tar.gz gdb-85ec6ce7d58c48d6474981c428a4f0d92e447173.tar.bz2 |
use the libiberty crc code
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.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/remote.c | 32 |
2 files changed, 6 insertions, 31 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 35d6bcc..bde9c2d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2013-08-14 Tom Tromey <tromey@redhat.com> + + * remote.c (crc32_table, crc32): Remove. + (remote_verify_memory): Use xcrc32. + 2013-08-13 Sergio Durigan Junior <sergiodj@redhat.com> * value.h (create_internalvar_type_lazy): Adjust prototype diff --git a/gdb/remote.c b/gdb/remote.c index 96a62ea..47012fe 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -8521,36 +8521,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 @@ -8571,7 +8541,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') |