Changeset f1c7755 in mainline for kernel/arch/amd64/include/atomic.h
- Timestamp:
- 2012-08-05T00:12:33Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b17518e
- Parents:
- 6eaed07
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/include/atomic.h
r6eaed07 rf1c7755 178 178 } 179 179 180 /** Atomicaly sets *ptr to new_val and returns the previous value. */ 181 NO_TRACE static inline void * atomic_swap_ptr(void **pptr, void *new_val) 182 { 183 void *new_in_old_out = new_val; 184 185 asm volatile ( 186 "xchgq %[val], %[pptr]\n" 187 : [val] "+r" (new_in_old_out), 188 [pptr] "+m" (*pptr) 189 ); 190 191 return new_in_old_out; 192 } 193 194 /** Sets *ptr to new_val and returns the previous value. NOT smp safe. 195 * 196 * This function is only atomic wrt to local interrupts and it is 197 * NOT atomic wrt to other cpus. 198 */ 199 NO_TRACE static inline void * atomic_swap_ptr_local(void **pptr, void *new_val) 200 { 201 /* 202 * Issuing a xchg instruction always implies lock prefix semantics. 203 * Therefore, it is cheaper to use a cmpxchg without a lock prefix 204 * in a loop. 205 */ 206 void *exp_val; 207 void *old_val; 208 209 do { 210 exp_val = *pptr; 211 old_val = atomic_cas_ptr_local(pptr, exp_val, new_val); 212 } while (old_val != exp_val); 213 214 return old_val; 215 } 216 217 180 218 #undef _atomic_cas_ptr_impl 181 219
Note:
See TracChangeset
for help on using the changeset viewer.