JFFS3 & performance

Joakim Tjernlund Joakim.Tjernlund at lumentis.se
Sat Dec 18 11:26:59 EST 2004


> On Fri, 17 December 2004 12:19:55 +0100, Joakim Tjernlund wrote:
> >
> > Looked a little closer on csum_partial and I think JFFS3 can use it. You need
> > csum_fold as well:
> > seed = ~0;
> > crc = csum_fold(csum_partial(buff, len, seed));
> >
> > Don't know if it is good enough for JFFS3 but it is fast.
>
> It sure is hard to read.  Is there any version in C around?
>
> Jörn

Found this in RFC1017:

       {
           /* Compute Internet Checksum for "count" bytes
            *         beginning at location "addr".
            */
       register long sum = 0;

        while( count > 1 )  {
           /*  This is the inner loop */
               sum += * (unsigned short) addr++;
               count -= 2;
       }

           /*  Add left-over byte, if any */
       if( count > 0 )
               sum += * (unsigned char *) addr;

           /*  Fold 32-bit sum to 16 bits */
       while (sum>>16)
           sum = (sum & 0xffff) + (sum >> 16);

       checksum = ~sum;
   }





More information about the linux-mtd mailing list