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), "0" (__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), "0" (__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 :"0" (__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 :"0" (__atomic_fool_gcc(v)));
52 }
53
54 static __inline__ int atomic_dec_and_test(atomic_t *v)
55 {
56 char c;
57 __asm__ __volatile__(
58 "subql #1,%0; seq %1"
59 :"=m" (__atomic_fool_gcc(v)), "=d" (c)
60 :"0" (__atomic_fool_gcc(v)));
61 return c != 0;
62 }
63
64 #endif