This source file includes following definitions.
- atomic_add
- atomic_sub
- atomic_sub_and_test
1 #ifndef __ARCH_ALPHA_ATOMIC__
2 #define __ARCH_ALPHA_ATOMIC__
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #define __atomic_fool_gcc(x) (*(struct { int a[100]; } *)x)
18
19 typedef int atomic_t;
20
21 extern __inline__ void atomic_add(atomic_t i, atomic_t * v)
22 {
23 unsigned long temp;
24 __asm__ __volatile__(
25 "\n1:\t"
26 "ldl_l %0,%1\n\t"
27 "addl %0,%2,%0\n\t"
28 "stl_c %0,%1\n\t"
29 "beq %0,1b\n"
30 "2:"
31 :"=&r" (temp),
32 "=m" (__atomic_fool_gcc(v))
33 :"Ir" (i),
34 "m" (__atomic_fool_gcc(v)));
35 }
36
37 extern __inline__ void atomic_sub(atomic_t i, atomic_t * v)
38 {
39 unsigned long temp;
40 __asm__ __volatile__(
41 "\n1:\t"
42 "ldl_l %0,%1\n\t"
43 "subl %0,%2,%0\n\t"
44 "stl_c %0,%1\n\t"
45 "beq %0,1b\n"
46 "2:"
47 :"=&r" (temp),
48 "=m" (__atomic_fool_gcc(v))
49 :"Ir" (i),
50 "m" (__atomic_fool_gcc(v)));
51 }
52
53
54
55
56 extern __inline__ int atomic_sub_and_test(atomic_t i, atomic_t * v)
57 {
58 unsigned long temp, result;
59 __asm__ __volatile__(
60 "\n1:\t"
61 "ldl_l %0,%1\n\t"
62 "subl %0,%3,%0\n\t"
63 "bis %0,%0,%2\n\t"
64 "stl_c %0,%1\n\t"
65 "beq %0,1b\n"
66 "2:"
67 :"=&r" (temp),
68 "=m" (__atomic_fool_gcc(v)),
69 "=&r" (result)
70 :"Ir" (i),
71 "m" (__atomic_fool_gcc(v)));
72 return result==0;
73 }
74
75 #define atomic_inc(v) atomic_add(1,(v))
76 #define atomic_dec(v) atomic_sub(1,(v))
77 #define atomic_dec_and_test(v) atomic_sub_and_test(1,(v))
78
79 #endif