161
162 inline void Atomic::store(jint store_value, volatile jint* dest) {
163 *dest = store_value;
164 }
165
166 inline void Atomic::store_ptr(intptr_t store_value, intptr_t* dest) {
167 *dest = store_value;
168 }
169
170 template<size_t byte_size>
171 struct Atomic::PlatformAdd
172 : Atomic::AddAndFetch<Atomic::PlatformAdd<byte_size> >
173 {
174 template<typename I, typename D>
175 D add_and_fetch(I add_value, D volatile* dest) const;
176 };
177
178 template<>
179 template<typename I, typename D>
180 inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) const {
181 STATIC_CAST(4 == sizeof(I));
182 STATIC_CAST(4 == sizeof(D));
183
184 #ifdef ARM
185 return add_using_helper<int>(arm_add_and_fetch, add_value, dest);
186 #else
187 #ifdef M68K
188 return add_using_helper<int>(m68k_add_and_fetch, add_value, dest);
189 #else
190 return __sync_add_and_fetch(dest, add_value);
191 #endif // M68K
192 #endif // ARM
193 }
194
195 template<>
196 template<typename I, typename D>
197 inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest) const {
198 STATIC_CAST(8 == sizeof(I));
199 STATIC_CAST(8 == sizeof(D));
200
201 return __sync_add_and_fetch(dest, add_value);
202 }
203
204 inline void Atomic::inc(volatile jint* dest) {
205 add(1, dest);
206 }
207
208 inline void Atomic::inc_ptr(volatile intptr_t* dest) {
209 add_ptr(1, dest);
210 }
211
212 inline void Atomic::inc_ptr(volatile void* dest) {
213 add_ptr(1, dest);
214 }
215
216 inline void Atomic::dec(volatile jint* dest) {
217 add(-1, dest);
218 }
219
|
161
162 inline void Atomic::store(jint store_value, volatile jint* dest) {
163 *dest = store_value;
164 }
165
166 inline void Atomic::store_ptr(intptr_t store_value, intptr_t* dest) {
167 *dest = store_value;
168 }
169
170 template<size_t byte_size>
171 struct Atomic::PlatformAdd
172 : Atomic::AddAndFetch<Atomic::PlatformAdd<byte_size> >
173 {
174 template<typename I, typename D>
175 D add_and_fetch(I add_value, D volatile* dest) const;
176 };
177
178 template<>
179 template<typename I, typename D>
180 inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) const {
181 STATIC_ASSERT(4 == sizeof(I));
182 STATIC_ASSERT(4 == sizeof(D));
183
184 #ifdef ARM
185 return add_using_helper<int>(arm_add_and_fetch, add_value, dest);
186 #else
187 #ifdef M68K
188 return add_using_helper<int>(m68k_add_and_fetch, add_value, dest);
189 #else
190 return __sync_add_and_fetch(dest, add_value);
191 #endif // M68K
192 #endif // ARM
193 }
194
195 template<>
196 template<typename I, typename D>
197 inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest) const {
198 STATIC_ASSERT(8 == sizeof(I));
199 STATIC_ASSERT(8 == sizeof(D));
200
201 return __sync_add_and_fetch(dest, add_value);
202 }
203
204 inline void Atomic::inc(volatile jint* dest) {
205 add(1, dest);
206 }
207
208 inline void Atomic::inc_ptr(volatile intptr_t* dest) {
209 add_ptr(1, dest);
210 }
211
212 inline void Atomic::inc_ptr(volatile void* dest) {
213 add_ptr(1, dest);
214 }
215
216 inline void Atomic::dec(volatile jint* dest) {
217 add(-1, dest);
218 }
219
|