Re: Support pg_attribute_aligned and noreturn in MSVC

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: James Coleman <jtc331(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Support pg_attribute_aligned and noreturn in MSVC
Date: 2022-09-20 00:21:28
Message-ID: YykHiEBq3DmRajUt@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Sep 19, 2022 at 06:21:58PM -0400, James Coleman wrote:
> It turns out that MSVC supports both noreturn [2] [3] and alignment
> [4] [5] attributes, so this patch adds support for those. MSVC also
> supports a form of packing, but the implementation as I can tell
> requires wrapping the entire struct (with a push/pop declaration set)
> [6], which doesn't seem to match the style of macros we're using for
> packing in other compilers, so I opted not to implement that
> attribute.

Interesting. Thanks for the investigation.

+/*
+ * MSVC supports aligned and noreturn
+ * Packing is also possible but only by wrapping the entire struct definition
+ * which doesn't fit into our current macro declarations.
+ */
+#elif defined(_MSC_VER)
+#define pg_attribute_aligned(a) __declspec(align(a))
+#define pg_attribute_noreturn() __declspec(noreturn)
#else
Nit: I think that the comment should be in the elif block for Visual.

pg_attribute_aligned() could be used in generic-msvc.h's
pg_atomic_uint64 as it uses now align.

Shouldn't HAVE_PG_ATTRIBUTE_NORETURN be set for the MSVC case as well?
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message James Coleman 2022-09-20 00:51:37 Re: Support pg_attribute_aligned and noreturn in MSVC
Previous Message Michel Pelletier 2022-09-20 00:15:54 Proposal to use JSON for Postgres Parser format