diff options
author | Eric Andersen <andersen@codepoet.org> | 2003-01-23 07:58:29 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2003-01-23 07:58:29 +0000 |
commit | f6a7ce04b503695f1a4aaf48fc81b227d0daf052 (patch) | |
tree | f25e612f3209f4e2a8b69d0aa7d3b55e53e78dc2 /libpthread | |
parent | 7e6a89bcf073ba896a01793098c84462fd0f5f3b (diff) |
Per patch from Nathan Field at ghs.com, fix the mips __compare_and_swap inline
function. Without this fix, pthread_mutex_lock/pthread_mutex_unlock don't work
on mips.
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. + + */ + } |