summaryrefslogtreecommitdiffstats
path: root/src/libutil/ref.h
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-26 18:50:03 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-26 18:50:03 +0000
commit86c5962983c4e1f97eccfa8636ebe5bdc88599cc (patch)
treeaa20f30dc112c0f53efa8a6821f2fd4bc16127b9 /src/libutil/ref.h
parentef3d454616a1b1bae06f035374a64fbde5bbbfff (diff)
downloadrspamd-86c5962983c4e1f97eccfa8636ebe5bdc88599cc.tar.gz
rspamd-86c5962983c4e1f97eccfa8636ebe5bdc88599cc.zip
Use atomic ops if possible
Diffstat (limited to 'src/libutil/ref.h')
-rw-r--r--src/libutil/ref.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libutil/ref.h b/src/libutil/ref.h
index 18e2c3903..1ad7d24a1 100644
--- a/src/libutil/ref.h
+++ b/src/libutil/ref.h
@@ -55,13 +55,13 @@ typedef struct ref_entry_s {
#ifdef HAVE_ATOMIC_BUILTINS
#define REF_RETAIN(obj) do { \
if ((obj) != NULL) { \
- __sync_add_and_fetch (&(obj)->ref.refcount, 1); \
+ __atomic_add_fetch (&(obj)->ref.refcount, 1, __ATOMIC_RELEASE); \
} \
} while (0)
#define REF_RELEASE(obj) do { \
if ((obj) != NULL) { \
- unsigned int _rc_priv = __sync_sub_and_fetch (&(obj)->ref.refcount, 1); \
+ unsigned int _rc_priv = __atomic_sub_fetch (&(obj)->ref.refcount, 1, __ATOMIC_ACQ_REL); \
if (_rc_priv == 0 && (obj)->ref.dtor) { \
(obj)->ref.dtor (obj); \
} \