Changeset View
Changeset View
Standalone View
Standalone View
sys/mips/include/atomic.h
Show First 20 Lines • Show All 749 Lines • ▼ Show 20 Lines | |||||
#define atomic_cmpset_rel_ptr atomic_cmpset_rel_long | #define atomic_cmpset_rel_ptr atomic_cmpset_rel_long | ||||
#define atomic_fcmpset_ptr atomic_fcmpset_long | #define atomic_fcmpset_ptr atomic_fcmpset_long | ||||
#define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_long | #define atomic_fcmpset_acq_ptr atomic_fcmpset_acq_long | ||||
#define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_long | #define atomic_fcmpset_rel_ptr atomic_fcmpset_rel_long | ||||
#define atomic_load_acq_ptr atomic_load_acq_long | #define atomic_load_acq_ptr atomic_load_acq_long | ||||
#define atomic_store_rel_ptr atomic_store_rel_long | #define atomic_store_rel_ptr atomic_store_rel_long | ||||
#define atomic_readandclear_ptr atomic_readandclear_long | #define atomic_readandclear_ptr atomic_readandclear_long | ||||
#define ATOMIC_SWAP(sem,suf,dtype,before,after) \ | |||||
static __inline dtype \ | |||||
atomic_swap##sem##suff(volatile dtype *ptr, const dtype value) \ | |||||
{ \ | |||||
kib: Style does not allow to initialize at declaration. | |||||
dtype retval; \ | |||||
\ | |||||
if (before) \ | |||||
atomic_thread_fence_rel(); \ | |||||
retval = *ptr; \ | |||||
while (!atomic_fcmpset_##suffix(ptr, &retval, value)) \ | |||||
; \ | |||||
if (after) \ | |||||
atomic_thread_fence_acq(); \ | |||||
return (retval); \ | |||||
} | |||||
ATOMIC_SWAP(,_int,u_int,0,0) | |||||
ATOMIC_SWAP(_rel,_int,u_int,1,0) | |||||
ATOMIC_SWAP(_ack,_int,u_int,0,1) | |||||
ATOMIC_SWAP(,_32,uint32_t,0,0) | |||||
ATOMIC_SWAP(_rel,_32,uint32_t,1,0) | |||||
ATOMIC_SWAP(_ack,_32,uint32_t,0,1) | |||||
#if defined(__mips_n64) || defined(__mips_n32) | |||||
ATOMIC_SWAP(,_64,uint64_t,0,0) | |||||
ATOMIC_SWAP(_rel,_64,uint64_t,1,0) | |||||
ATOMIC_SWAP(_ack,_64,uint64_t,0,1) | |||||
#endif | |||||
ATOMIC_SWAP(,_long,u_long,0,0) | |||||
ATOMIC_SWAP(_rel,_long,u_long,1,0) | |||||
ATOMIC_SWAP(_ack,_long,u_long,0,1) | |||||
ATOMIC_SWAP(,_ptr,void *,0,0) | |||||
ATOMIC_SWAP(_rel,_ptr,void *,1,0) | |||||
ATOMIC_SWAP(_ack,_ptr,void *,0,1) | |||||
Not Done Inline ActionsDo we provide ack/rel variants of swap on any other arch ? kib: Do we provide ack/rel variants of swap on any other arch ?
Also, if you use fcmpset_acq/rel, I… | |||||
Done Inline ActionsNo, usually not. Do you want me to clear those variants? hselasky: No, usually not. Do you want me to clear those variants? | |||||
Not Done Inline ActionsYes, I think it is better not to do that, both due to the precedent and because the implementation is somewhat questionable. kib: Yes, I think it is better not to do that, both due to the precedent and because the… | |||||
#endif /* ! _MACHINE_ATOMIC_H_ */ | #endif /* ! _MACHINE_ATOMIC_H_ */ |
Style does not allow to initialize at declaration.