linux-cvs-patches
[Top] [All Lists]

CVS Update@linux-mips.org: linux

To: linux-cvs-patches@linux-mips.org
Subject: CVS Update@linux-mips.org: linux
From: ths@linux-mips.org
Date: Fri, 08 Jul 2005 10:17:11 +0100
Reply-to: linux-mips@linux-mips.org
Sender: linux-cvs-patches-bounce@linux-mips.org
CVSROOT:        /home/cvs
Module name:    linux
Changes by:     ths@ftp.linux-mips.org  05/07/08 10:17:05

Modified files:
        include/asm-mips: checksum.h 

Log message:
        Protect noat assembly with .set push/pop and make it somewhat readable.

diff -urN linux/include/asm-mips/checksum.h linux/include/asm-mips/checksum.h
--- linux/include/asm-mips/checksum.h   2005/01/25 04:28:54     1.28
+++ linux/include/asm-mips/checksum.h   2005/07/08 09:17:05     1.29
@@ -70,14 +70,15 @@
 static inline unsigned short int csum_fold(unsigned int sum)
 {
        __asm__(
-       ".set\tnoat\t\t\t# csum_fold\n\t"
-       "sll\t$1,%0,16\n\t"
-       "addu\t%0,$1\n\t"
-       "sltu\t$1,%0,$1\n\t"
-       "srl\t%0,%0,16\n\t"
-       "addu\t%0,$1\n\t"
-       "xori\t%0,0xffff\n\t"
-       ".set\tat"
+       "       .set    push            # csum_fold\n"
+       "       .set    noat            \n"
+       "       sll     $1, %0, 16      \n"
+       "       addu    %0, $1          \n"
+       "       sltu    $1, %0, $1      \n"
+       "       srl     %0, %0, 16      \n"
+       "       addu    %0, $1          \n"
+       "       xori    %0, 0xffff      \n"
+       "       .set    pop"
        : "=r" (sum)
        : "0" (sum));
 
@@ -127,29 +128,30 @@
        unsigned int sum)
 {
        __asm__(
-       ".set\tnoat\t\t\t# csum_tcpudp_nofold\n\t"
+       "       .set    push            # csum_tcpudp_nofold\n"
+       "       .set    noat            \n"
 #ifdef CONFIG_MIPS32
-       "addu\t%0, %2\n\t"
-       "sltu\t$1, %0, %2\n\t"
-       "addu\t%0, $1\n\t"
-
-       "addu\t%0, %3\n\t"
-       "sltu\t$1, %0, %3\n\t"
-       "addu\t%0, $1\n\t"
-
-       "addu\t%0, %4\n\t"
-       "sltu\t$1, %0, %4\n\t"
-       "addu\t%0, $1\n\t"
+       "       addu    %0, %2          \n"
+       "       sltu    $1, %0, %2      \n"
+       "       addu    %0, $1          \n"
+
+       "       addu    %0, %3          \n"
+       "       sltu    $1, %0, %3      \n"
+       "       addu    %0, $1          \n"
+
+       "       addu    %0, %4          \n"
+       "       sltu    $1, %0, %4      \n"
+       "       addu    %0, $1          \n"
 #endif
 #ifdef CONFIG_MIPS64
-       "daddu\t%0, %2\n\t"
-       "daddu\t%0, %3\n\t"
-       "daddu\t%0, %4\n\t"
-       "dsll32\t$1, %0, 0\n\t"
-       "daddu\t%0, $1\n\t"
-       "dsrl32\t%0, %0, 0\n\t"
+       "       daddu   %0, %2          \n"
+       "       daddu   %0, %3          \n"
+       "       daddu   %0, %4          \n"
+       "       dsll32  $1, %0, 0       \n"
+       "       daddu   %0, $1          \n"
+       "       dsrl32  %0, %0, 0       \n"
 #endif
-       ".set\tat"
+       "       .set    pop"
        : "=r" (sum)
        : "0" (daddr), "r"(saddr),
 #ifdef __MIPSEL__
@@ -192,57 +194,57 @@
                                                     unsigned int sum)
 {
        __asm__(
-       ".set\tpush\t\t\t# csum_ipv6_magic\n\t"
-       ".set\tnoreorder\n\t"
-       ".set\tnoat\n\t"
-       "addu\t%0, %5\t\t\t# proto (long in network byte order)\n\t"
-       "sltu\t$1, %0, %5\n\t"
-       "addu\t%0, $1\n\t"
-
-       "addu\t%0, %6\t\t\t# csum\n\t"
-       "sltu\t$1, %0, %6\n\t"
-       "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"
-
-       "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"
-
-       "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"
-
-       "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"
-
-       "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"
-
-       "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"
-
-       "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"
-
-       "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"
+       "       .set    push            # csum_ipv6_magic\n"
+       "       .set    noreorder       \n"
+       "       .set    noat            \n"
+       "       addu    %0, %5          # proto (long in network byte order)\n"
+       "       sltu    $1, %0, %5      \n"
+       "       addu    %0, $1          \n"
+
+       "       addu    %0, %6          # csum\n"
+       "       sltu    $1, %0, %6      \n"
+       "       lw      %1, 0(%2)       # four words source address\n"
+       "       addu    %0, $1          \n"
+       "       addu    %0, %1          \n"
+       "       sltu    $1, %0, %1      \n"
+
+       "       lw      %1, 4(%2)       \n"
+       "       addu    %0, $1          \n"
+       "       addu    %0, %1          \n"
+       "       sltu    $1, %0, %1      \n"
+
+       "       lw      %1, 8(%2)       \n"
+       "       addu    %0, $1          \n"
+       "       addu    %0, %1          \n"
+       "       sltu    $1, %0, %1      \n"
+
+       "       lw      %1, 12(%2)      \n"
+       "       addu    %0, $1          \n"
+       "       addu    %0, %1          \n"
+       "       sltu    $1, %0, %1      \n"
+
+       "       lw      %1, 0(%3)       \n"
+       "       addu    %0, $1          \n"
+       "       addu    %0, %1          \n"
+       "       sltu    $1, %0, %1      \n"
+
+       "       lw      %1, 4(%3)       \n"
+       "       addu    %0, $1          \n"
+       "       addu    %0, %1          \n"
+       "       sltu    $1, %0, %1      \n"
+
+       "       lw      %1, 8(%3)       \n"
+       "       addu    %0, $1          \n"
+       "       addu    %0, %1          \n"
+       "       sltu    $1, %0, %1      \n"
+
+       "       lw      %1, 12(%3)      \n"
+       "       addu    %0, $1          \n"
+       "       addu    %0, %1          \n"
+       "       sltu    $1, %0, %1      \n"
 
-       "addu\t%0, $1\t\t\t# Add final carry\n\t"
-       ".set\tpop"
+       "       addu    %0, $1          # Add final carry\n"
+       "       .set    pop"
        : "=r" (sum), "=r" (proto)
        : "r" (saddr), "r" (daddr),
          "0" (htonl(len)), "1" (htonl(proto)), "r" (sum));

<Prev in Thread] Current Thread [Next in Thread>