[MIPS] Fix atomic*_sub_if_positive return value.
authorRalf Baechle <ralf@linux-mips.org>
Thu, 23 Feb 2006 14:10:53 +0000 (14:10 +0000)
committerRalf Baechle <ralf@linux-mips.org>
Mon, 27 Feb 2006 17:30:36 +0000 (17:30 +0000)
Reported and initial fix by Thomas Koeller <thomas.koeller@baslerweb.com>,
rewritten by me.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
include/asm-mips/atomic.h

index 654b97d3e13a405302cdf0e96d04f83977841bf5..2c8b853376c995892680d5cf3f9b139b57bc5b5b 100644 (file)
@@ -250,7 +250,10 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
                "       subu    %0, %1, %3                              \n"
                "       bltz    %0, 1f                                  \n"
                "       sc      %0, %2                                  \n"
+               "       .set    noreorder                               \n"
                "       beqzl   %0, 1b                                  \n"
+               "        subu   %0, %1, %3                              \n"
+               "       .set    reorder                                 \n"
                "       sync                                            \n"
                "1:                                                     \n"
                "       .set    mips0                                   \n"
@@ -266,7 +269,10 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
                "       subu    %0, %1, %3                              \n"
                "       bltz    %0, 1f                                  \n"
                "       sc      %0, %2                                  \n"
+               "       .set    noreorder                               \n"
                "       beqz    %0, 1b                                  \n"
+               "        subu   %0, %1, %3                              \n"
+               "       .set    reorder                                 \n"
                "       sync                                            \n"
                "1:                                                     \n"
                "       .set    mips0                                   \n"
@@ -598,7 +604,10 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
                "       dsubu   %0, %1, %3                              \n"
                "       bltz    %0, 1f                                  \n"
                "       scd     %0, %2                                  \n"
+               "       .set    noreorder                               \n"
                "       beqzl   %0, 1b                                  \n"
+               "        dsubu  %0, %1, %3                              \n"
+               "       .set    reorder                                 \n"
                "       sync                                            \n"
                "1:                                                     \n"
                "       .set    mips0                                   \n"
@@ -614,7 +623,10 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
                "       dsubu   %0, %1, %3                              \n"
                "       bltz    %0, 1f                                  \n"
                "       scd     %0, %2                                  \n"
+               "       .set    noreorder                               \n"
                "       beqz    %0, 1b                                  \n"
+               "        dsubu  %0, %1, %3                              \n"
+               "       .set    reorder                                 \n"
                "       sync                                            \n"
                "1:                                                     \n"
                "       .set    mips0                                   \n"