ARM64 InterlockedExchangeXXX

I’m porting some drivers to arm64 and found out there is no all InterlockedExchangeXXX macros, like version for 8.
Why it is like that? I’m talking about why it is not introduced for compatibility reasons.

There HAVE to be. Seriously.

Now, granted… I went looking for the answer to this specific question, and all I could find was a lot of half-answers in the MSFT docs. References to ARM64 that we’re later labeled x64 and just “ARM” for example (as in here).

Are you seeing the functions aren in the WDK headers (apologies… not at the office currently).


If you look in winnt.h, you’ll see that ALL of the Interlocked intrinsics are available for ARM64. And, Or, Xor, Increment, Decrement, Exchange, ExchangeAdd, 8, 16, 32, 64. They’re all there.

OK, so I’m at work now. In addition to their being in winnt.h, the definition for (for example) InterlockedExchange64 is in wdm.h:

#define InterlockedExchange64 **_**InterlockedExchange64

And the definition for **_**InterlockedExchange64 is in intrin0.h:

__MACHINEARM_ARM64_X64(__int64 _InterlockedExchange64(__int64 volatile * _Target, __int64 _Value))

So… yeah… the Interlocked intrinsics are defined on AMD64.



Thank you for response.
Are you sure you see InterlockedExchange8 is in wdm.h?
I’m talking about wdm.h, I can see some intristics definitions in intrin9.h, but it looks not defined in wdm.h.
I see for instance InterlockedExchange16 thats fine, but I cannot see above?
Looking in 10.0.18362.0


Are you sure you see InterlockedExchange8 is in wdm.h?

Well… now you’re asking a different question from your original one, aren’t you. You asserted that “there is no all InterlockedExchangeXXX macros” – Which is clearly not the case.

The docs claim that InterlockedExchange8 is supported on ARM64. I think it’s one of the basic required functions. It’s in intrin.h as appearing on all platforms, and the _acq and _nf variants are available specifically for ARM64:

__MACHINE(char _InterlockedExchange8(_Interlocked_operand_ char volatile * _Target, char _Value))
__MACHINEARM_ARM64(char _InterlockedExchange8_acq(_Interlocked_operand_ char volatile * _Target, char _Value))
__MACHINEARM_ARM64(char _InterlockedExchange8_nf(_Interlocked_operand_ char volatile * _Target, char _Value))

So, no… for ARM64 I don’t see it in wdm.h specifically. Does it matter if it’s not there? The fact that it’s not present probably just means (a) that somebody missed it, and/or (b) that nobody needed it so it’s not in the kernel-mode include files (yet).