Subversion Repositories Kolibri OS

Rev

Rev 5270 | Rev 6934 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5270 Rev 6082
Line 21... Line 21...
21
#if BITS_PER_LONG == 64
21
#if BITS_PER_LONG == 64
Line 22... Line 22...
22
 
22
 
Line 23... Line 23...
23
typedef atomic64_t atomic_long_t;
23
typedef atomic64_t atomic_long_t;
-
 
24
 
Line 24... Line -...
24
 
-
 
25
#define ATOMIC_LONG_INIT(i)	ATOMIC64_INIT(i)
-
 
26
 
-
 
27
static inline long atomic_long_read(atomic_long_t *l)
-
 
28
{
-
 
29
	atomic64_t *v = (atomic64_t *)l;
-
 
30
 
-
 
31
	return (long)atomic64_read(v);
-
 
32
}
-
 
33
 
-
 
34
static inline void atomic_long_set(atomic_long_t *l, long i)
-
 
35
{
-
 
36
	atomic64_t *v = (atomic64_t *)l;
-
 
37
 
-
 
38
	atomic64_set(v, i);
-
 
39
}
-
 
40
 
-
 
41
static inline void atomic_long_inc(atomic_long_t *l)
-
 
42
{
-
 
43
	atomic64_t *v = (atomic64_t *)l;
-
 
44
 
-
 
45
	atomic64_inc(v);
-
 
46
}
-
 
47
 
-
 
48
static inline void atomic_long_dec(atomic_long_t *l)
-
 
49
{
-
 
50
	atomic64_t *v = (atomic64_t *)l;
-
 
51
 
-
 
52
	atomic64_dec(v);
-
 
53
}
-
 
54
 
-
 
55
static inline void atomic_long_add(long i, atomic_long_t *l)
-
 
56
{
-
 
57
	atomic64_t *v = (atomic64_t *)l;
-
 
58
 
-
 
59
	atomic64_add(i, v);
-
 
60
}
-
 
61
 
-
 
62
static inline void atomic_long_sub(long i, atomic_long_t *l)
-
 
63
{
-
 
64
	atomic64_t *v = (atomic64_t *)l;
-
 
65
 
-
 
66
	atomic64_sub(i, v);
-
 
67
}
-
 
68
 
-
 
69
static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
-
 
70
{
-
 
71
	atomic64_t *v = (atomic64_t *)l;
-
 
72
 
-
 
73
	return atomic64_sub_and_test(i, v);
-
 
74
}
-
 
75
 
-
 
76
static inline int atomic_long_dec_and_test(atomic_long_t *l)
-
 
77
{
-
 
78
	atomic64_t *v = (atomic64_t *)l;
-
 
79
 
-
 
80
	return atomic64_dec_and_test(v);
-
 
81
}
-
 
82
 
-
 
83
static inline int atomic_long_inc_and_test(atomic_long_t *l)
-
 
84
{
-
 
85
	atomic64_t *v = (atomic64_t *)l;
-
 
86
 
-
 
87
	return atomic64_inc_and_test(v);
-
 
88
}
-
 
89
 
-
 
90
static inline int atomic_long_add_negative(long i, atomic_long_t *l)
-
 
91
{
-
 
92
	atomic64_t *v = (atomic64_t *)l;
-
 
93
 
-
 
94
	return atomic64_add_negative(i, v);
-
 
95
}
-
 
96
 
-
 
97
static inline long atomic_long_add_return(long i, atomic_long_t *l)
-
 
98
{
-
 
99
	atomic64_t *v = (atomic64_t *)l;
-
 
100
 
-
 
101
	return (long)atomic64_add_return(i, v);
-
 
102
}
-
 
103
 
-
 
104
static inline long atomic_long_sub_return(long i, atomic_long_t *l)
-
 
105
{
-
 
106
	atomic64_t *v = (atomic64_t *)l;
-
 
107
 
-
 
108
	return (long)atomic64_sub_return(i, v);
-
 
109
}
-
 
110
 
-
 
