From 517660f1922aa1ad33831b08d90359241cb37118 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 1 Apr 1999 16:36:22 +0000 Subject: Moved sparc specific version of in_cksum_hdr to an inline routine like the reset of the CPU specific implementations after comment from Eric Norum. --- cpukit/libnetworking/machine/in_cksum.h | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'cpukit/libnetworking/machine') diff --git a/cpukit/libnetworking/machine/in_cksum.h b/cpukit/libnetworking/machine/in_cksum.h index ba3c3668f6..dd2e01d4de 100644 --- a/cpukit/libnetworking/machine/in_cksum.h +++ b/cpukit/libnetworking/machine/in_cksum.h @@ -157,6 +157,49 @@ in_cksum_update(struct ip *ip) ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); } +/* + * SPARC Version + */ + +#elif (defined(__GNUC__) && defined(sparc)) + +static __inline u_int +in_cksum_hdr(const struct ip *ip) +{ + register u_int sum = 0; + register u_int tmp_o2; + register u_int tmp_o3; + + __asm__ volatile (" + ld [%0], %1 ; \ + ld [%0+4], %2 ; \ + addcc %1, %2, %1 ; \ + ld [%0+8], %2 ; \ + addxcc %1, %2, %1 ; \ + ld [%0+12], %2 ; \ + addxcc %1, %2, %1 ; \ + ld [%0+16], %2 ; \ + addxcc %1, %2, %1 ; \ + set 0x0ffff, %3 ; \ + srl %1, 16, %2 ; \ + and %1, %3, %1 ; \ + addx %1, %2, %1 ; \ + srl %1, 16, %1 ; \ + add %1, %%g0, %1 ; \ + neg %1 ; \ + and %1, %3, %1 ; \ + " : "=r" (ip), "=r" (sum), "=r" (tmp_o2), "=r" (tmp_o3) + : "0" (ip), "1" (sum) + ); + return sum; +} + +#define in_cksum_update(ip) \ + do { \ + int __tmpsum; \ + __tmpsum = (int)ntohs(ip->ip_sum) + 256; \ + ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16)); \ + } while(0) /* * Here is the generic, portable, inefficient algorithm. */ -- cgit v1.2.3