So I found the following code in a program:
static void* InterlockedExchangePtr(void** x, void* switchval)
{
return _InterlockedExchange((long*)(x), (long)(switchval));
}
(I know about atomics, only thing I don't quite get is what is this typecast (long*)(x))
This casts
x, which is a pointer to void pointer, to a pointer tolong.That cast is necessary because
_InterlockedExchangeexpects along*as its first argument andvoid**can't be implicitly converted to that.https://learn.microsoft.com/en-us/cpp/intrinsics/interlockedexchange-intrinsic-functions