use standard volatile semantics
PATCH 1/1 use standard volatile semantics
Make all archs are use the standardized concept of volatile. This patch will cause the most changes to arm64 codegen, and has yet to be tested on arm64 so is currently being submitted for comments. If someone would like to test on arm64 it would be appreciated. I do have an arm64 device, but it seems there's no existing arm64/windows wireguard binary package, so I can't just install such a thing and swap out the driver.
Signed-off-by Shawn Hoffman <[email protected]>
--- atomic.h | 54 ------------------------------ wintun.c | 76 +++++++++++++++++++++--------------------- wintun.vcxproj | 5 ++- wintun.vcxproj.filters | 3 -- 4 files changed, 40 insertions(+), 98 deletions(-) delete mode 100644 atomic.h
atomic.h deleted +0 -54
@@ -1,54 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 -* -* Copyright (C) 2018-2019 WireGuard LLC. All Rights Reserved. -*/ - -#pragma once - -#include <wdm.h> - -static __forceinlineVOID -InterlockedSet(_Inout_ _Interlocked_operand_ LONG volatile *Target, _In_ LONG Value) -{ - *Target = Value; -} - -static __forceinlineVOID -InterlockedSetU(_Inout_ _Interlocked_operand_ ULONG volatile *Target, _In_ ULONG Value) -{ - *Target = Value; -} - -static __forceinlineVOID -InterlockedSetPointer(_Inout_ _Interlocked_operand_ VOID *volatile *Target, _In_opt_ VOID *Value) -{ - *Target = Value; -} - -static __forceinlineLONG -InterlockedGet(_In_ _Interlocked_operand_ LONG volatile *Value) -{ -return *Value; -} - -static __forceinlineULONG -InterlockedGetU(_In_ _Interlocked_operand_ ULONG volatile *Value) -{ -return *Value; -} - -static __forceinlinePVOID -InterlockedGetPointer(_In_ _Interlocked_operand_ PVOID volatile *Value) -{ -return *Value; -} - -static __forceinlineLONG64 -InterlockedGet64(_In_ _Interlocked_operand_ LONG64 volatile *Value) -{ -#ifdef _WIN64 -return *Value; -#else -return InterlockedCompareExchange64 (Value,0 ,0 ); -#endif -}
wintun.c +38 -38
204 lines not on this page · raw message
wintun.vcxproj +2 -3
@@ -125,7 +125,7 @@ <ItemDefinitionGroup> <ClCompile> <PreprocessorDefinitions>NDIS_MINIPORT_DRIVER=1;NDIS620_MINIPORT=1;NDIS683_MINIPORT=1;NDIS_WDM=1;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <AdditionalOptions>/volatile:ms %(AdditionalOptions)</AdditionalOptions> + <AdditionalOptions>/volatile:iso %(AdditionalOptions)</AdditionalOptions> <EnablePREfast>true</EnablePREfast> </ClCompile> <ResourceCompile>
@@ -171,9 +171,8 @@ <FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" /> </ItemGroup> <ItemGroup> - <ClInclude Include="atomic.h" /> <ClInclude Include="undocumented.h" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets" /> -</Project> +</Project>
wintun.vcxproj.filters +0 -3
@@ -33,8 +33,5 @@ <ClInclude Include="undocumented.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="atomic.h"> - <Filter>Header Files</Filter> - </ClInclude> </ItemGroup> </Project>
Signature · 1 line
2.26.2.windows.1
Jason A. Donenfeld
AppliedApplied. Thanks a lot for this cleanup.
And sorry for the delay. We're getting rolling again now with Wintun improvements. Feel free to poke me on IRC (I'm zx2c4) if you're still interested in hacking on this.