diff options
Diffstat (limited to 'libpthread')
-rw-r--r-- | libpthread/linuxthreads/sysdeps/mips/pt-machine.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libpthread/linuxthreads/sysdeps/mips/pt-machine.h b/libpthread/linuxthreads/sysdeps/mips/pt-machine.h index 527392308..c40ab9e3e 100644 --- a/libpthread/linuxthreads/sysdeps/mips/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/mips/pt-machine.h @@ -77,6 +77,7 @@ __compare_and_swap (long int *p, long int oldval, long int newval) "1:\tll\t%0,%4\n\t" ".set\tnoreorder\n\t" "bne\t%0,%2,2f\n\t" + "move\t%0,$0\n\t" /*[NDF] Failure case. */ "move\t%0,%3\n\t" ".set\treorder\n\t" "sc\t%0,%1\n\t" @@ -87,4 +88,30 @@ __compare_and_swap (long int *p, long int oldval, long int newval) : "r"(oldval), "r"(newval), "m"(*p)); return ret; + + /* + 1: load locked: into ret(%0), from *p(0(%4)) + branch to 2 if ret(%0) != oldval(%2) + Delay slot: move 0 into ret(%0) // [NDF] Added + Don't branch case: + move newval(%3) into ret(%0) + setcompare ret(%0) into *p(0(%1)) + branch to 1 if ret(%0) == 0 (sc failed) + Delay slot: unknown/none + return + + 2: Delay slot + return + +ll a b +Sets a to the value pointed to by address b, and "locks" b so that if +any of a number of things are attempted that might access b then the +next sc will fail. + +sc a b +Sets the memory address pointed to by b to the value in a atomically. +If it succeeds then a will be set to 1, if it fails a will be set to 0. + + */ + } |