summaryrefslogtreecommitdiffstats
path: root/runtime/atomic.h
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-06-25 15:21:29 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-06-25 15:21:29 +0200
commit4818b0081d3a265a87f9f646d79f2a2ffbcda819 (patch)
treea9edb0a994fec151300e9c11faf71356ddb7e3c7 /runtime/atomic.h
parentd116f30a877c65b4f23dbb92601251402b0f957e (diff)
downloadrsyslog-4818b0081d3a265a87f9f646d79f2a2ffbcda819.tar.gz
rsyslog-4818b0081d3a265a87f9f646d79f2a2ffbcda819.tar.xz
rsyslog-4818b0081d3a265a87f9f646d79f2a2ffbcda819.zip
bugfix: subtle synchronization issue
This may have caused a segfault under strange circumstances (but if we just run long enough with a high enough message volume, even the strangest circumstances will occur...)
Diffstat (limited to 'runtime/atomic.h')
-rw-r--r--runtime/atomic.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/runtime/atomic.h b/runtime/atomic.h
index f5ae9357..f0733f09 100644
--- a/runtime/atomic.h
+++ b/runtime/atomic.h
@@ -41,7 +41,10 @@
* They simply came in too late. -- rgerhards, 2008-04-02
*/
#ifdef HAVE_ATOMIC_BUILTINS
+# define ATOMIC_SUB(data, val) __sync_fetch_and_sub(&(data), val)
+# define ATOMIC_ADD(data, val) __sync_fetch_and_add(&(data), val)
# define ATOMIC_INC(data) ((void) __sync_fetch_and_add(&(data), 1))
+# define ATOMIC_INC_AND_FETCH(data) __sync_fetch_and_add(&(data), 1)
# define ATOMIC_DEC(data) ((void) __sync_sub_and_fetch(&(data), 1))
# define ATOMIC_DEC_AND_FETCH(data) __sync_sub_and_fetch(&(data), 1)
# define ATOMIC_FETCH_32BIT(data) ((unsigned) __sync_fetch_and_and(&(data), 0xffffffff))