aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-09-16 12:01:20 +0000
committerJason A. Donenfeld <Jason@zx2c4.com>2021-09-16 12:02:29 +0000
commit07009b0ae686d2e34182873e359a91647f438a64 (patch)
tree6588d71a22cabdbc5d13eb23b079d96c6c6970c7
parentversion: bump (diff)
downloadwireguard-nt-07009b0ae686d2e34182873e359a91647f438a64.tar.xz
wireguard-nt-07009b0ae686d2e34182873e359a91647f438a64.zip
api: support MinGW in distributed header
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--TODO.md4
-rw-r--r--api/wireguard.h21
2 files changed, 22 insertions, 3 deletions
diff --git a/TODO.md b/TODO.md
index 7c2ed44..33d6323 100644
--- a/TODO.md
+++ b/TODO.md
@@ -39,3 +39,7 @@ check for the workaround thread polling.
### Remove `IP_OPTIONS`/`IPV6_RTHDR` hack
Currently we tag on an empty options cmsg to work around a bug in recent
Windows builds, where `IP_PKTINFO` gets stripped if it's passed alone.
+
+## Project
+
+### Enable `/std:c17` once NDIS headers can handle it, and switch to using `alignas` from stdalign.h.
diff --git a/api/wireguard.h b/api/wireguard.h
index 371c4a0..f820711 100644
--- a/api/wireguard.h
+++ b/api/wireguard.h
@@ -15,6 +15,21 @@
extern "C" {
#endif
+#ifndef ALIGNED
+# if defined(_MSC_VER)
+# define ALIGNED(n) __declspec(align(n))
+# elif defined(__GNUC__)
+# define ALIGNED(n) __attribute__((aligned(n)))
+# else
+# error "Unable to define ALIGNED"
+# endif
+#endif
+
+/* MinGW is missing this one, unfortunately. */
+#ifndef _Post_maybenull_
+# define _Post_maybenull_
+#endif
+
#pragma warning(push)
#pragma warning(disable : 4324) /* structure was padded due to alignment specifier */
@@ -278,7 +293,7 @@ BOOL(WINAPI WIREGUARD_GET_ADAPTER_STATE_FUNC)
#define WIREGUARD_KEY_LENGTH 32
typedef struct _WIREGUARD_ALLOWED_IP WIREGUARD_ALLOWED_IP;
-__declspec(align(8)) struct _WIREGUARD_ALLOWED_IP
+struct ALIGNED(8) _WIREGUARD_ALLOWED_IP
{
union
{
@@ -301,7 +316,7 @@ typedef enum
} WIREGUARD_PEER_FLAG;
typedef struct _WIREGUARD_PEER WIREGUARD_PEER;
-__declspec(align(8)) struct _WIREGUARD_PEER
+struct ALIGNED(8) _WIREGUARD_PEER
{
WIREGUARD_PEER_FLAG Flags; /**< Bitwise combination of flags */
DWORD Reserved; /**< Reserved; must be zero */
@@ -324,7 +339,7 @@ typedef enum
} WIREGUARD_INTERFACE_FLAG;
typedef struct _WIREGUARD_INTERFACE WIREGUARD_INTERFACE;
-__declspec(align(8)) struct _WIREGUARD_INTERFACE
+struct ALIGNED(8) _WIREGUARD_INTERFACE
{
WIREGUARD_INTERFACE_FLAG Flags; /**< Bitwise combination of flags */
WORD ListenPort; /**< Port for UDP listen socket, or 0 to choose randomly */