JFFS3 & performance

Joakim Tjernlund Joakim.Tjernlund at lumentis.se
Sat Dec 18 11:25:00 EST 2004


> On Fri, 17 December 2004 11:33:42 +0000, David Vrabel wrote:
> >
> > (Also, I wouldn't have thought crc16 on 32 bit archs would have any
> > significant performance benefits.  But since I don't know either the
> > crc16 or crc32 algorithms... *shrug*)
>
> See my earlier posts in this thread for the algorithms.  Without
> special optimizations, you can process 16 bits at a time for crc16 and
> 0 (zero) bits at a time for crc32.
>
> Jörn

Hi Jörn

Care to run this in your test program? Use the
same table as tglx posted. This will only work on LE machines
for now.

 Jocke

#define DO_CRC(x) crc = crc16tab[ (crc ^ (x)) & 255 ] ^ (crc>>8)

unsigned short crc16 (unsigned char *buf, size_t len)
{
  const unsigned short  *b =(unsigned short *)buf;
  unsigned short crc = 0xffff;

  if(len >= 2){
    /* load data 16 bits wide, xor data 16 bits wide. */
    size_t save_len = len & 1;
    len = len >> 1;
    do {
      crc ^= *b++;
      DO_CRC(0);
      DO_CRC(0);
    } while (--len);
    len = save_len;
  }
  /* And the last few bytes */
  if(len){
      unsigned char *p = (unsigned char *)b;
      DO_CRC(*p);
  }
  return crc;
}





More information about the linux-mtd mailing list