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


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

add test, symbolic names for consts

Location:
release/4/crc/trunk
Files:
3 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<#
  • release/4/crc/trunk/crc.setup

    r20283 r30538  
    55(verify-extension-name "crc")
    66
    7 (setup-shared-extension-module 'crc (extension-version "1.0.0")
     7(setup-shared-extension-module 'crc (extension-version "1.0.1")
    88  #:compile-options '(
    99    -scrutinize
  • release/4/crc/trunk/tests/run.scm

    r19820 r30538  
     1(use test)
     2(use crc)
     3
     4(test #x00000000 (crc32 ""))
     5(test #x414fa339 (crc32 "The quick brown fox jumps over the lazy dog"))
     6
     7(test-exit)
Note: See TracChangeset for help on using the changeset viewer.