On Mon, Sep 19, 2022 at 8:21 PM Michael Paquier <mich...@paquier.xyz> wrote:
>
> 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.

I was following the style of the comment outside the "if", but I'm not
attached to that style, so changed in this version.

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

Added.

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

Yes, fixed.

James Coleman

Attachment: v2-0001-Support-pg_attribute_aligned-and-noreturn-in-MSVC.patch
Description: Binary data

Reply via email to