Skip to contentSkip to conversation

2.5.39 s390 (14/26): inlining.

PATCH New Martin Schwidefsky 1 participant 1 message Sep 30, 2002 s390

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.5.39 s390 (14/26): inlining.

Inline csum_partial for s390, the only reason it was out-of-line previously is that some older compilers could not get the inline version right.

arch/s390/lib/Makefile +1 -2
diff -urN linux-2.5.39/arch/s390/lib/Makefile linux-2.5.39-s390/arch/s390/lib/Makefile
@@ -6,8 +6,7 @@
 
 EXTRA_AFLAGS := -traditional
 
-obj-y = checksum.o delay.o memset.o misaligned.o strcmp.o strncpy.o uaccess.o
-export-objs += misaligned.o
+obj-y = delay.o memset.o strcmp.o strncpy.o uaccess.o
 
 include $(TOPDIR)/Rules.make
 
arch/s390/lib/checksum.c +0 -57

57 lines not on this page · raw message

arch/s390/lib/misaligned.c +0 -29
diff -urN linux-2.5.39/arch/s390/lib/misaligned.c linux-2.5.39-s390/arch/s390/lib/misaligned.c
@@ -1,29 +0,0 @@
-/*
- *  arch/s390/lib/misaligned.c
- *    S390 misalignment panic stubs
- *
- *  S390 version
- *    Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
- *    Author(s): Martin Schwidefsky ([email protected]).
- *
- * xchg wants to panic if the pointer is not aligned. To avoid multiplying
- * the panic message over and over again, the panic is done in the helper
- * functions __misaligned_u32 and __misaligned_u16.
- */
-
-#include <linux/module.h> 
-#include <linux/kernel.h>
-
-void __misaligned_u16(void)
-{
-	panic("misaligned (__u16 *) in __xchg\n");
-}
-
-void __misaligned_u32(void)
-{
-	panic("misaligned (__u32 *) in __xchg\n");
-}
-
-EXPORT_SYMBOL(__misaligned_u16);
-EXPORT_SYMBOL(__misaligned_u32);
-
arch/s390x/lib/Makefile +1 -2
diff -urN linux-2.5.39/arch/s390x/lib/Makefile linux-2.5.39-s390/arch/s390x/lib/Makefile
@@ -6,8 +6,7 @@
 
 EXTRA_AFLAGS := -traditional
 
-obj-y = checksum.o delay.o memset.o misaligned.o strcmp.o strncpy.o uaccess.o
-export-objs += misaligned.o
+obj-y = delay.o memset.o strcmp.o strncpy.o uaccess.o
 
 include $(TOPDIR)/Rules.make
 
arch/s390x/lib/checksum.c +0 -40
diff -urN linux-2.5.39/arch/s390x/lib/checksum.c linux-2.5.39-s390/arch/s390x/lib/checksum.c
@@ -1,40 +0,0 @@
-/*
- *  arch/s390/lib/checksum.c
- *    S390 fast network checksum routines
- *
- *  S390 version
- *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
- *    Author(s): Ulrich Hild        (first version),
- *               Martin Schwidefsky ([email protected]),
- *               Denis Joseph Barrow ([email protected],[email protected]),
- *
- * This file contains network checksum routines
- */
- 
-#include <linux/string.h>
-#include <linux/types.h>
-#include <asm/uaccess.h>
-#include <asm/byteorder.h>
-#include <asm/checksum.h>
-
-/*
- * computes a partial checksum, e.g. for TCP/UDP fragments
- */
-unsigned int
-csum_partial (const unsigned char *buff, int len, unsigned int sum)
-{
-	  /*
-	   * Experiments with ethernet and slip connections show that buff
-	   * is aligned on either a 2-byte or 4-byte boundary.
-	   */
-        __asm__ __volatile__ (
-                "    lgr  2,%1\n"    /* address in gpr 2 */
-                "    lgfr 3,%2\n"    /* length in gpr 3 */
-                "0:  cksm %0,2\n"    /* do checksum on longs */
-                "    jo   0b\n"
-                : "+&d" (sum)
-                : "d" (buff), "d" (len)
-                : "cc", "2", "3" );
-        return sum;
-}
-
arch/s390x/lib/misaligned.c +0 -34
diff -urN linux-2.5.39/arch/s390x/lib/misaligned.c linux-2.5.39-s390/arch/s390x/lib/misaligned.c
@@ -1,34 +0,0 @@
-/*
- *  arch/s390/lib/misaligned.c
- *    S390 misalignment panic stubs
- *
- *  S390 version
- *    Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
- *    Author(s): Martin Schwidefsky ([email protected]).
- *
- * xchg wants to panic if the pointer is not aligned. To avoid multiplying
- * the panic message over and over again, the panic is done in the helper
- * functions __misaligned_u64, __misaligned_u32 and __misaligned_u16.
- */
- 
-#include <linux/module.h>
-#include <linux/kernel.h>
-
-void __misaligned_u16(void)
-{
-	panic("misaligned (__u16 *) in __xchg\n");
-}
-
-void __misaligned_u32(void)
-{
-	panic("misaligned (__u32 *) in __xchg\n");
-}
-
-void __misaligned_u64(void)
-{
-	panic("misaligned (__u64 *) in __xchg\n");
-}
-
-EXPORT_SYMBOL(__misaligned_u16);
-EXPORT_SYMBOL(__misaligned_u32);
-EXPORT_SYMBOL(__misaligned_u64);
include/asm-s390/checksum.h +25 -15
diff -urN linux-2.5.39/include/asm-s390/checksum.h linux-2.5.39-s390/include/asm-s390/checksum.h
@@ -27,13 +27,27 @@
  *
  * it's best to have buff aligned on a 32-bit boundary
  */