111
static inline long atomic_long_inc_return(atomic_long_t *l)
-
 
112
{
-
 
113
	atomic64_t *v = (atomic64_t *)l;
-
 
114
 
-
 
115
	return (long)atomic64_inc_return(v);
-
 
116
}
-
 
117
 
-
 
118
static inline long atomic_long_dec_return(atomic_long_t *l)
-
 
119
{
-
 
120
	atomic64_t *v = (atomic64_t *)l;
-
 
121
 
-
 
122
	return (long)atomic64_dec_return(v);
-
 
123
}
-
 
124
 
-
 
125
static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
-
 
126
{
-
 
127
	atomic64_t *v = (atomic64_t *)l;
25
#define ATOMIC_LONG_INIT(i)	ATOMIC64_INIT(i)
128
 
-
 
129
	return (long)atomic64_add_unless(v, a, u);
-
 
130
}
-
 
131
 
-
 
132
#define atomic_long_inc_not_zero(l) atomic64_inc_not_zero((atomic64_t *)(l))
-
 
133
 
-
 
134
#define atomic_long_cmpxchg(l, old, new) \
-
 
135
	(atomic64_cmpxchg((atomic64_t *)(l), (old), (new)))
-
 
136
#define atomic_long_xchg(v, new) \
-
 
Line 137... Line 26...
137
	(atomic64_xchg((atomic64_t *)(v), (new)))
26
#define ATOMIC_LONG_PFX(x)	atomic64 ## x
Line 138... Line 27...
138
 
27
 
139
#else  /*  BITS_PER_LONG == 64  */
28
#else
140
 
-
 
141
typedef atomic_t atomic_long_t;
-
 
Line 142... Line -...
142
 
-
 
143
#define ATOMIC_LONG_INIT(i)	ATOMIC_INIT(i)
29
 
Line -... Line 30...
-
 
30
typedef atomic_t atomic_long_t;
-
 
31
 
-
 
32
#define ATOMIC_LONG_INIT(i)	ATOMIC_INIT(i)
-
 
33
#define ATOMIC_LONG_PFX(x)	atomic ## x
-
 
34
 
-
 
35
#endif
-
 
36
 
-
 
37
#define ATOMIC_LONG_READ_OP(mo)						\
-
 
38
static inline long atomic_long_read##mo(const atomic_long_t *l)		\
-
 
