_InterlockedCompareExchange64 compiler intrinsic on Windows XP?
Based on the Microsoft documentati开发者_Python百科on InterlockedCompareExchange64 is not available as a Windows API call until Windows Vista. See http://msdn.microsoft.com/en-us/library/windows/desktop/ms683562(v=vs.85).aspx.
However, it seems like the _InterlockedCompareExchange64 compiler intrinsic might be available on Windows XP as long as you are using a Pentium or above processor: http://msdn.microsoft.com/en-us/library/ttk2z1ws(VS.80).aspx .
Is this correct? Is there any gotcha there?
The documentation is quite consistent. API function is available since Vista or Server 2003, but if you prefer an intrinsic (that is no extrernal API required) MS compiler will implement the function through specific CPU instruction (see Remarks):
Because _InterlockedCompareExchange64 uses the cmpxchg8b instruction, it is not available on pre-Pentium processors, such as the 486.
It is noted that this instruction might be an issue with very old CPUs. This means that if you run your app on 486 processor, it will just crash as soon as it stumbles on this code.
精彩评论