aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm_sparc.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm_sparc.h')
-rw-r--r--include/asm_sparc.h92
1 files changed, 0 insertions, 92 deletions
diff --git a/include/asm_sparc.h b/include/asm_sparc.h
deleted file mode 100644
index 96c8049..0000000
--- a/include/asm_sparc.h
+++ /dev/null
@@ -1,92 +0,0 @@
1/* sparc64 assembly.
2 * Don't include directly, use asm.h instead.
3 *
4 * Most of this code comes straight out of the Linux kernel.
5 *
6 * The terms of the GPL v2 apply.
7 *
8 */
9
10#define membar_safe(type) \
11do { __asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \
12 " membar " type "\n" \
13 "1:\n" \
14 : : : "memory"); \
15} while (0)
16
17#define mb() \
18 membar_safe("#LoadLoad | #LoadStore | #StoreStore | #StoreLoad")
19
20static inline void barrier(void)
21{
22 mb();
23}
24
25
26#define cpu_relax() barrier()
27
28static inline int
29cmpxchg(volatile int *m, int old, int new)
30{
31 __asm__ __volatile__("membar #StoreLoad | #LoadLoad\n"
32 "cas [%2], %3, %0\n\t"
33 "membar #StoreLoad | #StoreStore"
34 : "=&r" (new)
35 : "0" (new), "r" (m), "r" (old)
36 : "memory");
37
38 return new;
39}
40
41
42typedef struct { int counter; } atomic_t;
43
44#define ATOMIC_INIT(i) { (i) }
45
46/**
47 * atomic_read - read atomic variable
48 * @v: pointer of type atomic_t
49 *
50 * Atomically reads the value of @v.
51 */
52#define atomic_read(v) ((v)->counter)
53
54/**
55 * atomic_set - set atomic variable
56 * @v: pointer of type atomic_t
57 * @i: required value
58 *
59 * Atomically sets the value of @v to @i.
60 */
61#define atomic_set(v,i) (((v)->counter) = (i))
62
63
64/**
65 * atomic_add_return - add and return
66 * @v: pointer of type atomic_t
67 * @i: integer value to add
68 *
69 * Atomically adds @i to @v and returns @i + @v
70 */
71static __inline__ int atomic_add_return(int i, atomic_t *v)
72{
73 int old;
74 int ret;
75 goto first;
76 do {
77 cpu_relax();
78 first:
79 old = atomic_read(v);
80 ret = cmpxchg(&v->counter, old, old + i);
81 } while (ret != old);
82 return old + i;
83}
84
85static __inline__ void atomic_add(int i, atomic_t *v)
86{
87 atomic_add_return(i, v);
88}
89
90#define atomic_inc_return(v) (atomic_add_return(1,v))
91
92