39
{									\
-
 
40
	ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l;		\
-
 
41
									\
-
 
42
	return (long)ATOMIC_LONG_PFX(_read##mo)(v);			\
144
static inline long atomic_long_read(atomic_long_t *l)
43
}
-
 
44
ATOMIC_LONG_READ_OP()
-
 
45
ATOMIC_LONG_READ_OP(_acquire)
-
 
46
 
-
 
47
#undef ATOMIC_LONG_READ_OP
145
{
48
 
-
 
49
#define ATOMIC_LONG_SET_OP(mo)						\
-
 
50
static inline void atomic_long_set##mo(atomic_long_t *l, long i)	\
-
 
51
{									\
-
 
52
	ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l;		\
-
 
53
									\
-
 
54
	ATOMIC_LONG_PFX(_set##mo)(v, i);				\
146
	atomic_t *v = (atomic_t *)l;
55
}
-
 
56
ATOMIC_LONG_SET_OP()
-
 
57
ATOMIC_LONG_SET_OP(_release)
-
 
58
 
-
 
59
#undef ATOMIC_LONG_SET_OP
-
 
60
 
-
 
61
#define ATOMIC_LONG_ADD_SUB_OP(op, mo)					\
-
 
62
static inline long							\
-
 
63
atomic_long_##op##_return##mo(long i, atomic_long_t *l)			\
-
 
64
{									\
-
 
65
	ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l;		\
-
 
66
									\
-
 
67
	return (long)ATOMIC_LONG_PFX(_##op##_return##mo)(i, v);		\
-
 
68
}
-
 
69
ATOMIC_LONG_ADD_SUB_OP(add,)
-
 
70
ATOMIC_LONG_ADD_SUB_OP(add, _relaxed)
-
 
71
ATOMIC_LONG_ADD_SUB_OP(add, _acquire)
-
 
72
ATOMIC_LONG_ADD_SUB_OP(add, _release)
-
 
73
ATOMIC_LONG_ADD_SUB_OP(sub,)
-
 
74
ATOMIC_LONG_ADD_SUB_OP(sub, _relaxed)
-
 
75
ATOMIC_LONG_ADD_SUB_OP(sub, _acquire)
-
 
76
ATOMIC_LONG_ADD_SUB_OP(sub, _release)
-
 
77
 
-
 
78
#undef ATOMIC_LONG_ADD_SUB_OP
-
 
79
 
-
 
80
#define atomic_long_cmpxchg_relaxed(l, old, new) \
-
 
81
	(ATOMIC_LONG_PFX(_cmpxchg_relaxed)((ATOMIC_LONG_PFX(_t) *)(l), \
-
 
82
					   (old), (new)))
-
 
83
#define atomic_long_cmpxchg_acquire(l, old, new) \
Line -... Line 84...
-
 
84
	(ATOMIC_LONG_PFX(_cmpxchg_acquire)((ATOMIC_LONG_PFX(_t) *)(l), \
-
 
85
					   (old), (new)))
-
 
86
#define atomic_long_cmpxchg_release(l, old, new) \
-
 
87
	(ATOMIC_LONG_PFX(_cmpxchg_release)((ATOMIC_LONG_PFX(_t) *)(l), \
-
 
88
					   (old), (new)))
-
 
89
#define atomic_long_cmpxchg(l, old, new) \
147
 
90
	(ATOMIC_LONG_PFX(_cmpxchg)((ATOMIC_LONG_PFX(_t) *)(l), (old), (new)))
148
	return (long)atomic_read(v);
-
 
-
 
91
 
Line 149... Line 92...
149
}
92
#define atomic_long_xchg_relaxed(v, new) \
150
 
93
	(ATOMIC_LONG_PFX(_xchg_relaxed)((ATOMIC_LONG_PFX(_t) *)(v), (new)))
151
static inline void atomic_long_set(atomic_long_t *l, long i)
94
#define atomic_long_xchg_acquire(v, new) \
Line 152... Line 95...
152
{
95
	(ATOMIC_LONG_PFX(_xchg_acquire)((ATOMIC_LONG_PFX(_t) *)(v), (new)))
153
	atomic_t *v = (atomic_t *)l;
96
#define atomic_long_xchg_release(v, new) \
Line 154... Line 97...
154
 
97
	(ATOMIC_LONG_PFX(_xchg_release)((ATOMIC_LONG_PFX(_t) *)(v), (new)))
155
	atomic_set(v, i);
98
#define atomic_long_xchg(v, new) \
156
}
99
	(ATOMIC_LONG_PFX(_xchg)((ATOMIC_LONG_PFX(_t) *)(v), (new)))
Line 157... Line 100...
157
 
100
 
158
static inline void atomic_long_inc(atomic_long_t *l)
101
static inline void atomic_long_inc(atomic_long_t *l)
Line -... Line 102...
-
 
102
{
-
 
103
	ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l;
159
{
104
 
160
	atomic_t *v = (atomic_t *)l;
105
	ATOMIC_LONG_PFX(_inc)(v);
161
 
106
}
162
	atomic_inc(v);
107
 
163
}
108
static inline void atomic_long_dec(atomic_long_t *l)
164
 
109
{
Line -... Line 110...
-
 
110
	ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l;
-
 
111
 
165
static inline void atomic_long_dec(atomic_long_t *l)
112
	ATOMIC_LONG_PFX(_dec)(v);
166
{
113
}
-
 
114
 
167
	atomic_t *v = (atomic_t *)l;
115
#define ATOMIC_LONG_OP(op)						\
Line 168... Line 116...
168
 
116
static inline void							\
169
	atomic_dec(v);
-
 
Line 170... Line 117...
170
}
117
atomic_long_##op(long i, atomic_long_t *l)				\
171
 
118
{									\
172
static inline void atomic_long_add(long i, atomic_long_t *l)
119
	ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l;		\
Line 173... Line 120...
173
{
120
									\
174
	atomic_t *v = (atomic_t *)l;
121
	ATOMIC_LONG_PFX(_##op)(i, v);					\
Line 175... Line 122...
175
 
122
}
176
	atomic_add(i, v);
123
 
177
}
124
ATOMIC_LONG_OP(add)
Line 178... Line 125...
178
 
125
ATOMIC_LONG_OP(sub)
179
static inline void atomic_long_sub(long i, atomic_long_t *l)
126
ATOMIC_LONG_OP(and)
Line 180... Line 127...
180
{
127
ATOMIC_LONG_OP(or)
181
	atomic_t *v = (atomic_t *)l;
128
ATOMIC_LONG_OP(xor)
182
 
129
ATOMIC_LONG_OP(andnot)
Line 183... Line 130...
183
	atomic_sub(i, v);
130
 
184
}
131
#undef ATOMIC_LONG_OP
Line 185... Line 132...
185
 
132
 
186
static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
133
static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
187
{
-
 
188
	atomic_t *v = (atomic_t *)l;
-
 
189
 
-
 
190
	return atomic_sub_and_test(i, v);
-
 
191
}
-
 
192
 
-
 
193
static inline int atomic_long_dec_and_test(atomic_long_t *l)
-
 
194
{
134
{
195
	atomic_t *v = (atomic_t *)l;
-
 
196
 
-
 
197
	return atomic_dec_and_test(v);
-
 
198
}
-
 
199
 
-
 
200
static inline int atomic_long_inc_and_test(atomic_long_t *l)
-
 
201
{
-
 
202
	atomic_t *v = (atomic_t *)l;
-
 
203
 
-
 
204
	return atomic_inc_and_test(v);
-
 
205
}
-
 
206
 
-
 
207
static inline int atomic_long_add_negative(long i, atomic_long_t *l)
-
 
208
{
-
 
Line 209... Line 135...
209
	atomic_t *v = (atomic_t *)l;
135
	ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l;
210
 
136
 
Line -... Line 137...
-
 
137
	return ATOMIC_LONG_PFX(_sub_and_test)(i, v);
-
 
138
}
211
	return atomic_add_negative(i, v);
139
 
-
 
140
static inline int atomic_long_dec_and_test(atomic_long_t *l)
-
 
141
{
-
 
142
	ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l;
-
 
143
 
212
}
144
	return ATOMIC_LONG_PFX(_dec_and_test)(v);
-
 
145
}
-
 
146
 
-
 
147
static inline int atomic_long_inc_and_test(atomic_long_t *l)
-
 
148
{
213
 
149
	ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l;
-
 
150
 
-
 
151
	return ATOMIC_LONG_PFX(_inc_and_test)(v);
-
 
152
}
Line 214... Line 153...
214
static inline long atomic_long_add_return(long i, atomic_long_t *l)
153
 
215
{
-
 
Line 216... Line 154...
216
	atomic_t *v = (atomic_t *)l;
154
static inline int atomic_long_add_negative(long i, atomic_long_t *l)
217
 
155
{
218
	return (long)atomic_add_return(i, v);
156
	ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l;
Line 219... Line 157...
219
}
157
 
220
 
158
	return ATOMIC_LONG_PFX(_add_negative)(i, v);
Line 221... Line -...
221
static inline long atomic_long_sub_return(long i, atomic_long_t *l)
-
 
222
{
-
 
223
	atomic_t *v = (atomic_t *)l;
-
 
224
 
-
 
225
	return (long)atomic_sub_return(i, v);
159
}
226
}
160
 
227
 
-
 
228
static inline long atomic_long_inc_return(atomic_long_t *l)
-
 
Line 229... Line 161...
229
{
161
#define ATOMIC_LONG_INC_DEC_OP(op, mo)					\