-unsigned int
-csum_partial(const unsigned char * buff, int len, unsigned int sum);
+static inline unsigned int
+csum_partial(const unsigned char * buff, int len, unsigned int sum)
+{
+	register_pair rp;
+	/*
+	 * Experiments with ethernet and slip connections show that buf
+	 * is aligned on either a 2-byte or 4-byte boundary.
+	 */
+	rp.subreg.even = (unsigned long) buff;
+	rp.subreg.odd = (unsigned long) len;
+	__asm__ __volatile__ (
+		"0:  cksm %0,%1\n"	/* do checksum on longs */
+		"    jo   0b\n"
+		: "+&d" (sum), "+&a" (rp) : : "cc" );
+	return sum;
+}
 
 /*
  * csum_partial as an inline function
  */
-extern inline unsigned int 
+static inline unsigned int 
 csum_partial_inline(const unsigned char * buff, int len, unsigned int sum)
 {
 	register_pair rp;
@@ -55,7 +69,7 @@
  * better 64-bit) boundary
  */
 
-extern inline unsigned int 
+static inline unsigned int 
 csum_partial_copy(const char *src, char *dst, int len,unsigned int sum)
 {
 	memcpy(dst,src,len);
@@ -71,7 +85,7 @@
  * Copy from userspace and compute checksum.  If we catch an exception
  * then zero the rest of the buffer.
  */
-extern inline unsigned int 
+static inline unsigned int 
 csum_partial_copy_from_user (const char *src, char *dst,
                                           int len, unsigned int sum,
                                           int *err_ptr)
@@ -88,7 +102,7 @@
 }
 
 
-extern inline unsigned int
+static inline unsigned int
 csum_partial_copy_nocheck (const char *src, char *dst, int len, unsigned int sum)
 {
         memcpy(dst,src,len);
@@ -98,10 +112,7 @@
 /*
  *      Fold a partial checksum without adding pseudo headers
  */
-#if 1
-unsigned short csum_fold(unsigned int sum);
-#else
-extern inline unsigned short
+static inline unsigned short
 csum_fold(unsigned int sum)
 {
 	register_pair rp;
@@ -116,14 +127,13 @@
 		: "+&d" (sum), "=d" (rp) : : "cc" );
 	return ((unsigned short) ~sum);
 }
-#endif
 
 /*
  *	This is a version of ip_compute_csum() optimized for IP headers,
  *	which always checksum on 4 octet boundaries.
  *
  */
-extern inline unsigned short
+static inline unsigned short
 ip_fast_csum(unsigned char *iph, unsigned int ihl)
 {
 	register_pair rp;
@@ -143,7 +153,7 @@
  * computes the checksum of the TCP/UDP pseudo-header
  * returns a 32-bit checksum
  */
-extern inline unsigned int 
+static inline unsigned int 
 csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr,
                    unsigned short len, unsigned short proto,
                    unsigned int sum)
