Closed zhuoyikang closed 9 years ago
bool sync_bool_compare_and_swap (type *ptr, type oldval type newval, ...) type sync_val_compare_and_swap (type ptr, type oldval type newval, ...) These builtins perform an atomic compare and swap. That is, if the current value of ptr is oldval, then write newval into *ptr.
The “bool” version returns true if the comparison is successful and newval was written. The “val” version returns the contents of *ptr before the operation.
只用bool的话,使用太受限制了
宏写出来和bool效果是一样的,对swap的返回值进行比较返回1或0,看起来是和bool的行为一样。 你是还要进行什么扩展吗》
不,是一直以来我看了函数名一直以为参数需要是bool类型的
define COMPARE_AND_SWAP(PTR,OLD,NEW) \
可以直接修改为
define COMPARE_AND_SWAP(PTR,OLD,NEW) \