Is there an 8-bit atomic CAS (cmpxchg) intrinsic for X64 in Visual C++?

别说谁变了你拦得住时间么 提交于 2019-12-03 16:07:38

No, that doesn't exist. You can implement it out-of-line though, if needed.

atomic_msvc_x64.asm

_text   SEGMENT

; char _InterlockedCompareExchange8(volatile char*, char NewValue, char Expected) 
;      - RCX, RDX, R8

_InterlockedCompareExchange8  PROC

    mov    eax,r8d
    lock cmpxchg [rcx],dl
    ret

_InterlockedCompareExchange8  ENDP

_text  ENDS

       END

Verified for Visual Studio 2012 that this intrinsic does exist :

char _InterlockedCompareExchange8(volatile char*, char NewValue, char Expected)

However, it appears nowhere in the documentation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!