Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd4c0f91

Browse files
committed
C11 alignas instead of unions -- extended alignments
This replaces some uses of pg_attribute_aligned() with the standardalignas() for cases where extended alignment (larger than max_align_t)is required.This patch stipulates that all supported compilers must supportalignments up to PG_IO_ALIGN_SIZE, but that seems pretty likely.We can then also desupport the case where direct I/O is disabledbecause 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
1 parent4b203d4 commitd4c0f91

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

‎src/include/c.h‎

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,25 +1132,15 @@ typedef struct PGAlignedBlock
11321132
* for I/O in general, but may be strictly required on some platforms when
11331133
* using direct I/O.
11341134
*/
1135-
typedefunionPGIOAlignedBlock
1135+
typedefstructPGIOAlignedBlock
11361136
{
1137-
#ifdefpg_attribute_aligned
1138-
pg_attribute_aligned(PG_IO_ALIGN_SIZE)
1139-
#endif
1140-
chardata[BLCKSZ];
1141-
doubleforce_align_d;
1142-
int64force_align_i64;
1137+
alignas(PG_IO_ALIGN_SIZE)chardata[BLCKSZ];
11431138
}PGIOAlignedBlock;
11441139

11451140
/* Same, but for an XLOG_BLCKSZ-sized buffer */
1146-
typedefunionPGAlignedXLogBlock
1141+
typedefstructPGAlignedXLogBlock
11471142
{
1148-
#ifdefpg_attribute_aligned
1149-
pg_attribute_aligned(PG_IO_ALIGN_SIZE)
1150-
#endif
1151-
chardata[XLOG_BLCKSZ];
1152-
doubleforce_align_d;
1153-
int64force_align_i64;
1143+
alignas(PG_IO_ALIGN_SIZE)chardata[XLOG_BLCKSZ];
11541144
}PGAlignedXLogBlock;
11551145

11561146
/* msb for char */

‎src/include/storage/fd.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ extern PGDLLIMPORT int max_safe_fds;
8585
* to the appropriate Windows flag in src/port/open.c. We simulate it with
8686
* fcntl(F_NOCACHE) on macOS inside fd.c's open() wrapper. We use the name
8787
* PG_O_DIRECT rather than defining O_DIRECT in that case (probably not a good
88-
* idea on a Unix). We can only use it if the compiler will correctly align
89-
* PGIOAlignedBlock for us, though.
88+
* idea on a Unix).
9089
*/
91-
#if defined(O_DIRECT)&& defined(pg_attribute_aligned)
90+
#if defined(O_DIRECT)
9291
#definePG_O_DIRECT O_DIRECT
9392
#elif defined(F_NOCACHE)
9493
#definePG_O_DIRECT 0x80000000

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp