OSCompareAndSwap (Mac OS X) 是否等同于 CMPXCHG8B?
最佳答案
您可以在 XNU 源代码的 OSAtomic.s 文件中找到原子函数的定义。例如,这里是 OSAtomicCompareAndSwapPtr for x86_64在版本 1486.2.11 中:
_OSCompareAndSwap64:
_OSCompareAndSwapPtr: #;oldValue, newValue, ptr
movq %rdi, %rax
lock
cmpxchgq %rsi, 0(%rdx) #; CAS (eax is an implicit operand)
sete %al #; did CAS succeed? (TZ=1)
movzbq %al, %rax #; clear out the high bytes
ret
关于macos - OSCompareAndSwap (Mac OS X) 是否等同于 CMPXCHG8B?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2476654/