summaryrefslogtreecommitdiffstats
path: root/include/libtf/atomic.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/libtf/atomic.h')
-rw-r--r--include/libtf/atomic.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/libtf/atomic.h b/include/libtf/atomic.h
new file mode 100644
index 0000000..ec9f1e0
--- /dev/null
+++ b/include/libtf/atomic.h
@@ -0,0 +1,19 @@
+/* atomic.h - wrapper for atomic gcc built-ins
+ *
+ * Copyright (C) 2009 Timo Teräs <timo.teras@iki.fi>
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 or later as
+ * published by the Free Software Foundation.
+ *
+ * See http://www.gnu.org/ for details.
+ */
+
+#ifndef TF_ATOMIC_H
+#define TF_ATOMIC_H
+
+#define tf_atomic_inc(var) __sync_add_and_fetch(&(var), 1)
+#define tf_atomic_dec(var) __sync_add_and_fetch(&(var), -1)
+
+#endif