X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=libiberty%2Fcrc32.c;h=96b12b9b56a720b652dcd11ebd4d5a80b10cccc1;hb=63ffd7c9131c0e9723016d33cf8d435cc508d02b;hp=2171a3d1c7fbe9e7611fafdc36310b1c57a7c569;hpb=6e88169156860fb7a726b875af919cade2c940b5;p=deliverable%2Fbinutils-gdb.git diff --git a/libiberty/crc32.c b/libiberty/crc32.c index 2171a3d1c7..96b12b9b56 100644 --- a/libiberty/crc32.c +++ b/libiberty/crc32.c @@ -1,5 +1,5 @@ /* crc32.c - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2019 Free Software Foundation, Inc. This file is part of the libiberty library. @@ -33,15 +33,14 @@ #include "libiberty.h" -/* This table was generated by the following program. This matches - what gdb does. +/* This table was generated by the following program. #include int main () { - int i, j; + unsigned int i, j; unsigned int c; int table[256]; @@ -138,24 +137,37 @@ static const unsigned int crc32_table[] = /* -@deftypefn Extension unsigned int crc32 (const unsigned char *@var{buf}, int @var{len}, unsigned int @var{init}) +@deftypefn Extension {unsigned int} crc32 (const unsigned char *@var{buf}, @ + int @var{len}, unsigned int @var{init}) Compute the 32-bit CRC of @var{buf} which has length @var{len}. The starting value is @var{init}; this may be used to compute the CRC of data split across multiple buffers by passing the return value of each call as the @var{init} parameter of the next. -This is intended to match the CRC used by the @command{gdb} remote -protocol for the @samp{qCRC} command. In order to get the same -results as gdb for a block of data, you must pass the first CRC -parameter as @code{0xffffffff}. +This is used by the @command{gdb} remote protocol for the @samp{qCRC} +command. In order to get the same results as gdb for a block of data, +you must pass the first CRC parameter as @code{0xffffffff}. + +This CRC can be specified as: + + Width : 32 + Poly : 0x04c11db7 + Init : parameter, typically 0xffffffff + RefIn : false + RefOut : false + XorOut : 0 + +This differs from the "standard" CRC-32 algorithm in that the values +are not reflected, and there is no final XOR value. These differences +make it easy to compose the values of multiple blocks. @end deftypefn */ unsigned int -crc32 (const unsigned char *buf, int len, unsigned int init) +xcrc32 (const unsigned char *buf, int len, unsigned int init) { unsigned int crc = init; while (len--)