Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Sept/Oct 2019 Issue of The NT Insider available

Download PDF here:

It’s a particularly BIG issue, too: 40 pages of technical goodness, ranging from WDF to Minifilters. Check it out.
Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

ARM64 InterlockedExchangeXXX

Pavel_SPavel_S Member Posts: 74

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.


  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,411

    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).


    Peter Viscarola

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,066

    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.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,411
    edited September 3

    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.


    Peter Viscarola

  • Pavel_SPavel_S Member Posts: 74
    edited September 4


    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


  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,411

    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).


    Peter Viscarola

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Writing WDF Drivers 21 Oct 2019 OSR Seminar Space & ONLINE
Internals & Software Drivers 18 Nov 2019 Dulles, VA
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Developing Minifilters 27 Apr 2020 OSR Seminar Space & ONLINE