|
31 | 31 | #define ATOMIC_H
|
32 | 32 |
|
33 | 33 | #define BUS_LOCK "lock ; "
|
34 |
| -/* |
35 |
| - * #define atomic_set_char(P, V) (*(unsigned char *)(P) |= (V)) |
36 |
| - */ |
37 |
| -static inline void atomic_set_char(unsigned char *p, unsigned char v) |
38 |
| -{ |
39 |
| - __asm __volatile(BUS_LOCK "orb %b1,%0" |
40 |
| - : "+m" (*p) |
41 |
| - : "q" (v) |
42 |
| - : "cc", "memory"); |
43 |
| -} |
44 |
| - |
45 |
| -/* |
46 |
| - * #define atomic_clear_char(P, V) (*(unsigned char *)(P) &= ~(V)) |
47 |
| - */ |
48 |
| -static inline void atomic_clear_char(unsigned char *p, unsigned char v) |
49 |
| -{ |
50 |
| - __asm __volatile(BUS_LOCK "andb %b1,%0" |
51 |
| - : "+m" (*p) |
52 |
| - : "q" (~v) |
53 |
| - : "cc", "memory"); |
54 |
| -} |
55 |
| - |
56 |
| -/* |
57 |
| - * #define atomic_add_char(P, V) (*(unsigned char *)(P) += (V)) |
58 |
| - */ |
59 |
| -static inline void atomic_add_char(unsigned char *p, unsigned char v) |
60 |
| -{ |
61 |
| - __asm __volatile(BUS_LOCK "addb %b1,%0" |
62 |
| - : "+m" (*p) |
63 |
| - : "q" (v) |
64 |
| - : "cc", "memory"); |
65 |
| -} |
66 |
| - |
67 |
| -/* |
68 |
| - * #define atomic_subtract_char(P, V) (*(unsigned char *)(P) -= (V)) |
69 |
| - */ |
70 |
| -static inline void atomic_subtract_char(unsigned char *p, unsigned char v) |
71 |
| -{ |
72 |
| - __asm __volatile(BUS_LOCK "subb %b1,%0" |
73 |
| - : "+m" (*p) |
74 |
| - : "q" (v) |
75 |
| - : "cc", "memory"); |
76 |
| -} |
77 |
| - |
78 |
| -/* |
79 |
| - * #define atomic_set_short(P, V) (*(unsigned short *)(P) |= (V)) |
80 |
| - */ |
81 |
| -static inline void atomic_set_short(unsigned short *p, unsigned short v) |
82 |
| -{ |
83 |
| - __asm __volatile(BUS_LOCK "orw %w1,%0" |
84 |
| - : "+m" (*p) |
85 |
| - : "r" (v) |
86 |
| - : "cc", "memory"); |
87 |
| -} |
88 |
| - |
89 |
| -/* |
90 |
| - * #define atomic_clear_short(P, V) (*(unsigned short *)(P) &= ~(V)) |
91 |
| - */ |
92 |
| -static inline void atomic_clear_short(unsigned short *p, unsigned short v) |
93 |
| -{ |
94 |
| - __asm __volatile(BUS_LOCK "andw %w1,%0" |
95 |
| - : "+m" (*p) |
96 |
| - : "r" (~v) |
97 |
| - : "cc", "memory"); |
98 |
| -} |
99 |
| - |
100 |
| -/* |
101 |
| - * #define atomic_add_short(P, V) (*(unsigned short *)(P) += (V)) |
102 |
| - */ |
103 |
| -static inline void atomic_add_short(unsigned short *p, unsigned short v) |
104 |
| -{ |
105 |
| - __asm __volatile(BUS_LOCK "addw %w1,%0" |
106 |
| - : "+m" (*p) |
107 |
| - : "r" (v) |
108 |
| - : "cc", "memory"); |
109 |
| -} |
110 |
| - |
111 |
| -/* |
112 |
| - * #define atomic_subtract_short(P, V) (*(unsigned short *)(P) -= (V)) |
113 |
| - */ |
114 |
| -static inline void atomic_subtract_short(unsigned short *p, unsigned short v) |
115 |
| -{ |
116 |
| - __asm __volatile(BUS_LOCK "subw %w1,%0" |
117 |
| - : "+m" (*p) |
118 |
| - : "r" (v) |
119 |
| - : "cc", "memory"); |
120 |
| -} |
121 | 34 |
|
122 | 35 | /*
|
123 | 36 | * #define atomic_set_int(P, V) (*(unsigned int *)(P) |= (V))
|
|
0 commit comments