summaryrefslogtreecommitdiff
path: root/arch/mips/atomic.h
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-07-12 23:18:03 -0400
committerRich Felker <dalias@aerifal.cx>2012-07-12 23:18:03 -0400
commit48d20136b033da456f7bd98dfc9c384b39891d5f (patch)
treec6327537d28d08afa8c499a976a744883ae06be9 /arch/mips/atomic.h
parent532cd3a7171667d3f18e03c7c8d9d6f7846551e4 (diff)
downloadmusl-48d20136b033da456f7bd98dfc9c384b39891d5f.tar.gz
musl-48d20136b033da456f7bd98dfc9c384b39891d5f.tar.bz2
musl-48d20136b033da456f7bd98dfc9c384b39891d5f.tar.xz
musl-48d20136b033da456f7bd98dfc9c384b39891d5f.zip
fix broken mips a_fetch_add
sc was overwriting the result
Diffstat (limited to 'arch/mips/atomic.h')
-rw-r--r--arch/mips/atomic.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/arch/mips/atomic.h b/arch/mips/atomic.h
index 33e53d4e..a09f98df 100644
--- a/arch/mips/atomic.h
+++ b/arch/mips/atomic.h
@@ -70,19 +70,19 @@ static inline int a_swap(volatile int *x, int v)
static inline int a_fetch_add(volatile int *x, int v)
{
- int new;
+ int old, dummy;
__asm__ __volatile__(
".set push\n"
".set noreorder\n"
- "1: ll %0, 0(%1)\n"
- " addu %0, %0, %2\n"
- " sc %0, 0(%1)\n"
- " beq %0, $0, 1b\n"
+ "1: ll %0, 0(%2)\n"
+ " addu %1, %0, %3\n"
+ " sc %1, 0(%2)\n"
+ " beq %1, $0, 1b\n"
" nop\n"
"1: \n"
".set pop\n"
- : "=&r"(new) : "r"(x), "r"(v) : "memory" );
- return new-v;
+ : "=&r"(old), "=&r"(dummy) : "r"(x), "r"(v) : "memory" );
+ return old;
}
static inline void a_inc(volatile int *x)