I think I'm missing something obvious here. I have code like this:
int *a = <some_address>;int *b = <another_address>;// ...// desired atomic swap of addresses a and b hereint *tmp = a;a = b; b = tmp;
I want to do this atomically. I've been looking at __c11_atomic_exchange
and on OSX the OSAtomic methods, but nothing seems to perform a straight swap atomically. They can all write a value into 1 of the 2 variables atomically, but never both.
Any ideas?