summaryrefslogtreecommitdiffhomepage
path: root/include/stc
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-11-26 11:08:57 +0100
committerTyge Løvset <[email protected]>2021-11-26 11:08:57 +0100
commitcde7c39de3492f8b701038af6563a6c4e01ff558 (patch)
tree55529f503a0925b185ccc42f3a9cad20de9a2821 /include/stc
parentf857d8215a266673e25356779f740100fe362025 (diff)
downloadSTC-modified-cde7c39de3492f8b701038af6563a6c4e01ff558.tar.gz
STC-modified-cde7c39de3492f8b701038af6563a6c4e01ff558.zip
Bugfix of c_atomic_decrement() asm version in csptr.h. Some cleanup
Diffstat (limited to 'include/stc')
-rw-r--r--include/stc/csptr.h9
1 files changed, 3 insertions, 6 deletions
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"