What (if any) is the C# equivalent of the x86 asm xchg instruction?
With that command, which imo is a genuine exchange (unlike Interlocked.Exchange), I
Outside of Interlocked.Exchange, I'm assuming the XCHG command is probably an implementation of the XOR Swap, so you could write your own.
C syntax: (from wikipedia link)
void xorSwap (int *x, int *y) {
if (x != y) {
*x ^= *y;
*y ^= *x;
*x ^= *y;
}
}
Edit this is not atomic, you would have to synchronize it yourself