This doesn\'t exactly seem to be right although I am unsure why. Advice would be great as the documentation for CMPXCHG16B is pretty minimal (I don\'t own any intel manuals...)<
It's good to note that if you're using GCC, you don't need to use inline asm to get at this instruction. You can use one of the __sync functions, like:
template<>
inline bool cas(volatile types::uint128_t *src,
types::uint128_t cmp,
types::uint128_t with)
{
return __sync_bool_compare_and_swap(src, cmp, with);
}
Microsoft has a similar function for VC++:
__int64 exchhi = __int64(with >> 64);
__int64 exchlo = (__int64)(with);
return _InterlockedCompareExchange128(a, exchhi, exchlo, &cmp) != 0;