Function 在Mac OS上以原子方式获取价值
我需要一些函数来自动获取int值。一种叫做OSAtomicGet的东西。模拟g_-atomic_-int_-get。在运行Mac/iStuffs的体系结构上,从已知指针取消对int的引用始终是原子的。如果需要内存屏障,请使用Function 在Mac OS上以原子方式获取价值,function,macos,get,atomic,darwin,Function,Macos,Get,Atomic,Darwin,我需要一些函数来自动获取int值。一种叫做OSAtomicGet的东西。模拟g_-atomic_-int_-get。在运行Mac/iStuffs的体系结构上,从已知指针取消对int的引用始终是原子的。如果需要内存屏障,请使用 int OSAtomicGet(volatile int* value) { OSMemoryBarrier(); return *value; } Сcounterquestion:所有int值都存储在哪里,以便您可以使用OSAtomic*API访问它们?
int OSAtomicGet(volatile int* value) {
OSMemoryBarrier();
return *value;
}
Сcounterquestion:所有int值都存储在哪里,以便您可以使用OSAtomic*API访问它们?