• brucedawson's avatar
    Fix runtime-atomics for Win 10 SDK and remove volatile · b2ed2530
    brucedawson authored
    For unclear and probably accidental reasons the Windows 10 SDK
    renamed some _Interlocked* functions to _InlineInterlocked. This
    leads to these errors:
    
    runtime-atomics.cc(159): error C3861: '_InterlockedExchange64': identifier not found
    runtime-atomics.cc(159): error C3861: '_InterlockedExchangeAdd64': identifier not found
    runtime-atomics.cc(159): error C3861: '_InterlockedAnd64': identifier not found
    runtime-atomics.cc(159): error C3861: '_InterlockedOr64': identifier not found
    runtime-atomics.cc(159): error C3861: '_InterlockedXor64': identifier not found
    
    Fixing this requires either adding defines to map these five _Interlocked*
    functions to _InlineInterlocked*, or else changing to using the
    non-underscore versions. It appears that using the non-underscore versions
    is preferable so I went that way. This also requires adding three  new
    defines because there is a huge lack of consistency, probably due to these
    macros being defined sometimes in <intrin.h> and sometimes in <winnt.h>
    
    All five of the renamed 64-bit functions were manually checked to ensure
    that the change to the non-underscore versions would make no differences -
    the inline functions that they map to were identical. Other functions were
    spot-checked.
    
    Also, the 'volatile' qualifiers were removed. Volatile has no no useful
    meaning for multi-threaded programming. It only exists in the Interlocked*
    prototypes to *allow* volatile variables to be passed. Since this is a bad
    habit to encourage there is no reason for us to permit it, and we can
    still call the Microsoft functions (T* converts to volatile T*, just not
    vice-versa).
    
    The updated code builds with the Windows 8.1 SDK and with the Windows 10 SDK.
    
    R=jarin@chromium.org
    LOG=Y
    BUG=440500,491424
    
    Review URL: https://codereview.chromium.org/1228063005
    
    Cr-Commit-Position: refs/heads/master@{#29687}
    b2ed2530
runtime-atomics.cc 26 KB