开发者

Is OSCompareAndSwap (Mac OS X) equivalent to CMPXCHG8B?

开发者 https://www.devze.com 2022-12-24 00:31 出处:网络
Is OSCompareAndSwa开发者_如何学Gop (Mac OS X) equivalent to CMPXCHG8B?You can find the definition of the atomic functions in the OSAtomic.s file in the XNU source.For example, here\'s OSAtomicCompareA

Is OSCompareAndSwa开发者_如何学Gop (Mac OS X) equivalent to CMPXCHG8B?


You can find the definition of the atomic functions in the OSAtomic.s file in the XNU source. For example, here's OSAtomicCompareAndSwapPtr for x86_64 in version 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


lock cmpxchg8b

more exactly

It's for intel processors, but take into account, that osx exists not only for intel architecture, so asm will be different

0

精彩评论

暂无评论...
验证码 换一张
取 消