summaryrefslogtreecommitdiff
path: root/src/include/c.h
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2022-09-21 10:11:23 +0900
committerMichael Paquier <michael@paquier.xyz>2022-09-21 10:11:23 +0900
commitec3c9cc202fb2749fce82483e6dc247cfe286cab (patch)
tree3de8933a2bdeb4af9950c26844efde71b0588949 /src/include/c.h
parent1c27d16e6e5c1f463bbe1e9ece88dda811235165 (diff)
downloadpostgresql-ec3c9cc202fb2749fce82483e6dc247cfe286cab.tar.gz
Add definition pg_attribute_aligned() for MSVC
Visual Studio 2015+ has support for a macro to control the alignement of structures as of __declspec(align(#)), and this commit adds a definition of pg_attribute_aligned() based on that. It happens that this was already used in the implementation of atomics for MSVC. Note that there is still no definition fo pg_attribute_packed(), so this does not impact itemptr.h. Author: James Coleman Discussion: https://postgr.es/m/CAAaqYe-HbtZvR3msoMtk+hYW2S0e0OapzMW8icSMYTMA+mN8Aw@mail.gmail.com
Diffstat (limited to 'src/include/c.h')
-rw-r--r--src/include/c.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/include/c.h b/src/include/c.h
index 101ba41331..c8f72e44d8 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -181,6 +181,17 @@
#define pg_attribute_noreturn() __attribute__((noreturn))
#define pg_attribute_packed() __attribute__((packed))
#define HAVE_PG_ATTRIBUTE_NORETURN 1
+#elif defined(_MSC_VER)
+/*
+ * MSVC supports aligned. noreturn is also possible but in MSVC it is
+ * declared before the definition while pg_attribute_noreturn() macro
+ * is currently used after the definition.
+ *
+ * Packing is also possible but only by wrapping the entire struct definition
+ * which doesn't fit into our current macro declarations.
+ */
+#define pg_attribute_aligned(a) __declspec(align(a))
+#define pg_attribute_noreturn()
#else
/*
* NB: aligned and packed are not given default definitions because they