projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
optimize contended normal mutex case; add int compare-and-swap atomic
[musl]
/
arch
/
x86_64
/
atomic.h
diff --git
a/arch/x86_64/atomic.h
b/arch/x86_64/atomic.h
index
7a665c1
..
04f6c28
100644
(file)
--- 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;
}
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" );
static inline void *a_swap_p(void *volatile *x, void *v)
{
__asm__( "xchg %0, %1" : "=r"(v), "=m"(*(void **)x) : "0"(v) : "memory" );