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

Commitec3c9cc

Browse files
committed
Add definition pg_attribute_aligned() for MSVC
Visual Studio 2015+ has support for a macro to control the alignement ofstructures as of __declspec(align(#)), and this commit adds a definitionof pg_attribute_aligned() based on that. It happens that this wasalready used in the implementation of atomics for MSVC. Note that thereis still no definition fo pg_attribute_packed(), so this does not impactitemptr.h.Author: James ColemanDiscussion:https://postgr.es/m/CAAaqYe-HbtZvR3msoMtk+hYW2S0e0OapzMW8icSMYTMA+mN8Aw@mail.gmail.com
1 parent1c27d16 commitec3c9cc

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

‎config/c-compiler.m4‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ if test x"$pgac_cv__128bit_int" = xyes ; then
139139
/* This must match the corresponding code in c.h: */
140140
#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
141141
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
142+
#elif defined(_MSC_VER)
143+
#define pg_attribute_aligned(a) __declspec(align(a))
142144
#endif
143145
typedef __int128 int128a
144146
#if defined(pg_attribute_aligned)

‎configure‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17462,6 +17462,8 @@ else
1746217462
/* This must match the corresponding code in c.h: */
1746317463
#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
1746417464
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
17465+
#elif defined(_MSC_VER)
17466+
#define pg_attribute_aligned(a) __declspec(align(a))
1746517467
#endif
1746617468
typedef __int128 int128a
1746717469
#if defined(pg_attribute_aligned)

‎src/include/c.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,17 @@
181181
#definepg_attribute_noreturn() __attribute__((noreturn))
182182
#definepg_attribute_packed() __attribute__((packed))
183183
#defineHAVE_PG_ATTRIBUTE_NORETURN 1
184+
#elif defined(_MSC_VER)
185+
/*
186+
* MSVC supports aligned. noreturn is also possible but in MSVC it is
187+
* declared before the definition while pg_attribute_noreturn() macro
188+
* is currently used after the definition.
189+
*
190+
* Packing is also possible but only by wrapping the entire struct definition
191+
* which doesn't fit into our current macro declarations.
192+
*/
193+
#definepg_attribute_aligned(a) __declspec(align(a))
194+
#definepg_attribute_noreturn()
184195
#else
185196
/*
186197
* NB: aligned and packed are not given default definitions because they

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ typedef struct pg_atomic_uint32
3939
}pg_atomic_uint32;
4040

4141
#definePG_HAVE_ATOMIC_U64_SUPPORT
42-
typedefstruct__declspec(align(8))pg_atomic_uint64
42+
typedefstructpg_attribute_aligned(8)pg_atomic_uint64
4343
{
4444
volatileuint64value;
4545
}pg_atomic_uint64;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp