diff options
author | jbj <devnull@localhost> | 2001-12-27 21:00:17 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2001-12-27 21:00:17 +0000 |
commit | 0e58e87c7af3427ffe9252ac9ce2e652160299bb (patch) | |
tree | 3ea65666749c50af9adb3e22ee42eb3066d070b8 /zlib/crc32.c | |
parent | a3b362c466a12488fffe2f6dd4fffb728da2b0c0 (diff) | |
download | librpm-tizen-0e58e87c7af3427ffe9252ac9ce2e652160299bb.tar.gz librpm-tizen-0e58e87c7af3427ffe9252ac9ce2e652160299bb.tar.bz2 librpm-tizen-0e58e87c7af3427ffe9252ac9ce2e652160299bb.zip |
- simple automake wrappers for zlib.
- expose various comments for doxygen digestification.
CVS patchset: 5229
CVS date: 2001/12/27 21:00:17
Diffstat (limited to 'zlib/crc32.c')
-rw-r--r-- | zlib/crc32.c | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/zlib/crc32.c b/zlib/crc32.c index 2fae943f2..0af89a1c0 100644 --- a/zlib/crc32.c +++ b/zlib/crc32.c @@ -1,9 +1,13 @@ -/* crc32.c -- compute the CRC-32 of a data stream +/* @(#) $Id: crc32.c,v 1.4 2001/11/22 21:12:46 jbj Exp $ */ +/* * Copyright (C) 1995-1998 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ -/* @(#) $Id: crc32.c,v 1.3 2001/11/21 22:01:55 jbj Exp $ */ +/** + * \file crc32.c + * Compute the CRC-32 of a data stream. + */ #include "zlib.h" @@ -18,30 +22,30 @@ local uLongf crc_table[256]; local void make_crc_table OF((void)) /*@*/; -/* - Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: - x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. - - Polynomials over GF(2) are represented in binary, one bit per coefficient, - with the lowest powers in the most significant bit. Then adding polynomials - is just exclusive-or, and multiplying a polynomial by x is a right shift by - one. If we call the above polynomial p, and represent a byte as the - polynomial q, also with the lowest power in the most significant bit (so the - byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, - where a mod b means the remainder after dividing a by b. - - This calculation is done using the shift-register method of multiplying and - taking the remainder. The register is initialized to zero, and for each - incoming bit, x^32 is added mod p to the register if the bit is a one (where - x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by - x (which is shifting right by one and adding x^32 mod p if the bit shifted - out is a one). We start with the highest power (least significant bit) of - q and repeat for all eight bits of q. - - The table is simply the CRC of all possible eight bit values. This is all - the information needed to generate CRC's on data a byte at a time for all - combinations of CRC register values and incoming bytes. -*/ +/** + * Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: + * x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. + * + * Polynomials over GF(2) are represented in binary, one bit per coefficient, + * with the lowest powers in the most significant bit. Then adding polynomials + * is just exclusive-or, and multiplying a polynomial by x is a right shift by + * one. If we call the above polynomial p, and represent a byte as the + * polynomial q, also with the lowest power in the most significant bit (so the + * byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, + * where a mod b means the remainder after dividing a by b. + * + * This calculation is done using the shift-register method of multiplying and + * taking the remainder. The register is initialized to zero, and for each + * incoming bit, x^32 is added mod p to the register if the bit is a one (where + * x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by + * x (which is shifting right by one and adding x^32 mod p if the bit shifted + * out is a one). We start with the highest power (least significant bit) of + * q and repeat for all eight bits of q. + * + * The table is simply the CRC of all possible eight bit values. This is all + * the information needed to generate CRC's on data a byte at a time for all + * combinations of CRC register values and incoming bytes. + */ local void make_crc_table(void) { uLong c; |