aboutsummaryrefslogtreecommitdiffstats
path: root/api/atomic.h
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2020-10-24 08:28:17 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2020-10-30 16:51:01 +0100
commit4b8f879fd6e41b06da2b580b0444e9ad31063f1e (patch)
tree81903eda7fee0f7fcf0a05bdad5f159df43d2c7b /api/atomic.h
parentapi: allow Debug build packaging (diff)
downloadwintun-4b8f879fd6e41b06da2b580b0444e9ad31063f1e.tar.xz
wintun-4b8f879fd6e41b06da2b580b0444e9ad31063f1e.zip
api: add ring management
Rather than every client reinvent the art of using the Wintun and its ring buffers, we offer helper structs and functions to unify and simplify Wintun usage. Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'api/atomic.h')
-rw-r--r--api/atomic.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/api/atomic.h b/api/atomic.h
new file mode 100644
index 0000000..011e53b
--- /dev/null
+++ b/api/atomic.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2018-2020 WireGuard LLC. All Rights Reserved.
+ */
+
+#pragma once
+
+#include <Windows.h>
+
+static __forceinline VOID
+InterlockedSetU(_Inout_ _Interlocked_operand_ ULONG volatile *Target, _In_ ULONG Value)
+{
+ *Target = Value;
+}
+
+static __forceinline LONG
+InterlockedGet(_In_ _Interlocked_operand_ LONG volatile *Value)
+{
+ return *Value;
+}
+
+static __forceinline ULONG
+InterlockedGetU(_In_ _Interlocked_operand_ ULONG volatile *Value)
+{
+ return *Value;
+}