From b960514077419ddd13dcd8824f40ad1b0e3555d1 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 6 Oct 1998 21:43:58 +0000 Subject: crc32 algorithm. obtained from dr dobb's journal http://www.ddj.com/ftp/1992/1992.05/crcman.zip. copyright 1992 mark r nelson. (This used to be commit 73667141af2f707fe306a0fda4853d160e55bd97) --- source3/lib/crc32.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 source3/lib/crc32.c (limited to 'source3/lib/crc32.c') diff --git a/source3/lib/crc32.c b/source3/lib/crc32.c new file mode 100644 index 0000000000..ef9cefea18 --- /dev/null +++ b/source3/lib/crc32.c @@ -0,0 +1,70 @@ +/* + * Dr Dobb's Journal: http://www.ddj.com/ftp/1992/1992.05/crcman.zip + * + * Copyright Mark R. Nelson 1992 + * + */ + +#include "includes.h" + +#define CRC32_POLYNOMIAL 0xEDB88320L + +/***************************************************************** + Instead of performing a straightforward calculation of the 32 bit + CRC using a series of logical operations, this program uses the + faster table lookup method. This routine is called once when the + program starts up to build the table which will be used later + when calculating the CRC values. + *****************************************************************/ + +static uint32 CRCTable[256]; + +void crc32_build_table(void) +{ + int i; + int j; + uint32 crc; + + for ( i = 0; i <= 255 ; i++ ) + { + crc = i; + for ( j = 8 ; j > 0; j-- ) + { + if ( crc & 1 ) + { + crc = ( crc >> 1 ) ^ CRC32_POLYNOMIAL; + } + else + { + crc >>= 1; + } + } + CRCTable[ i ] = crc; + } +} + +/***************************************************************** + This routine calculates the CRC for a block of data using the + table lookup method. + *****************************************************************/ + +uint32 crc32_calc_buffer( uint32 count, uchar *buffer) +{ + uchar *p; + uint32 crc; + + p = buffer; + crc = 0xffffffff; + + while ( count-- != 0 ) + { + uint32 temp1; + uint32 temp2; + + temp1 = ( crc >> 8 ) & 0x00FFFFFFL; + temp2 = CRCTable[ ( (int) crc ^ *p++ ) & 0xff ]; + crc = temp1 ^ temp2; + } + return crc; +} + -- cgit From d0ca2da837844e592b55a49e9e3f5d39f2e4f0e4 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 8 Oct 1998 14:11:19 +0000 Subject: added "permission obtained from John Erickson ...." (This used to be commit 0067e45d4194bd14549aac6e8f40a2ef19305716) --- source3/lib/crc32.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/lib/crc32.c') diff --git a/source3/lib/crc32.c b/source3/lib/crc32.c index ef9cefea18..cb8bcde909 100644 --- a/source3/lib/crc32.c +++ b/source3/lib/crc32.c @@ -3,6 +3,9 @@ * * Copyright Mark R. Nelson 1992 * + * This code used by permission of J Erickson + * Tues 6th October 1998. Copyright acknowledged above, as agreed. + * */ #include "includes.h" -- cgit From abb67ee6deac030c4bc38e166cd3e3ab086ae285 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 9 Oct 1998 20:31:52 +0000 Subject: signed / unsigned issues spotted by herb (This used to be commit 0b90442021aa3adb5ae7f09c53c9e54c7655d8c5) --- source3/lib/crc32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib/crc32.c') diff --git a/source3/lib/crc32.c b/source3/lib/crc32.c index cb8bcde909..7d0b6e350d 100644 --- a/source3/lib/crc32.c +++ b/source3/lib/crc32.c @@ -51,9 +51,9 @@ void crc32_build_table(void) table lookup method. *****************************************************************/ -uint32 crc32_calc_buffer( uint32 count, uchar *buffer) +uint32 crc32_calc_buffer( uint32 count, char *buffer) { - uchar *p; + char *p; uint32 crc; p = buffer; -- cgit From 935dc98f6670ba630bd2086ef9eddcc94a0562e2 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 14 Oct 1998 06:29:20 +0000 Subject: dce/rpc (This used to be commit 69f5f9f88935de1f63ffc9aa19c0629b395e66e6) --- source3/lib/crc32.c | 116 ++++++++++++++++++++++++++-------------------------- 1 file changed, 58 insertions(+), 58 deletions(-) (limited to 'source3/lib/crc32.c') diff --git a/source3/lib/crc32.c b/source3/lib/crc32.c index 7d0b6e350d..b92bc70d12 100644 --- a/source3/lib/crc32.c +++ b/source3/lib/crc32.c @@ -1,73 +1,73 @@ /* - * Dr Dobb's Journal: http://www.ddj.com/ftp/1992/1992.05/crcman.zip + * Copyright francesco@aerra.it - code used WITHOUT acknowledgment to + * request to use it here yet received. * - * Copyright Mark R. Nelson 1992 + * must work on the dr dobb's version or find another version if + * permission not received or permission refused. * - * This code used by permission of J Erickson - * Tues 6th October 1998. Copyright acknowledged above, as agreed. * */ #include "includes.h" +extern int DEBUGLEVEL; -#define CRC32_POLYNOMIAL 0xEDB88320L - -/***************************************************************** - Instead of performing a straightforward calculation of the 32 bit - CRC using a series of logical operations, this program uses the - faster table lookup method. This routine is called once when the - program starts up to build the table which will be used later - when calculating the CRC values. - *****************************************************************/ - -static uint32 CRCTable[256]; - -void crc32_build_table(void) +static unsigned long CRCTable[256] = { - int i; - int j; - uint32 crc; - - for ( i = 0; i <= 255 ; i++ ) - { - crc = i; - for ( j = 8 ; j > 0; j-- ) - { - if ( crc & 1 ) - { - crc = ( crc >> 1 ) ^ CRC32_POLYNOMIAL; - } - else - { - crc >>= 1; - } - } - CRCTable[ i ] = crc; - } -} - -/***************************************************************** - This routine calculates the CRC for a block of data using the - table lookup method. - *****************************************************************/ + 0x00000000,0x77073096,0xEE0E612C,0x990951BA,0x076DC419,0x706AF48F, + 0xE963A535,0x9E6495A3,0x0EDB8832,0x79DCB8A4,0xE0D5E91E,0x97D2D988, + 0x09B64C2B,0x7EB17CBD,0xE7B82D07,0x90BF1D91,0x1DB71064,0x6AB020F2, + 0xF3B97148,0x84BE41DE,0x1ADAD47D,0x6DDDE4EB,0xF4D4B551,0x83D385C7, + 0x136C9856,0x646BA8C0,0xFD62F97A,0x8A65C9EC,0x14015C4F,0x63066CD9, + 0xFA0F3D63,0x8D080DF5,0x3B6E20C8,0x4C69105E,0xD56041E4,0xA2677172, + 0x3C03E4D1,0x4B04D447,0xD20D85FD,0xA50AB56B,0x35B5A8FA,0x42B2986C, + 0xDBBBC9D6,0xACBCF940,0x32D86CE3,0x45DF5C75,0xDCD60DCF,0xABD13D59, + 0x26D930AC,0x51DE003A,0xC8D75180,0xBFD06116,0x21B4F4B5,0x56B3C423, + 0xCFBA9599,0xB8BDA50F,0x2802B89E,0x5F058808,0xC60CD9B2,0xB10BE924, + 0x2F6F7C87,0x58684C11,0xC1611DAB,0xB6662D3D,0x76DC4190,0x01DB7106, + 0x98D220BC,0xEFD5102A,0x71B18589,0x06B6B51F,0x9FBFE4A5,0xE8B8D433, + 0x7807C9A2,0x0F00F934,0x9609A88E,0xE10E9818,0x7F6A0DBB,0x086D3D2D, + 0x91646C97,0xE6635C01,0x6B6B51F4,0x1C6C6162,0x856530D8,0xF262004E, + 0x6C0695ED,0x1B01A57B,0x8208F4C1,0xF50FC457,0x65B0D9C6,0x12B7E950, + 0x8BBEB8EA,0xFCB9887C,0x62DD1DDF,0x15DA2D49,0x8CD37CF3,0xFBD44C65, + 0x4DB26158,0x3AB551CE,0xA3BC0074,0xD4BB30E2,0x4ADFA541,0x3DD895D7, + 0xA4D1C46D,0xD3D6F4FB,0x4369E96A,0x346ED9FC,0xAD678846,0xDA60B8D0, + 0x44042D73,0x33031DE5,0xAA0A4C5F,0xDD0D7CC9,0x5005713C,0x270241AA, + 0xBE0B1010,0xC90C2086,0x5768B525,0x206F85B3,0xB966D409,0xCE61E49F, + 0x5EDEF90E,0x29D9C998,0xB0D09822,0xC7D7A8B4,0x59B33D17,0x2EB40D81, + 0xB7BD5C3B,0xC0BA6CAD,0xEDB88320,0x9ABFB3B6,0x03B6E20C,0x74B1D29A, + 0xEAD54739,0x9DD277AF,0x04DB2615,0x73DC1683,0xE3630B12,0x94643B84, + 0x0D6D6A3E,0x7A6A5AA8,0xE40ECF0B,0x9309FF9D,0x0A00AE27,0x7D079EB1, + 0xF00F9344,0x8708A3D2,0x1E01F268,0x6906C2FE,0xF762575D,0x806567CB, + 0x196C3671,0x6E6B06E7,0xFED41B76,0x89D32BE0,0x10DA7A5A,0x67DD4ACC, + 0xF9B9DF6F,0x8EBEEFF9,0x17B7BE43,0x60B08ED5,0xD6D6A3E8,0xA1D1937E, + 0x38D8C2C4,0x4FDFF252,0xD1BB67F1,0xA6BC5767,0x3FB506DD,0x48B2364B, + 0xD80D2BDA,0xAF0A1B4C,0x36034AF6,0x41047A60,0xDF60EFC3,0xA867DF55, + 0x316E8EEF,0x4669BE79,0xCB61B38C,0xBC66831A,0x256FD2A0,0x5268E236, + 0xCC0C7795,0xBB0B4703,0x220216B9,0x5505262F,0xC5BA3BBE,0xB2BD0B28, + 0x2BB45A92,0x5CB36A04,0xC2D7FFA7,0xB5D0CF31,0x2CD99E8B,0x5BDEAE1D, + 0x9B64C2B0,0xEC63F226,0x756AA39C,0x026D930A,0x9C0906A9,0xEB0E363F, + 0x72076785,0x05005713,0x95BF4A82,0xE2B87A14,0x7BB12BAE,0x0CB61B38, + 0x92D28E9B,0xE5D5BE0D,0x7CDCEFB7,0x0BDBDF21,0x86D3D2D4,0xF1D4E242, + 0x68DDB3F8,0x1FDA836E,0x81BE16CD,0xF6B9265B,0x6FB077E1,0x18B74777, + 0x88085AE6,0xFF0F6A70,0x66063BCA,0x11010B5C,0x8F659EFF,0xF862AE69, + 0x616BFFD3,0x166CCF45,0xA00AE278,0xD70DD2EE,0x4E048354,0x3903B3C2, + 0xA7672661,0xD06016F7,0x4969474D,0x3E6E77DB,0xAED16A4A,0xD9D65ADC, + 0x40DF0B66,0x37D83BF0,0xA9BCAE53,0xDEBB9EC5,0x47B2CF7F,0x30B5FFE9, + 0xBDBDF21C,0xCABAC28A,0x53B39330,0x24B4A3A6,0xBAD03605,0xCDD70693, + 0x54DE5729,0x23D967BF,0xB3667A2E,0xC4614AB8,0x5D681B02,0x2A6F2B94, + 0xB40BBE37,0xC30C8EA1,0x5A05DF1B,0x2D02EF8D +}; uint32 crc32_calc_buffer( uint32 count, char *buffer) { - char *p; - uint32 crc; - - p = buffer; - crc = 0xffffffff; - - while ( count-- != 0 ) + unsigned long crc=0xffffffff; + int i; + for(i=0;i> 8 ) & 0x00FFFFFFL; - temp2 = CRCTable[ ( (int) crc ^ *p++ ) & 0xff ]; - crc = temp1 ^ temp2; + crc = (crc>>8) ^ CRCTable[(buffer[i] ^ crc) & 0xff]; } - return crc; + crc^=0xffffffff; + DEBUG(10,("crc_32_calc_buffer: %x\n", crc)); + dump_data(100, buffer, count); + return crc; } - -- cgit From c09647c3e1faa54e36c383958d9ea6def911f77d Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 14 Oct 1998 07:08:43 +0000 Subject: more warnings... (This used to be commit 8b9c0bad889d4f26987d87c54b4d8bf102af1744) --- source3/lib/crc32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/crc32.c') diff --git a/source3/lib/crc32.c b/source3/lib/crc32.c index b92bc70d12..ad7131a800 100644 --- a/source3/lib/crc32.c +++ b/source3/lib/crc32.c @@ -60,7 +60,7 @@ static unsigned long CRCTable[256] = uint32 crc32_calc_buffer( uint32 count, char *buffer) { - unsigned long crc=0xffffffff; + uint32 crc=0xffffffff; int i; for(i=0;i Date: Thu, 15 Oct 1998 05:35:57 +0000 Subject: second implementation of crc32, used with permission of francesco ferrara . thanks! http://www.aerre.it/francesco (This used to be commit c48ee2bfbaec8a29b6c5da2a4e3d28937c9fb8e2) --- source3/lib/crc32.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source3/lib/crc32.c') diff --git a/source3/lib/crc32.c b/source3/lib/crc32.c index ad7131a800..8e687d30e6 100644 --- a/source3/lib/crc32.c +++ b/source3/lib/crc32.c @@ -1,9 +1,7 @@ /* - * Copyright francesco@aerra.it - code used WITHOUT acknowledgment to - * request to use it here yet received. + * Copyright Francesco Ferrara, 1998 * - * must work on the dr dobb's version or find another version if - * permission not received or permission refused. + * Used by kind permission, 14th October 1998. http://www.aerre.it/francesco * * */ -- cgit From 9307940876a6c226969e9169d55c0408cd7ab032 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 21 Oct 1998 01:35:01 +0000 Subject: fixing smbd encrypted rpcs (data lens, alloc hints, sequence nums argh). put unicode strings after SAMLOGON query regardless of whether it's an NT mailslot or a non-NT mailslot, after having observed this behaviour out of NT machines. (This used to be commit c101113ec20ed0ba633e78e4ee45596cdccaf1b5) --- source3/lib/crc32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/crc32.c') diff --git a/source3/lib/crc32.c b/source3/lib/crc32.c index 8e687d30e6..9da5b4bfe1 100644 --- a/source3/lib/crc32.c +++ b/source3/lib/crc32.c @@ -65,7 +65,7 @@ uint32 crc32_calc_buffer( uint32 count, char *buffer) crc = (crc>>8) ^ CRCTable[(buffer[i] ^ crc) & 0xff]; } crc^=0xffffffff; - DEBUG(10,("crc_32_calc_buffer: %x\n", crc)); + DEBUG(10,("crc32_calc_buffer: %x\n", crc)); dump_data(100, buffer, count); return crc; } -- cgit From 56128244261f8e4c6e1144da66c736fbc2104665 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 25 Oct 1999 19:03:27 +0000 Subject: - typecast malloc / Realloc issues. - signed / unsigned issues. (This used to be commit c8fd555179314baf1672a23db34dc8ad9f2d02bf) --- source3/lib/crc32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/crc32.c') diff --git a/source3/lib/crc32.c b/source3/lib/crc32.c index 9da5b4bfe1..39c01fa30f 100644 --- a/source3/lib/crc32.c +++ b/source3/lib/crc32.c @@ -59,7 +59,7 @@ static unsigned long CRCTable[256] = uint32 crc32_calc_buffer( uint32 count, char *buffer) { uint32 crc=0xffffffff; - int i; + uint32 i; for(i=0;i>8) ^ CRCTable[(buffer[i] ^ crc) & 0xff]; -- cgit From 3db52feb1f3b2c07ce0b06ad4a7099fa6efe3fc7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Dec 1999 13:27:58 +0000 Subject: first pass at updating head branch to be to be the same as the SAMBA_2_0 branch (This used to be commit 453a822a76780063dff23526c35408866d0c0154) --- source3/lib/crc32.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source3/lib/crc32.c') diff --git a/source3/lib/crc32.c b/source3/lib/crc32.c index 39c01fa30f..16b337c764 100644 --- a/source3/lib/crc32.c +++ b/source3/lib/crc32.c @@ -56,14 +56,12 @@ static unsigned long CRCTable[256] = 0xB40BBE37,0xC30C8EA1,0x5A05DF1B,0x2D02EF8D }; -uint32 crc32_calc_buffer( uint32 count, char *buffer) +uint32 crc32_calc_buffer( char *buffer, uint32 count) { uint32 crc=0xffffffff; - uint32 i; + int i; for(i=0;i>8) ^ CRCTable[(buffer[i] ^ crc) & 0xff]; - } crc^=0xffffffff; DEBUG(10,("crc32_calc_buffer: %x\n", crc)); dump_data(100, buffer, count); -- cgit From dc1fc3ee8ec2199bc73bb5d7ec711c6800f61d65 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 2 Oct 2001 04:29:50 +0000 Subject: Removed 'extern int DEBUGLEVEL' as it is now in the smb.h header. (This used to be commit 2d0922b0eabfdc0aaf1d0797482fef47ed7fde8e) --- source3/lib/crc32.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/lib/crc32.c') diff --git a/source3/lib/crc32.c b/source3/lib/crc32.c index 16b337c764..e026fbf861 100644 --- a/source3/lib/crc32.c +++ b/source3/lib/crc32.c @@ -7,7 +7,6 @@ */ #include "includes.h" -extern int DEBUGLEVEL; static unsigned long CRCTable[256] = { -- cgit From e1a65ecd0d14700f313bb3b97beaff8dc66fdd29 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 17 Feb 2002 18:30:01 +0000 Subject: int -> uint32 (This used to be commit 5efe39af0c89e549bb8211a39a949f80f6d1bf78) --- source3/lib/crc32.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/lib/crc32.c') diff --git a/source3/lib/crc32.c b/source3/lib/crc32.c index e026fbf861..bd4f1633e5 100644 --- a/source3/lib/crc32.c +++ b/source3/lib/crc32.c @@ -57,8 +57,7 @@ static unsigned long CRCTable[256] = uint32 crc32_calc_buffer( char *buffer, uint32 count) { - uint32 crc=0xffffffff; - int i; + uint32 crc=0xffffffff, i; for(i=0;i>8) ^ CRCTable[(buffer[i] ^ crc) & 0xff]; crc^=0xffffffff; -- cgit From 6cbe33161d195c720aaa7149d082ee72ca222c07 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 18 Mar 2003 12:12:14 +0000 Subject: Add const. (This used to be commit 38a6ad95d789b3ece7a8e697195c8851663b3cd9) --- source3/lib/crc32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib/crc32.c') diff --git a/source3/lib/crc32.c b/source3/lib/crc32.c index bd4f1633e5..da3aeaa901 100644 --- a/source3/lib/crc32.c +++ b/source3/lib/crc32.c @@ -8,7 +8,7 @@ #include "includes.h" -static unsigned long CRCTable[256] = +static const unsigned long CRCTable[256] = { 0x00000000,0x77073096,0xEE0E612C,0x990951BA,0x076DC419,0x706AF48F, 0xE963A535,0x9E6495A3,0x0EDB8832,0x79DCB8A4,0xE0D5E91E,0x97D2D988, @@ -55,7 +55,7 @@ static unsigned long CRCTable[256] = 0xB40BBE37,0xC30C8EA1,0x5A05DF1B,0x2D02EF8D }; -uint32 crc32_calc_buffer( char *buffer, uint32 count) +uint32 crc32_calc_buffer( const char *buffer, uint32 count) { uint32 crc=0xffffffff, i; for(i=0;i Date: Wed, 9 Nov 2005 19:35:23 +0000 Subject: r11614: Replace old crc32 code with one from the FreeBSD tree. * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or * code or tables extracted from it, as desired without restriction. Jeremy. (This used to be commit 11c6b8ecd601ff2f6eaf184efeed8e39f54fdcf1) --- source3/lib/crc32.c | 148 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 92 insertions(+), 56 deletions(-) (limited to 'source3/lib/crc32.c') diff --git a/source3/lib/crc32.c b/source3/lib/crc32.c index da3aeaa901..c6a13fada1 100644 --- a/source3/lib/crc32.c +++ b/source3/lib/crc32.c @@ -1,67 +1,103 @@ -/* - * Copyright Francesco Ferrara, 1998 +/*- + * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or + * code or tables extracted from it, as desired without restriction. * - * Used by kind permission, 14th October 1998. http://www.aerre.it/francesco + * First, the polynomial itself and its table of feedback terms. The + * polynomial is + * 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+X^0 * + * Note that we take it "backwards" and put the highest-order term in + * the lowest-order bit. The X^32 term is "implied"; the LSB is the + * X^31 term, etc. The X^0 term (usually shown as "+1") results in + * the MSB being 1 * + * Note that the usual hardware shift register implementation, which + * is what we're using (we're merely optimizing it by doing eight-bit + * chunks at a time) shifts bits into the lowest-order term. In our + * implementation, that means shifting towards the right. Why do we + * do it this way? Because the calculated CRC must be transmitted in + * order from highest-order term to lowest-order term. UARTs transmit + * characters in order from LSB to MSB. By storing the CRC this way + * we hand it to the UART in the order low-byte to high-byte; the UART + * sends each low-bit to hight-bit; and the result is transmission bit + * by bit from highest- to lowest-order term without requiring any bit + * shuffling on our part. Reception works similarly + * + * The feedback terms table consists of 256, 32-bit entries. Notes + * + * The table can be generated at runtime if desired; code to do so + * is shown later. It might not be obvious, but the feedback + * terms simply represent the results of eight shift/xor opera + * tions for all combinations of data and CRC register values + * + * The values must be right-shifted by eight bits by the "updcrc + * logic; the shift must be unsigned (bring in zeroes). On some + * hardware you could probably optimize the shift in assembler by + * using byte-swap instructions + * polynomial $edb88320 + * + * + * CRC32 code derived from work by Gary S. Brown. */ #include "includes.h" -static const unsigned long CRCTable[256] = -{ - 0x00000000,0x77073096,0xEE0E612C,0x990951BA,0x076DC419,0x706AF48F, - 0xE963A535,0x9E6495A3,0x0EDB8832,0x79DCB8A4,0xE0D5E91E,0x97D2D988, - 0x09B64C2B,0x7EB17CBD,0xE7B82D07,0x90BF1D91,0x1DB71064,0x6AB020F2, - 0xF3B97148,0x84BE41DE,0x1ADAD47D,0x6DDDE4EB,0xF4D4B551,0x83D385C7, - 0x136C9856,0x646BA8C0,0xFD62F97A,0x8A65C9EC,0x14015C4F,0x63066CD9, - 0xFA0F3D63,0x8D080DF5,0x3B6E20C8,0x4C69105E,0xD56041E4,0xA2677172, - 0x3C03E4D1,0x4B04D447,0xD20D85FD,0xA50AB56B,0x35B5A8FA,0x42B2986C, - 0xDBBBC9D6,0xACBCF940,0x32D86CE3,0x45DF5C75,0xDCD60DCF,0xABD13D59, - 0x26D930AC,0x51DE003A,0xC8D75180,0xBFD06116,0x21B4F4B5,0x56B3C423, - 0xCFBA9599,0xB8BDA50F,0x2802B89E,0x5F058808,0xC60CD9B2,0xB10BE924, - 0x2F6F7C87,0x58684C11,0xC1611DAB,0xB6662D3D,0x76DC4190,0x01DB7106, - 0x98D220BC,0xEFD5102A,0x71B18589,0x06B6B51F,0x9FBFE4A5,0xE8B8D433, - 0x7807C9A2,0x0F00F934,0x9609A88E,0xE10E9818,0x7F6A0DBB,0x086D3D2D, - 0x91646C97,0xE6635C01,0x6B6B51F4,0x1C6C6162,0x856530D8,0xF262004E, - 0x6C0695ED,0x1B01A57B,0x8208F4C1,0xF50FC457,0x65B0D9C6,0x12B7E950, - 0x8BBEB8EA,0xFCB9887C,0x62DD1DDF,0x15DA2D49,0x8CD37CF3,0xFBD44C65, - 0x4DB26158,0x3AB551CE,0xA3BC0074,0xD4BB30E2,0x4ADFA541,0x3DD895D7, - 0xA4D1C46D,0xD3D6F4FB,0x4369E96A,0x346ED9FC,0xAD678846,0xDA60B8D0, - 0x44042D73,0x33031DE5,0xAA0A4C5F,0xDD0D7CC9,0x5005713C,0x270241AA, - 0xBE0B1010,0xC90C2086,0x5768B525,0x206F85B3,0xB966D409,0xCE61E49F, - 0x5EDEF90E,0x29D9C998,0xB0D09822,0xC7D7A8B4,0x59B33D17,0x2EB40D81, - 0xB7BD5C3B,0xC0BA6CAD,0xEDB88320,0x9ABFB3B6,0x03B6E20C,0x74B1D29A, - 0xEAD54739,0x9DD277AF,0x04DB2615,0x73DC1683,0xE3630B12,0x94643B84, - 0x0D6D6A3E,0x7A6A5AA8,0xE40ECF0B,0x9309FF9D,0x0A00AE27,0x7D079EB1, - 0xF00F9344,0x8708A3D2,0x1E01F268,0x6906C2FE,0xF762575D,0x806567CB, - 0x196C3671,0x6E6B06E7,0xFED41B76,0x89D32BE0,0x10DA7A5A,0x67DD4ACC, - 0xF9B9DF6F,0x8EBEEFF9,0x17B7BE43,0x60B08ED5,0xD6D6A3E8,0xA1D1937E, - 0x38D8C2C4,0x4FDFF252,0xD1BB67F1,0xA6BC5767,0x3FB506DD,0x48B2364B, - 0xD80D2BDA,0xAF0A1B4C,0x36034AF6,0x41047A60,0xDF60EFC3,0xA867DF55, - 0x316E8EEF,0x4669BE79,0xCB61B38C,0xBC66831A,0x256FD2A0,0x5268E236, - 0xCC0C7795,0xBB0B4703,0x220216B9,0x5505262F,0xC5BA3BBE,0xB2BD0B28, - 0x2BB45A92,0x5CB36A04,0xC2D7FFA7,0xB5D0CF31,0x2CD99E8B,0x5BDEAE1D, - 0x9B64C2B0,0xEC63F226,0x756AA39C,0x026D930A,0x9C0906A9,0xEB0E363F, - 0x72076785,0x05005713,0x95BF4A82,0xE2B87A14,0x7BB12BAE,0x0CB61B38, - 0x92D28E9B,0xE5D5BE0D,0x7CDCEFB7,0x0BDBDF21,0x86D3D2D4,0xF1D4E242, - 0x68DDB3F8,0x1FDA836E,0x81BE16CD,0xF6B9265B,0x6FB077E1,0x18B74777, - 0x88085AE6,0xFF0F6A70,0x66063BCA,0x11010B5C,0x8F659EFF,0xF862AE69, - 0x616BFFD3,0x166CCF45,0xA00AE278,0xD70DD2EE,0x4E048354,0x3903B3C2, - 0xA7672661,0xD06016F7,0x4969474D,0x3E6E77DB,0xAED16A4A,0xD9D65ADC, - 0x40DF0B66,0x37D83BF0,0xA9BCAE53,0xDEBB9EC5,0x47B2CF7F,0x30B5FFE9, - 0xBDBDF21C,0xCABAC28A,0x53B39330,0x24B4A3A6,0xBAD03605,0xCDD70693, - 0x54DE5729,0x23D967BF,0xB3667A2E,0xC4614AB8,0x5D681B02,0x2A6F2B94, - 0xB40BBE37,0xC30C8EA1,0x5A05DF1B,0x2D02EF8D +const uint32 crc32_tab[] = { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, + 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, + 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, + 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, + 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, + 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, + 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, + 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, + 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, + 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, + 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, + 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, + 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, + 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, + 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, + 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, + 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, + 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, + 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, + 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, + 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, + 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, + 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, + 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, + 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; -uint32 crc32_calc_buffer( const char *buffer, uint32 count) +uint32 crc32_calc_buffer(const char *buf, size_t size) { - uint32 crc=0xffffffff, i; - for(i=0;i>8) ^ CRCTable[(buffer[i] ^ crc) & 0xff]; - crc^=0xffffffff; - DEBUG(10,("crc32_calc_buffer: %x\n", crc)); - dump_data(100, buffer, count); - return crc; + const unsigned char *p; + uint32 crc; + + p = buf; + crc = ~0U; + + while (size--) + crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); + + return crc ^ ~0U; } -- cgit From 0ad770a6268756d958dddaabe512341c2e32902a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 17 Nov 2005 21:57:38 +0000 Subject: r11764: Doesn't need to be exported from here. Jeremy. (This used to be commit 95665dfd77ac9959d1d538770157127a425b4b4e) --- source3/lib/crc32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/crc32.c') diff --git a/source3/lib/crc32.c b/source3/lib/crc32.c index c6a13fada1..7522ab7c81 100644 --- a/source3/lib/crc32.c +++ b/source3/lib/crc32.c @@ -42,7 +42,7 @@ #include "includes.h" -const uint32 crc32_tab[] = { +static const uint32 crc32_tab[] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, -- cgit From d1f91f7c723733113b4e9792042101c80dfc064c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 3 Dec 2005 06:46:46 +0000 Subject: r12043: It's amazing the warnings you find when compiling on a 64-bit box with gcc4 and -O6... Fix a bunch of C99 dereferencing type-punned pointer will break strict-aliasing rules errors. Also added prs_int32 (not uint32...) as it's needed in one place. Find places where prs_uint32 was being used to marshall/unmarshall a time_t (a big no no on 64-bits). More warning fixes to come. Thanks to Volker for nudging me to compile like this. Jeremy. (This used to be commit c65b752604f8f58abc4e7ae8514dc2c7f086271c) --- source3/lib/crc32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/crc32.c') diff --git a/source3/lib/crc32.c b/source3/lib/crc32.c index 7522ab7c81..a4ae90c469 100644 --- a/source3/lib/crc32.c +++ b/source3/lib/crc32.c @@ -93,7 +93,7 @@ uint32 crc32_calc_buffer(const char *buf, size_t size) const unsigned char *p; uint32 crc; - p = buf; + p = (const unsigned char *)buf; crc = ~0U; while (size--) -- cgit