summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/ntapi/bits/i386/nt_atomic_i386_asm__gcc.h28
1 files changed, 19 insertions, 9 deletions
diff --git a/include/ntapi/bits/i386/nt_atomic_i386_asm__gcc.h b/include/ntapi/bits/i386/nt_atomic_i386_asm__gcc.h
index 23260e9..1e9ed71 100644
--- a/include/ntapi/bits/i386/nt_atomic_i386_asm__gcc.h
+++ b/include/ntapi/bits/i386/nt_atomic_i386_asm__gcc.h
@@ -251,15 +251,25 @@ static __inline__ int64_t at_locked_cas_64(
int64_t cmp,
int64_t xchg)
{
- __atomic_compare_exchange_n(
- dst,
- &cmp,
- xchg,
- 0,
- __ATOMIC_SEQ_CST,
- __ATOMIC_SEQ_CST);
-
- return cmp;
+ unsigned edx, eax;
+ unsigned ecx, ebx;
+
+ eax = (unsigned)cmp;
+ edx = (uint64_t)cmp >> 32;
+
+ ebx = (unsigned)xchg;
+ ecx = (uint64_t)xchg >> 32;
+
+ __asm__ volatile (
+ "lock;"
+ "cmpxchg8b %6"
+
+ : "=a" (eax), "=d" (edx)
+ : "a" (eax), "d" (edx), "b" (ebx), "c" (ecx), "m" (*dst)
+ : "memory");
+
+
+ return ((int64_t)edx << 32) + eax;
}