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

Commitdb4ec2f

Browse files
committed
Fix alignment of pg_atomic_uint64 variables on some 32bit platforms.
I failed to recognize that pg_atomic_uint64 wasn't guaranteed to be 8byte aligned on some 32bit platforms - which it has to be on someplatforms to guarantee the desired atomicity and which we assert.As this is all compiler specific code anyway we can just rely oncompiler specific tricks to enforce alignment.I've been unable to find concrete documentation about the version thatintroduce the sunpro alignment support, so that might need additionalguards.I've verified that this works with gcc x86 32bit, but I don't haveaccess to any other 32bit environment.Discussion: op.xpsjdkil0sbe7t@vld-kuciPer report from Vladimir Koković.
1 parent62f5e44 commitdb4ec2f

File tree

6 files changed

+17
-4
lines changed

6 files changed

+17
-4
lines changed

‎src/include/port/atomics/arch-x86.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ typedef struct pg_atomic_uint32
7373
#definePG_HAVE_ATOMIC_U64_SUPPORT
7474
typedefstructpg_atomic_uint64
7575
{
76+
/* alignment guaranteed due to being on a 64bit platform */
7677
volatileuint64value;
7778
}pg_atomic_uint64;
7879
#endif

‎src/include/port/atomics/generic-acc.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ typedef struct pg_atomic_uint32
4040
#definePG_HAVE_ATOMIC_U64_SUPPORT
4141
typedefstructpg_atomic_uint64
4242
{
43+
/*
44+
* Alignment is guaranteed to be 64bit. Search for "Well-behaved
45+
* application restrictions" => "Data alignment and data sharing" on HP's
46+
* website. Unfortunately the URL doesn't seem to stable enough to
47+
* include.
48+
*/
4349
volatileuint64value;
4450
}pg_atomic_uint64;
4551

‎src/include/port/atomics/generic-gcc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ typedef struct pg_atomic_uint32
9898

9999
typedefstructpg_atomic_uint64
100100
{
101-
volatileuint64value;
101+
volatileuint64value __attribute__((aligned(8)));
102102
}pg_atomic_uint64;
103103

104104
#endif/* defined(HAVE_GCC__ATOMIC_INT64_CAS) || defined(HAVE_GCC__SYNC_INT64_CAS) */

‎src/include/port/atomics/generic-msvc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ typedef struct pg_atomic_uint32
4141
}pg_atomic_uint32;
4242

4343
#definePG_HAVE_ATOMIC_U64_SUPPORT
44-
typedefstructpg_atomic_uint64
44+
typedefstruct__declspec(align(8))pg_atomic_uint64
4545
{
4646
volatileuint64value;
4747
}pg_atomic_uint64;

‎src/include/port/atomics/generic-sunpro.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ typedef struct pg_atomic_uint32
5555
#definePG_HAVE_ATOMIC_U64_SUPPORT
5656
typedefstructpg_atomic_uint64
5757
{
58-
volatileuint64value;
58+
/*
59+
* Syntax to enforce variable alignment should be supported by versions
60+
* supporting atomic.h, but it's hard to find accurate documentation. If
61+
* it proves to be a problem, we'll have to add more version checks for 64
62+
* bit support.
63+
*/
64+
volatileuint64value __attribute__((__aligned__(8)));
5965
}pg_atomic_uint64;
6066

6167
#endif/* HAVE_ATOMIC_H */

‎src/include/port/atomics/generic-xlc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ typedef struct pg_atomic_uint32
3232
#definePG_HAVE_ATOMIC_U64_SUPPORT
3333
typedefstructpg_atomic_uint64
3434
{
35-
volatileuint64value;
35+
volatileuint64value __attribute__((__aligned__(8)));
3636
}pg_atomic_uint64;
3737

3838
#endif/* __64BIT__ */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp