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

Commit481018f

Browse files
committed
Add macro to cast away volatile without allowing changes to underlying type
This adds unvolatize(), which works just like unconstify() but for volatile.Discussion:https://www.postgresql.org/message-id/flat/7a5cbea7-b8df-e910-0f10-04014bcad701%402ndquadrant.com
1 parent572e3e6 commit481018f

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

‎src/backend/postmaster/pgstat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3311,7 +3311,7 @@ pgstat_read_current_status(void)
33113311
localentry->backendStatus.st_procpid=beentry->st_procpid;
33123312
if (localentry->backendStatus.st_procpid>0)
33133313
{
3314-
memcpy(&localentry->backendStatus,(char*)beentry,sizeof(PgBackendStatus));
3314+
memcpy(&localentry->backendStatus,unvolatize(PgBackendStatus*,beentry),sizeof(PgBackendStatus));
33153315

33163316
/*
33173317
* strcpy is safe even if the string is modified concurrently,

‎src/backend/storage/ipc/pmsignal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ PMSignalShmemInit(void)
134134

135135
if (!found)
136136
{
137-
MemSet(PMSignalState,0,PMSignalShmemSize());
137+
MemSet(unvolatize(PMSignalData*,PMSignalState),0,PMSignalShmemSize());
138138
PMSignalState->num_child_flags=MaxLivePostmasterChildren();
139139
}
140140
}

‎src/include/c.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ typedef union PGAlignedXLogBlock
11221122
#endif
11231123

11241124
/*
1125-
* Macro that allows to cast constness away from an expression, but doesn't
1125+
* Macro that allows to cast constnessand volatileaway from an expression, but doesn't
11261126
* allow changing the underlying type. Enforcement of the latter
11271127
* currently only works for gcc like compilers.
11281128
*
@@ -1141,9 +1141,15 @@ typedef union PGAlignedXLogBlock
11411141
(StaticAssertExpr(__builtin_types_compatible_p(__typeof(expr), const underlying_type), \
11421142
"wrong cast"), \
11431143
(underlying_type) (expr))
1144+
#defineunvolatize(underlying_type,expr) \
1145+
(StaticAssertExpr(__builtin_types_compatible_p(__typeof(expr), volatile underlying_type), \
1146+
"wrong cast"), \
1147+
(underlying_type) (expr))
11441148
#else
11451149
#defineunconstify(underlying_type,expr) \
11461150
((underlying_type) (expr))
1151+
#defineunvolatize(underlying_type,expr) \
1152+
((underlying_type) (expr))
11471153
#endif
11481154

11491155
/* ----------------------------------------------------------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp