summaryrefslogtreecommitdiffhomepage
path: root/include/ntapi/bits
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-05-21 22:56:45 -0400
committermidipix <writeonce@midipix.org>2016-05-22 02:37:33 -0400
commit381f65e77bcc81945e20829756a3da4a3d5c8624 (patch)
treeedff24777268f44f72b6448a28437c19035b5942 /include/ntapi/bits
parent8aa2990a9b004e448e21f272e527222c83b3ee77 (diff)
downloadntapi-381f65e77bcc81945e20829756a3da4a3d5c8624.tar.bz2
ntapi-381f65e77bcc81945e20829756a3da4a3d5c8624.tar.xz
nt_atomic.h: i386: implement at_locked_cas_64 as inline asm (distilled pain).
Diffstat (limited to 'include/ntapi/bits')
-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;
}