powerpc: Fix casueword(9) post-r349951
'=' asm constraint marks a variable as write-only. Because of this, gcc throws away the initialization of 'res', causing garbage to be returned if the CAS was successful. Use '+' to mark res as read/write, so that the initialization stays in the generated asm. Also, fix the reservation clearing stwcx store index register in casueword32, and only do the dummy store when needed, skip it if the real store has already succeeded.
This commit is contained in:
parent
59c3949700
commit
462a300755
@ -456,13 +456,13 @@ casueword32(volatile uint32_t *addr, uint32_t old, uint32_t *oldvalp,
|
||||
"cmplw %4, %0\n\t" /* compare */
|
||||
"bne 1f\n\t" /* exit if not equal */
|
||||
"stwcx. %5, 0, %3\n\t" /* attempt to store */
|
||||
"bne- 1f\n\t" /* if failed */
|
||||
"b 2f\n\t" /* we've succeeded */
|
||||
"bne- 2f\n\t" /* if failed */
|
||||
"b 3f\n\t" /* we've succeeded */
|
||||
"1:\n\t"
|
||||
"stwcx. %0, 0, %4\n\t" /* clear reservation (74xx) */
|
||||
"li %2, 1\n\t"
|
||||
"2:\n\t"
|
||||
: "=&r" (val), "=m" (*p), "=&r" (res)
|
||||
"stwcx. %0, 0, %3\n\t" /* clear reservation (74xx) */
|
||||
"2:li %2, 1\n\t"
|
||||
"3:\n\t"
|
||||
: "=&r" (val), "=m" (*p), "+&r" (res)
|
||||
: "r" (p), "r" (old), "r" (new), "m" (*p)
|
||||
: "cr0", "memory");
|
||||
|
||||
@ -511,13 +511,13 @@ casueword(volatile u_long *addr, u_long old, u_long *oldvalp, u_long new)
|
||||
"cmpld %4, %0\n\t" /* compare */
|
||||
"bne 1f\n\t" /* exit if not equal */
|
||||
"stdcx. %5, 0, %3\n\t" /* attempt to store */
|
||||
"bne- 1f\n\t" /* if failed */
|
||||
"b 2f\n\t" /* we've succeeded */
|
||||
"bne- 2f\n\t" /* if failed */
|
||||
"b 3f\n\t" /* we've succeeded */
|
||||
"1:\n\t"
|
||||
"stdcx. %0, 0, %3\n\t" /* clear reservation (74xx) */
|
||||
"li %2, 1\n\t"
|
||||
"2:\n\t"
|
||||
: "=&r" (val), "=m" (*p), "=&r" (res)
|
||||
"2:li %2, 1\n\t"
|
||||
"3:\n\t"
|
||||
: "=&r" (val), "=m" (*p), "+&r" (res)
|
||||
: "r" (p), "r" (old), "r" (new), "m" (*p)
|
||||
: "cr0", "memory");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user