Re: alignas (C11)

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: alignas (C11)
Date: 2025-11-12 15:33:08
Message-ID: eb9a1132-0144-4b04-848b-6f919fd0b189@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12.11.25 15:17, Thomas Munro wrote:
> In a very quick hack (so probably missing things) I also seemed to be
> able to get rid of all our ALIGNOF_ configure probes and just write
> alignof(int) when I want the alignment of int,

According to my research, using alignof could be quite dangerous for our
use, because it does not necessarily match what the ALIGNOF_ probes
return. The latter just answer the question, what is the offset if I
stick this in a struct as the second field, but that could be larger
than the smallest valid alignment for a type. And there are
platforms/ABIs where they are actually different.

If we didn't have to worry about on-disk compatibility, then using
alignof would in theory be better, because if the minimal alignment is
actually smaller than the current configure probes compute, then we
could save storage. But for the system catalog structs we actually do
want the offset-in-struct interpretation, so we're tied to that anyway.

(Also, something about AIX here ... :-/)

So, I don't know, better be careful with this ...

> move the MAXALIGN
> derivation into about two lines of c.h,

Yes, I had also arrived at that. Just to unify some configure and meson
code.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2025-11-12 15:39:50 Re: should we have a fast-path planning for OLTP starjoins?
Previous Message Manni Wood 2025-11-12 15:26:20 Re: [PATCH] Add pg_get_tablespace_ddl() function to reconstruct CREATE TABLESPACE statement