diff options
| author | Peter Eisentraut <peter@eisentraut.org> | 2025-11-21 09:57:06 +0100 |
|---|---|---|
| committer | Peter Eisentraut <peter@eisentraut.org> | 2025-11-21 10:08:24 +0100 |
| commit | 97e04c74bedb902327b89eb8a9e6aea01aabdad2 (patch) | |
| tree | 3b4af6c386011bdf378b5207bd36a135042bf202 /src/include/c.h | |
| parent | 266543a62055541ddefe4e66797e0e1e4aa8705a (diff) | |
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 <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.h | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/include/c.h b/src/include/c.h index 8e887bec0b2..729eb8a27de 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -1117,15 +1117,11 @@ pg_noreturn extern void ExceptionalCondition(const char *conditionName, * Use this, not "char buf[BLCKSZ]", to declare a field or local variable * holding a page buffer, if that page might be accessed as a page. Otherwise * the variable might be under-aligned, causing problems on alignment-picky - * hardware. We include both "double" and "int64" in the union to ensure that - * the compiler knows the value must be MAXALIGN'ed (cf. configure's - * computation of MAXIMUM_ALIGNOF). + * hardware. */ -typedef union PGAlignedBlock +typedef struct PGAlignedBlock { - char data[BLCKSZ]; - double force_align_d; - int64 force_align_i64; + alignas(MAXIMUM_ALIGNOF) char data[BLCKSZ]; } PGAlignedBlock; /* |
