This source file includes following definitions.
- atomic_add
- atomic_sub
1 #ifndef __ARCH_I386_ATOMIC__
2 #define __ARCH_I386_ATOMIC__
3
4
5
6
7
8
9
10
11
12
13
14 #define __atomic_fool_gcc(x) (*(struct { int a[100]; } *)x)
15
16 typedef int atomic_t;
17
18 extern __inline__ void atomic_add(atomic_t i, atomic_t * v)
19 {
20 unsigned long temp;
21 __asm__ __volatile__(
22 "\n1:\t"
23 "ldl_l %0,%1\n\t"
24 "addl %0,%2,%0\n\t"
25 "stl_c %0,%1\n\t"
26 "beq %0,1b\n"
27 "2:"
28 :"=&r" (temp),
29 "=m" (__atomic_fool_gcc(v))
30 :"Ir" (i),
31 "m" (__atomic_fool_gcc(v)));
32 }
33
34 extern __inline__ void atomic_sub(atomic_t i, atomic_t * v)
35 {
36 unsigned long temp;
37 __asm__ __volatile__(
38 "\n1:\t"
39 "ldl_l %0,%1\n\t"
40 "subl %0,%2,%0\n\t"
41 "stl_c %0,%1\n\t"
42 "beq %0,1b\n"
43 "2:"
44 :"=&r" (temp),
45 "=m" (__atomic_fool_gcc(v))
46 :"Ir" (i),
47 "m" (__atomic_fool_gcc(v)));
48 }
49
50 #define atomic_inc(v) atomic_add(1,(v))
51 #define atomic_dec(v) atomic_sub(1,(v))
52
53 #endif