在platform21之前都能够好好的使用一下这两个函数,用于原子操作的加减。但是当使用platform21时这里发生了一点变化,头文件sys/atomics.h也去掉了,改为stdatomic.h。
__atomic_dec(void *)
__atomic_inc(void *)
常用的这两个接口也改为更加灵活的方式:
__sync_fetch_and_add(void *, int)
__sync_fetch_and_sub(void *, int)
// test
int mRefCount = 2;
__sync_fetch_and_add(&mRefCount, 1);