@@ -176,7 +186,7 @@
  * returns a 16-bit checksum, already complemented
  */
 
-extern inline unsigned short int
+static inline unsigned short int
 csum_tcpudp_magic(unsigned long saddr, unsigned long daddr,
                   unsigned short len, unsigned short proto,
                   unsigned int sum)
@@ -189,7 +199,7 @@
  * in icmp.c
  */
 
-extern inline unsigned short
+static inline unsigned short
 ip_compute_csum(unsigned char * buff, int len)
 {
 	return csum_fold(csum_partial(buff, len, 0));
include/asm-s390/system.h +46 -63

119 lines not on this page · raw message

include/asm-s390x/checksum.h +27 -11
diff -urN linux-2.5.39/include/asm-s390x/checksum.h linux-2.5.39-s390/include/asm-s390x/checksum.h
@@ -27,13 +27,29 @@
  *
  * it's best to have buff aligned on a 32-bit boundary
  */
-unsigned int
-csum_partial(const unsigned char * buff, int len, unsigned int sum);
+static inline unsigned int
+csum_partial(const unsigned char * buff, int len, unsigned int sum)
+{
+	/*
+	 * Experiments with ethernet and slip connections show that buff
+	 * is aligned on either a 2-byte or 4-byte boundary.
+	 */
+        __asm__ __volatile__ (
+                "    lgr  2,%1\n"    /* address in gpr 2 */
+                "    lgfr 3,%2\n"    /* length in gpr 3 */
+                "0:  cksm %0,2\n"    /* do checksum on longs */
+                "    jo   0b\n"
+                : "+&d" (sum)
+                : "d" (buff), "d" (len)
+                : "cc", "2", "3" );
+        return sum;
+	
+}
 
 /*
  * csum_partial as an inline function
  */
-extern inline unsigned int 
+static inline unsigned int 
 csum_partial_inline(const unsigned char * buff, int len, unsigned int sum)
 {
 	__asm__ __volatile__ (
@@ -55,7 +71,7 @@
  * better 64-bit) boundary
  */
 
-extern inline unsigned int 
+static inline unsigned int 
 csum_partial_copy(const char *src, char *dst, int len,unsigned int sum)
 {
 	memcpy(dst,src,len);
@@ -71,7 +87,7 @@
  * Copy from userspace and compute checksum.  If we catch an exception
  * then zero the rest of the buffer.
  */
-extern inline unsigned int 
+static inline unsigned int 
 csum_partial_copy_from_user (const char *src, char *dst,
                                           int len, unsigned int sum,
                                           int *err_ptr)
@@ -87,7 +103,7 @@
 	return csum_partial(dst, len, sum);
 }
 
-extern inline unsigned int
+static inline unsigned int
 csum_partial_copy_nocheck (const char *src, char *dst, int len, unsigned int sum)
 {
         memcpy(dst,src,len);
@@ -97,7 +113,7 @@
 /*
  *      Fold a partial checksum without adding pseudo headers
  */
-extern inline unsigned short
+static inline unsigned short
 csum_fold(unsigned int sum)
 {
 	__asm__ __volatile__ (
@@ -116,7 +132,7 @@
  *	which always checksum on 4 octet boundaries.
  *
  */
-extern inline unsigned short
+static inline unsigned short
 ip_fast_csum(unsigned char *iph, unsigned int ihl)
 {
 	unsigned long sum;
@@ -137,7 +153,7 @@
  * computes the checksum of the TCP/UDP pseudo-header
  * returns a 32-bit checksum
  */
-extern inline unsigned int 
+static inline unsigned int 
 csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr,
                    unsigned short len, unsigned short proto,
                    unsigned int sum)
@@ -170,7 +186,7 @@
  * returns a 16-bit checksum, already complemented
  */
 
-extern inline unsigned short int
+static inline unsigned short int
 csum_tcpudp_magic(unsigned long saddr, unsigned long daddr,
                   unsigned short len, unsigned short proto,
                   unsigned int sum)
@@ -183,7 +199,7 @@
  * in icmp.c
  */
 
-extern inline unsigned short
+static inline unsigned short
 ip_compute_csum(unsigned char * buff, int len)
 {
 	return csum_fold(csum_partial_inline(buff, len, 0));
include/asm-s390x/system.h +53 -70

130 lines not on this page · raw message