obcsim/msp_crc.c
unsigned long crc32(const unsigned char *data, unsigned long len, unsigned long start_remainder)
{
  unsigned long crc;
  unsigned long i;
  unsigned char j;

  /* we need to mask out the 32 least significant bits since a long can be
     larger than 32 bits. */
  crc = (~start_remainder) & 0xFFFFFFFF;

  for (i = 0; i < len; i++) {
    unsigned long rem = data[i] ^ (crc & 0xFF);
    for (j = 0; j < 8; j++) {
      if (rem & 1) {
        rem >>= 1;
        rem ^= CRC32_POLYNOMIAL;
      } else {
        rem >>= 1;
      }
    }

    crc = (crc >> 8) ^ rem;
  }

  return (~crc) & 0xFFFFFFFF;
}
/* Computes CRC32 without a lookup table */
Computes CRC32 without a lookup table
Computes CRC32 without a lookup table
unsigned long crc32(const unsigned char *data, unsigned long len, unsigned long start_remainder)
{
  unsigned long crc;
  unsigned long i;
  unsigned char j;
  crc = (~start_remainder) & 0xFFFFFFFF;
  for (i = 0; i < len; i++) {
    unsigned long rem = data[i] ^ (crc & 0xFF);
    for (j = 0; j < 8; j++) {
      if (rem & 1) {
        rem >>= 1;
        rem ^= CRC32_POLYNOMIAL;
      } else {
        rem >>= 1;
      }
    }
    crc = (crc >> 8) ^ rem;
  }
  return (~crc) & 0xFFFFFFFF;
}
unsigned long crc32 ( const unsigned char * data , unsigned long len , unsigned long start_remainder ) { unsigned long crc ; unsigned long i ; unsigned char j ; crc = ( ~ start_remainder ) & 0xFFFFFFFF ; for ( i = 0 ; i < len ; i ++ ) { unsigned long rem = data [ i ] ^ ( crc & 0xFF ) ; for ( j = 0 ; j < 8 ; j ++ ) { if ( rem & 1 ) { rem >>= 1 ; rem ^= CRC32_POLYNOMIAL ; } else { rem >>= 1 ; } } crc = ( crc >> 8 ) ^ rem ; } return ( ~ crc ) & 0xFFFFFFFF ; }
Computes CRC32 without a lookup table
Computes CRC32 without a lookup table
/* we need to mask out the 32 least significant bits since a long can be
     larger than 32 bits. */