From cde7c39de3492f8b701038af6563a6c4e01ff558 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Fri, 26 Nov 2021 11:08:57 +0100 Subject: Bugfix of c_atomic_decrement() asm version in csptr.h. Some cleanup --- include/stc/csptr.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/stc/csptr.h b/include/stc/csptr.h index 7415c20a..b702f461 100644 --- a/include/stc/csptr.h +++ b/include/stc/csptr.h @@ -65,11 +65,8 @@ typedef long atomic_count_t; #elif defined(__i386__) || defined(__x86_64__) STC_INLINE void c_atomic_increment(atomic_count_t* v) { __asm__ __volatile__("lock; incq %0" :"=m"(*v) :"m"(*v)); } - STC_INLINE atomic_count_t c_atomic_decrement(atomic_count_t* v) { - atomic_count_t r; - __asm__ __volatile__("lock; xadd %0, %1" :"=r"(r) :"m"(*v), "0"(-1)); - return r - 1; - } + STC_INLINE atomic_count_t c_atomic_decrement(atomic_count_t* v) + { __asm__ __volatile__("lock; decq %0" :"=m"(*v) :"m"(*v)); return *v; } #endif #define csptr_null {NULL, NULL} @@ -181,4 +178,4 @@ _cx_memb(_compare)(const _cx_self* x, const _cx_self* y) { #undef cx_increment #undef cx_decrement #undef i_nonatomic -#include "template.h" \ No newline at end of file +#include "template.h" -- cgit v1.2.3