summaryrefslogtreecommitdiffstats
path: root/lib/checksum.c
Commit message (Collapse)AuthorAgeFilesLines
* lib/checksum: fix one more thinkoArnd Bergmann2009-11-031-2/+2
| | | | | | | | | | | When do_csum gets unaligned data, we really need to treat the first byte as an even byte, not an odd byte, because we swap the two halves later. Found by Mike's checksum-selftest module. Reported-by: Mike Frysinger <vapier.adi@gmail.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
* lib/checksum.c: make do_csum optionalArnd Bergmann2009-11-031-0/+2
| | | | | | | | | | | | | Mike Frysinger suggested that do_csum should be optional so that an architecture can use the generic checksum code but still provide an optimized fast-path for the most critical function. This can mean an implementation using inline assembly, or in case of Alpha one using 64-bit arithmetic in C. Cc: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
* lib/checksum.c: use 32-bit arithmetic consistentlyArnd Bergmann2009-11-031-4/+4
| | | | | | | | | | | | | The use of 'unsigned long' variables in the 32-bit part of do_csum() is confusing at best, and potentially broken for long input on 64-bit machines. This changes the code to use 'unsigned int' instead, which makes the code behave in the same (correct) way on both 32 and 64 bit machines. Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
* lib/checksum.c: fix endianess bugArnd Bergmann2009-06-191-1/+9
| | | | | | | | | | | | | | | | | The new generic checksum code has a small dependency on endianess and worked only on big-endian systems. I could not find a nice efficient way to express this, so I added an #ifdef. Using 'result += le16_to_cpu(*buff);' would have worked as well, but would be slightly less efficient on big-endian systems and IMHO would not be clearer. Also fix a bug that prevents this from working on 64-bit machines. If you have a 64-bit CPU and want to use the generic checksum code, you should probably do some more optimizations anyway, but at least the code should not break. Reported-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
* add generic lib/checksum.cArnd Bergmann2009-06-111-0/+193
Add a generic (unoptimized) implementation of checksum.c in pure C for use by all architectures that cannot be bother with implementing their own version. Based on microblaze code by Michal Simek <monstr@monstr.eu> Cc: Michal Simek <monstr@monstr.eu> Signed-off-by: Remis Lima Baima <remis.developer@googlemail.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de>