summaryrefslogtreecommitdiff
path: root/arch/x86_64
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-03-17 12:14:40 -0400
committerRich Felker <dalias@aerifal.cx>2011-03-17 12:14:40 -0400
commite914f8b7ec79f622fa3b017af434642f61d45ce8 (patch)
treedfba95ae52b2a5998269f7296bef97aa9fce47c4 /arch/x86_64
parent1d59f1eddbcca03063cf080ded6df13170adcb23 (diff)
downloadmusl-e914f8b7ec79f622fa3b017af434642f61d45ce8.tar.gz
musl-e914f8b7ec79f622fa3b017af434642f61d45ce8.tar.bz2
musl-e914f8b7ec79f622fa3b017af434642f61d45ce8.tar.xz
musl-e914f8b7ec79f622fa3b017af434642f61d45ce8.zip
optimize contended normal mutex case; add int compare-and-swap atomic
Diffstat (limited to 'arch/x86_64')
-rw-r--r--arch/x86_64/atomic.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/arch/x86_64/atomic.h b/arch/x86_64/atomic.h
index 7a665c1b..04f6c28d 100644
--- a/arch/x86_64/atomic.h
+++ b/arch/x86_64/atomic.h
@@ -48,6 +48,13 @@ static inline long a_cas_l(volatile void *p, long t, long s)
return t;
}
+static inline int a_cas(volatile int *p, int t, int s)
+{
+ __asm__( "lock ; cmpxchgl %3, %1"
+ : "=a"(t), "=m"(*p) : "a"(t), "r"(s) : "memory" );
+ return t;
+}
+
static inline void *a_swap_p(void *volatile *x, void *v)
{
__asm__( "xchg %0, %1" : "=r"(v), "=m"(*(void **)x) : "0"(v) : "memory" );