summaryrefslogtreecommitdiffstats
path: root/atomic.h
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-03-31 09:07:24 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-03-31 09:07:24 +0000
commit26aa8b09dbc2de1c7bdd97921a273511d585e043 (patch)
treeefb400bafcf30f832e1418d3a8e448b01d7d1293 /atomic.h
parenteddf674157b304f167d965ccff80ec223b7f9ab1 (diff)
downloadrsyslog-26aa8b09dbc2de1c7bdd97921a273511d585e043.tar.gz
rsyslog-26aa8b09dbc2de1c7bdd97921a273511d585e043.tar.xz
rsyslog-26aa8b09dbc2de1c7bdd97921a273511d585e043.zip
worked a bit on atomic memory operations to support problem-free threading
(only at non-intrusive places)
Diffstat (limited to 'atomic.h')
-rw-r--r--atomic.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/atomic.h b/atomic.h
index 28ed24e5..1883e030 100644
--- a/atomic.h
+++ b/atomic.h
@@ -6,6 +6,9 @@
* because in the non-presence of them, we simply do it without atomicitiy.
* Which, for word-aligned data types, usually (but only usually!) should work.
*
+ * We are using the functions described in
+ * http:/gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html
+ *
* THESE MACROS MUST ONLY BE USED WITH WORD-SIZED DATA TYPES!
*
* Copyright 2008 Rainer Gerhards and Adiscon GmbH.
@@ -32,6 +35,9 @@
#ifndef INCLUDED_ATOMIC_H
#define INCLUDED_ATOMIC_H
-#define ATOMIC_INC(data) __sync_fetch_and_add(&data, 1);
+/* set the following to 1 if we have atomic operations (and #undef it otherwise) */
+#define DO_HAVE_ATOMICS 1
+#define ATOMIC_INC(data) ((void) __sync_fetch_and_add(&data, 1))
+#define ATOMIC_DEC_AND_FETCH(data) __sync_sub_and_fetch(&data, 1)
#endif /* #ifndef INCLUDED_ATOMIC_H */