]> git.buserror.net Git - polintos/scott/priv.git/blob - include/c/lowlevel/arch-x64/atomic.h
Remove #if 0 section.
[polintos/scott/priv.git] / include / c / lowlevel / arch-x64 / atomic.h
1 #ifndef _LL_ARCH_ATOMIC_H
2 #define _LL_ARCH_ATOMIC_H
3
4 #include <lowlevel/arch-x86-common/atomic.h>
5
6 static inline int ll_cmpxchg_long(unsigned long *val, unsigned long oldval,
7                                   unsigned long newval)
8 {
9         int ret;
10
11         if (_LL_SMP)
12                 asm("lock; cmpxchgq %0, %1; setz %b1" :
13                     "+m" (*val) : "r" (newval), "a" (oldval) : "memory");
14         else
15                 asm("cmpxchgq %0, %1; setz %b1" :
16                     "+m" (*val) : "r" (newval), "a" (oldval) : "memory");
17
18         return ret;
19 }
20
21 static inline unsigned long ll_xchg_long(unsigned long *ptr,
22                                          unsigned long val)
23 {
24         asm("xchgq %0, %1" : "+r" (val), "+m" (*ptr));
25         return val;
26 }
27
28 #endif