summaryrefslogtreecommitdiffstats
path: root/lib/libc_r
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2002-11-16 17:05:06 +0000
committermarcel <marcel@FreeBSD.org>2002-11-16 17:05:06 +0000
commit448c522a41592e4428f041449236ea9cae62da5e (patch)
treeb6338e19ceea921cd4469d68ea0cd64b12298d6b /lib/libc_r
parent0f47f00a644da2af9b6cd625bb5b1c38a77a1463 (diff)
downloadFreeBSD-src-448c522a41592e4428f041449236ea9cae62da5e.zip
FreeBSD-src-448c522a41592e4428f041449236ea9cae62da5e.tar.gz
Implement the lock with a cmpxchg instruction instead of a xchg.
Both are atomic, but the cmpxchg has memory ordering hints. We give this acquire semantics. NOTE: The unlock in libc_r is implemented by a "normal" assign statement. This is not correct on ia64 due to the memory ordering characteristics of the architecture. We need release semantics for an unlock.
Diffstat (limited to 'lib/libc_r')
-rw-r--r--lib/libc_r/arch/ia64/_atomic_lock.S5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libc_r/arch/ia64/_atomic_lock.S b/lib/libc_r/arch/ia64/_atomic_lock.S
index 836b375..d2fc18a 100644
--- a/lib/libc_r/arch/ia64/_atomic_lock.S
+++ b/lib/libc_r/arch/ia64/_atomic_lock.S
@@ -38,11 +38,12 @@
* is not currently locked.
*
* long _atomic_lock(long *);
- * eax will contain the return value (zero if lock obtained).
*/
ENTRY(_atomic_lock, 1)
+ mov ar.ccv = r0
add r14 = 1, r0
+ nop 0
;;
- xchg8 r8 = [r32], r14
+ cmpxchg8.acq r8 = [r32], r14, ar.ccv
br.ret.sptk rp
END(_atomic_lock)
OpenPOWER on IntegriCloud