Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要一些函数来原子地获取 int 值。称为 OSAtomicGet() 的东西。g_atomic_int_get() 的模拟。
在运行 Mac/iStuffs 的架构上,从已知指针中取消引用int始终是原子操作。如果需要内存屏障,请使用OSMemoryBarrier() 。
int
int OSAtomicGet(volatile int* value) { OSMemoryBarrier(); return *value; }