summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/arc/bits/atomic.h
diff options
context:
space:
mode:
authorVineet Gupta <vgupta@synopsys.com>2014-07-25 17:39:05 +0530
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2014-08-18 11:52:34 +0200
commit873fa5beccbb4e95d1bbb9afb6a0eec02811f09b (patch)
tree17ceb2c595fe9a491f3e7fa91d7c379babf2c356 /libc/sysdeps/linux/arc/bits/atomic.h
parent6915b3a6b96e8e34601941c0eb7519cde1c0f999 (diff)
NPTL: ARC support
Signed-off-by: Vineet Gupta <vgupta@synopsys.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libc/sysdeps/linux/arc/bits/atomic.h')
-rw-r--r--libc/sysdeps/linux/arc/bits/atomic.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/arc/bits/atomic.h b/libc/sysdeps/linux/arc/bits/atomic.h
new file mode 100644
index 000000000..d4abf4eb7
--- /dev/null
+++ b/libc/sysdeps/linux/arc/bits/atomic.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <stdint.h>
+#include <sysdep.h>
+
+typedef int8_t atomic8_t;
+typedef uint8_t uatomic8_t;
+typedef int_fast8_t atomic_fast8_t;
+typedef uint_fast8_t uatomic_fast8_t;
+
+typedef int32_t atomic32_t;
+typedef uint32_t uatomic32_t;
+typedef int_fast32_t atomic_fast32_t;
+typedef uint_fast32_t uatomic_fast32_t;
+
+typedef intptr_t atomicptr_t;
+typedef uintptr_t uatomicptr_t;
+typedef intmax_t atomic_max_t;
+typedef uintmax_t uatomic_max_t;
+
+void __arc_link_error (void);
+
+#define atomic_full_barrier() \
+ __asm__ __volatile__("": : :"memory")
+
+/* Atomic compare and exchange. */
+
+#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
+ ({ __arc_link_error (); oldval; })
+
+#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
+ ({ __arc_link_error (); oldval; })
+
+#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
+ ({ \
+ __typeof(oldval) prev; \
+ \
+ __asm__ __volatile__( \
+ "1: llock %0, [%1] \n" \
+ " brne %0, %2, 2f \n" \
+ " scond %3, [%1] \n" \
+ " bnz 1b \n" \
+ "2: \n" \
+ : "=&r"(prev) \
+ : "r"(mem), "ir"(oldval), \
+ "r"(newval) /* can't be "ir". scond can't take limm for "b" */\
+ : "cc", "memory"); \
+ \
+ prev; \
+ })
+
+#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
+ ({ __arc_link_error (); oldval; })