patch-2.4.19 linux-2.4.19/include/asm-mips64/checksum.h
Next file: linux-2.4.19/include/asm-mips64/cpu.h
Previous file: linux-2.4.19/include/asm-mips64/cacheops.h
Back to the patch index
Back to the overall index
- Lines: 146
- Date:
Fri Aug 2 17:39:45 2002
- Orig file:
linux-2.4.18/include/asm-mips64/checksum.h
- Orig date:
Wed Jul 4 11:50:39 2001
diff -urN linux-2.4.18/include/asm-mips64/checksum.h linux-2.4.19/include/asm-mips64/checksum.h
@@ -6,6 +6,7 @@
* Copyright (C) 1995, 1996, 1997, 1998, 1999 by Ralf Baechle
* Copyright (C) 1999 Silicon Graphics, Inc.
* Copyright (C) 2001 Thiemo Seufer.
+ * Copyright (C) 2002 Maciej W. Rozycki
*/
#ifndef _ASM_CHECKSUM_H
#define _ASM_CHECKSUM_H
@@ -43,7 +44,7 @@
* Copy and checksum to user
*/
#define HAVE_CSUM_COPY_USER
-extern inline unsigned int csum_and_copy_to_user (const char *src, char *dst,
+static inline unsigned int csum_and_copy_to_user (const char *src, char *dst,
int len, int sum,
int *err_ptr)
{
@@ -82,8 +83,7 @@
"xori\t%0,0xffff\n\t"
".set\tat"
: "=r" (sum)
- : "0" (sum)
- : "$1");
+ : "0" (sum));
return sum;
}
@@ -135,8 +135,7 @@
"2:\t.set\tat\n\t"
".set\treorder"
: "=&r" (sum), "=&r" (iph), "=&r" (ihl), "=&r" (dummy)
- : "1" (iph), "2" (ihl)
- : "$1");
+ : "1" (iph), "2" (ihl));
return csum_fold(sum);
}
@@ -144,6 +143,10 @@
/*
* computes the checksum of the TCP/UDP pseudo-header
* returns a 16-bit checksum, already complemented
+ *
+ * Cast unsigned short expressions to unsigned long explicitly
+ * to avoid surprises resulting from implicit promotions to
+ * signed int. --macro
*/
static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
unsigned long daddr,
@@ -160,15 +163,14 @@
"daddu\t%0, $1\n\t"
"dsrl32\t%0, %0, 0\n\t"
".set\tat"
- : "=r" (sum)
+ : "=&r" (sum)
: "0" (daddr), "r"(saddr),
#ifdef __MIPSEL__
- "r" ((ntohs(len)<<16)+proto*256),
+ "r" (((unsigned long)ntohs(len)<<16)+proto*256),
#else
- "r" (((proto)<<16)+len),
+ "r" (((unsigned long)(proto)<<16)+len),
#endif
- "r" (sum)
- : "$1");
+ "r" (sum));
return sum;
}
@@ -196,11 +198,11 @@
}
#define _HAVE_ARCH_IPV6_CSUM
-static inline unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
- struct in6_addr *daddr,
- __u32 len,
- unsigned short proto,
- unsigned int sum)
+static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
+ struct in6_addr *daddr,
+ __u32 len,
+ unsigned short proto,
+ unsigned int sum)
{
__asm__(
".set\tnoreorder\t\t\t# csum_ipv6_magic\n\t"
@@ -214,48 +216,49 @@
"lw\t%1, 0(%2)\t\t\t# four words source address\n\t"
"addu\t%0, $1\n\t"
"addu\t%0, %1\n\t"
- "sltu\t$1, %0, $1\n\t"
+ "sltu\t$1, %0, %1\n\t"
"lw\t%1, 4(%2)\n\t"
"addu\t%0, $1\n\t"
"addu\t%0, %1\n\t"
- "sltu\t$1, %0, $1\n\t"
+ "sltu\t$1, %0, %1\n\t"
"lw\t%1, 8(%2)\n\t"
"addu\t%0, $1\n\t"
"addu\t%0, %1\n\t"
- "sltu\t$1, %0, $1\n\t"
+ "sltu\t$1, %0, %1\n\t"
"lw\t%1, 12(%2)\n\t"
"addu\t%0, $1\n\t"
"addu\t%0, %1\n\t"
- "sltu\t$1, %0, $1\n\t"
+ "sltu\t$1, %0, %1\n\t"
"lw\t%1, 0(%3)\n\t"
"addu\t%0, $1\n\t"
"addu\t%0, %1\n\t"
- "sltu\t$1, %0, $1\n\t"
+ "sltu\t$1, %0, %1\n\t"
"lw\t%1, 4(%3)\n\t"
"addu\t%0, $1\n\t"
"addu\t%0, %1\n\t"
- "sltu\t$1, %0, $1\n\t"
+ "sltu\t$1, %0, %1\n\t"
"lw\t%1, 8(%3)\n\t"
"addu\t%0, $1\n\t"
"addu\t%0, %1\n\t"
- "sltu\t$1, %0, $1\n\t"
+ "sltu\t$1, %0, %1\n\t"
"lw\t%1, 12(%3)\n\t"
"addu\t%0, $1\n\t"
"addu\t%0, %1\n\t"
- "sltu\t$1, %0, $1\n\t"
+ "sltu\t$1, %0, %1\n\t"
+
+ "addu\t%0, $1\t\t\t# Add final carry\n\t"
".set\tnoat\n\t"
".set\tnoreorder"
- : "=r" (sum), "=r" (proto)
+ : "=&r" (sum), "=&r" (proto)
: "r" (saddr), "r" (daddr),
- "0" (htonl(len)), "1" (htonl(proto)), "r" (sum)
- : "$1");
+ "0" (htonl(len)), "1" (htonl(proto)), "r" (sum));
return csum_fold(sum);
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)