summaryrefslogtreecommitdiffhomepage
path: root/include/ntapi/bits/i386/nt_atomic_i386_asm__gcc.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/ntapi/bits/i386/nt_atomic_i386_asm__gcc.h')
-rw-r--r--include/ntapi/bits/i386/nt_atomic_i386_asm__gcc.h31
1 files changed, 22 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 04c0a8f..23260e9 100644
--- a/include/ntapi/bits/i386/nt_atomic_i386_asm__gcc.h
+++ b/include/ntapi/bits/i386/nt_atomic_i386_asm__gcc.h
@@ -424,7 +424,9 @@ static __inline__ void at_store(
intptr_t val)
{
__asm__(
- "mov %1, %0"
+ "mov %1, %0;"
+ "lock;"
+ "orl $0,%0;"
: "=m" (*dst)
: "r" (val)
: "memory");
@@ -436,7 +438,9 @@ static __inline__ void at_store_32(
int32_t val)
{
__asm__(
- "mov %1, %0"
+ "mov %1, %0;"
+ "lock;"
+ "orl $0,%0;"
: "=m" (*dst)
: "r" (val)
: "memory");
@@ -445,15 +449,24 @@ static __inline__ void at_store_32(
static __inline__ void at_store_64(
volatile int64_t * dst,
- int64_t val)
+ int64_t xchg)
{
- __asm__(
- "mov %1, %0"
- : "=m" (*dst)
- : "r" (val)
- : "memory");
-}
+ int64_t cmp;
+ int64_t prev;
+ do {
+ prev = *dst;
+ cmp = prev;
+
+ __atomic_compare_exchange_n(
+ dst,
+ &cmp,
+ xchg,
+ 0,
+ __ATOMIC_SEQ_CST,
+ __ATOMIC_SEQ_CST);
+ } while (cmp != prev);
+}
static __inline__ int at_bsf(
unsigned int * index,