This source file includes following definitions.
- atomic_add
- atomic_sub
- atomic_inc
- atomic_dec
- atomic_dec_and_test
1 #ifndef __ARCH_M68K_ATOMIC__
2 #define __ARCH_M68K_ATOMIC__
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #define __atomic_fool_gcc(x) (*(struct { int a[100]; } *)x)
19
20 typedef int atomic_t;
21
22 static __inline__ void atomic_add(atomic_t i, atomic_t *v)
23 {
24 __asm__ __volatile__(
25 "addl %1,%0"
26 :"=m" (__atomic_fool_gcc(v))
27 :"ir" (i), "m" (__atomic_fool_gcc(v)));
28 }
29
30 static __inline__ void atomic_sub(atomic_t i, atomic_t *v)
31 {
32 __asm__ __volatile__(
33 "subl %1,%0"
34 :"=m" (__atomic_fool_gcc(v))
35 :"ir" (i), "m" (__atomic_fool_gcc(v)));
36 }
37
38 static __inline__ void atomic_inc(atomic_t *v)
39 {
40 __asm__ __volatile__(
41 "addql #1,%0"
42 :"=m" (__atomic_fool_gcc(v))
43 :"m" (__atomic_fool_gcc(v)));
44 }
45
46 static __inline__ void atomic_dec(atomic_t *v)
47 {
48 __asm__ __volatile__(
49 "subql #1,%0"
50 :"=m" (__atomic_fool_gcc(v))
51 :"m" (__atomic_fool_gcc(v)));
52 }
53
54 static __inline__ int atomic_dec_and_test(atomic_t *v)
55 {
56 __asm__ __volatile__(
57 "subql #1,%0"
58 :"=m" (__atomic_fool_gcc(v))
59 :"m" (__atomic_fool_gcc(v)));
60 return (*v <= 0);
61 }
62
63 #endif