Changeset 30538 in project for release/4/crc/trunk/crc.scm


Ignore:
Timestamp:
03/08/14 19:18:42 (7 years ago)
Author:
Kon Lovett
Message:

add test, symbolic names for consts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/crc/trunk/crc.scm

    r19850 r30538  
    6666    711928724UL, 3020668471UL, 3272380065UL, 1510334235UL, 755167117UL};
    6767
     68#define CRCPOLY   0xEDB88320L
     69#define CRCINV    0x5B358FD3L // inverse poly of (x^N) mod CRCPOLY
     70#define INITXOR   0xFFFFFFFFL
     71#define FINALXOR  0xFFFFFFFFL
     72
    6873#if 0
    6974/* Flag: has the table been computed? Initially false. */
     
    8186    for (k = 0; k < 8; k++) {
    8287      if (c & 1)
    83         c = 0xedb88320L ^ (c >> 1);
     88        c = CRCPOLY ^ (c >> 1);
    8489      else
    85         c = (c >> 1);
     90        c >>= 1;
    8691    }
    8792    crc_table[n] = c;
     
    113118uint32_t crc(uint8_t *buf, int len)
    114119{
    115   return update_crc(0xffffffffL, buf, len) ^ 0xffffffffL;
     120  return update_crc(INITXOR, buf, len) ^ FINALXOR;
    116121}
    117122<#
Note: See TracChangeset for help on using the changeset viewer.