summaryrefslogtreecommitdiff
path: root/src/include/c.h
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2025-11-24 07:36:49 +0100
committerPeter Eisentraut <peter@eisentraut.org>2025-11-24 07:39:37 +0100
commitd4c0f91f7d57066b9d62c0eccb2a913d40c14066 (patch)
treec2be6f35339f3925f6d01a1f710b4e986f599c23 /src/include/c.h
parent4b203d499c610160e9867e6add2366780429344c (diff)
C11 alignas instead of unions -- extended alignments
This replaces some uses of pg_attribute_aligned() with the standard alignas() for cases where extended alignment (larger than max_align_t) is required. This patch stipulates that all supported compilers must support alignments up to PG_IO_ALIGN_SIZE, but that seems pretty likely. We can then also desupport the case where direct I/O is disabled because pg_attribute_aligned is not supported. Reviewed-by: Chao Li <li.evan.chao@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/46f05236-d4d4-4b4e-84d4-faa500f14691%40eisentraut.org
Diffstat (limited to 'src/include/c.h')
-rw-r--r--src/include/c.h18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/include/c.h b/src/include/c.h
index 729eb8a27de..a40f0cf4642 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -1132,25 +1132,15 @@ typedef struct PGAlignedBlock
* for I/O in general, but may be strictly required on some platforms when
* using direct I/O.
*/
-typedef union PGIOAlignedBlock
+typedef struct PGIOAlignedBlock
{
-#ifdef pg_attribute_aligned
- pg_attribute_aligned(PG_IO_ALIGN_SIZE)
-#endif
- char data[BLCKSZ];
- double force_align_d;
- int64 force_align_i64;
+ alignas(PG_IO_ALIGN_SIZE) char data[BLCKSZ];
} PGIOAlignedBlock;
/* Same, but for an XLOG_BLCKSZ-sized buffer */
-typedef union PGAlignedXLogBlock
+typedef struct PGAlignedXLogBlock
{
-#ifdef pg_attribute_aligned
- pg_attribute_aligned(PG_IO_ALIGN_SIZE)
-#endif
- char data[XLOG_BLCKSZ];
- double force_align_d;
- int64 force_align_i64;
+ alignas(PG_IO_ALIGN_SIZE) char data[XLOG_BLCKSZ];
} PGAlignedXLogBlock;
/* msb for char */