From 97e04c74bedb902327b89eb8a9e6aea01aabdad2 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 21 Nov 2025 09:57:06 +0100 Subject: C11 alignas instead of unions This changes a few union members that only existed to ensure alignments and replaces them with the C11 alignas specifier. This change only uses fundamental alignments (meaning approximately alignments of basic types), which all C11 compilers must support. There are opportunities for similar changes using extended alignments, for example in PGIOAlignedBlock, but these are not necessarily supported by all compilers, so they are kept as a separate change. Reviewed-by: Chao Li Discussion: https://www.postgresql.org/message-id/flat/46f05236-d4d4-4b4e-84d4-faa500f14691%40eisentraut.org --- src/backend/access/common/toast_internals.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/backend/access/common/toast_internals.c') diff --git a/src/backend/access/common/toast_internals.c b/src/backend/access/common/toast_internals.c index 81dbd67c725..63b848473f8 100644 --- a/src/backend/access/common/toast_internals.c +++ b/src/backend/access/common/toast_internals.c @@ -287,11 +287,9 @@ toast_save_datum(Relation rel, Datum value, bool t_isnull[3] = {0}; union { - struct varlena hdr; + alignas(int32) struct varlena hdr; /* this is to make the union big enough for a chunk: */ char data[TOAST_MAX_CHUNK_SIZE + VARHDRSZ]; - /* ensure union is aligned well enough: */ - int32 align_it; } chunk_data; int32 chunk_size; -- cgit v1.2.3