summaryrefslogtreecommitdiffstats
path: root/lib/libcompiler_rt/__sync_fetch_and_add_4.c
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2011-12-27 22:13:51 +0000
committered <ed@FreeBSD.org>2011-12-27 22:13:51 +0000
commit52306b41a65349c9fb64a1e03d2b593af6927dbd (patch)
tree55052b5fbd1048f4b1c9e2fdcd09939c5337b577 /lib/libcompiler_rt/__sync_fetch_and_add_4.c
parentc8ed04c26b6758354853a6bed4629f71d0d01a7d (diff)
downloadFreeBSD-src-52306b41a65349c9fb64a1e03d2b593af6927dbd.zip
FreeBSD-src-52306b41a65349c9fb64a1e03d2b593af6927dbd.tar.gz
Add locally implemented atomic intrinsics to libcompiler_rt.
The built-in atomic operations are not implemented in our version of GCC 4.2 for the ARM and MIPS architectures. Instead of emitting locked instructions, they generate calls to functions that can be implemented in the C runtime. Only implement the atomic operations that are used by <stdatomic.h> for datatype sizes that are supported by atomic(9). This means that on these architectures, we can only use atomic operations on 32-bits and 64-bits variables, which is typically sufficient. This makes <stdatomic.h> work on all architectures except MIPS, since MIPS and SPARC64 still use libgcc. Converting these architectures to libcompiler_rt is on my todo list.
Diffstat (limited to 'lib/libcompiler_rt/__sync_fetch_and_add_4.c')
-rw-r--r--lib/libcompiler_rt/__sync_fetch_and_add_4.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/libcompiler_rt/__sync_fetch_and_add_4.c b/lib/libcompiler_rt/__sync_fetch_and_add_4.c
new file mode 100644
index 0000000..3c11a3b
--- /dev/null
+++ b/lib/libcompiler_rt/__sync_fetch_and_add_4.c
@@ -0,0 +1,6 @@
+/* $FreeBSD$ */
+#define NAME __sync_fetch_and_add_4
+#define TYPE uint32_t
+#define FETCHADD(x, y) atomic_fetchadd_32(x, y)
+
+#include "__sync_fetch_and_op_n.h"
OpenPOWER on IntegriCloud