时OSCompareAndSwap(Mac OS X的),相当于CMPXCHG8B?

有帮助吗?

解决方案

可以找到的在XNU源的OSAtomic.s文件的原子的功能的定义。例如,下面的 OSAtomicCompareAndSwapPtr为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

其他提示

锁 CMPXCHG8B

更精确地

它是英特尔处理器,但考虑到,即OSX不仅针对英特尔架构存在,所以ASM将是不同的

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top