patch-1.3.31 linux/include/asm-i386/checksum.h

Next file: linux/include/asm-i386/delay.h
Previous file: linux/include/asm-i386/bitops.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.30/linux/include/asm-i386/checksum.h linux/include/asm-i386/checksum.h
@@ -103,20 +103,17 @@
  *	Fold a partial checksum without adding pseudo headers
  */
 
-static inline unsigned short int csum_fold(unsigned int sum)
+static inline unsigned int csum_fold(unsigned int sum)
 {
- 	__asm__("
- 		movl %0, %1
- 		shrl $16, %1
- 		addw %w1, %w0
- 		adcl $0, %0
- 		notl %0
- 		"
- 		: "=&r" (sum)
- 		: "0" (sum)
- 	);
- 	return sum;
- }
+	__asm__("
+		addl %1, %0
+		adcl $0xffff, %0
+		"
+		: "=r" (sum)
+		: "r" (sum << 16), "0" (sum & 0xffff0000)
+	);
+	return (~sum) >> 16;
+}
  
 /*
  * this routine is used for miscellaneous IP-like checksums, mainly

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this