Improve unconstify() documentation
Refer to expression instead of variable when appropriate. Discussion: https://www.postgresql.org/message-id/08adbe4e-38f8-2c73-55f0-591392371687%402ndquadrant.com
This commit is contained in:
parent
4beea5508e
commit
f2898de98a
@ -1122,14 +1122,14 @@ typedef union PGAlignedXLogBlock
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Macro that allows to cast constness away from a variable, but doesn't
|
* Macro that allows to cast constness away from an expression, but doesn't
|
||||||
* allow changing the underlying type. Enforcement of the latter
|
* allow changing the underlying type. Enforcement of the latter
|
||||||
* currently only works for gcc like compilers.
|
* currently only works for gcc like compilers.
|
||||||
*
|
*
|
||||||
* Please note IT IS NOT SAFE to cast constness away if the variable will ever
|
* Please note IT IS NOT SAFE to cast constness away if the result will ever
|
||||||
* be modified (it would be undefined behaviour). Doing so anyway can cause
|
* be modified (it would be undefined behaviour). Doing so anyway can cause
|
||||||
* compiler misoptimizations or runtime crashes (modifying readonly memory).
|
* compiler misoptimizations or runtime crashes (modifying readonly memory).
|
||||||
* It is only safe to use when the the variable will not be modified, but API
|
* It is only safe to use when the the result will not be modified, but API
|
||||||
* design or language restrictions prevent you from declaring that
|
* design or language restrictions prevent you from declaring that
|
||||||
* (e.g. because a function returns both const and non-const variables).
|
* (e.g. because a function returns both const and non-const variables).
|
||||||
*
|
*
|
||||||
@ -1137,13 +1137,13 @@ typedef union PGAlignedXLogBlock
|
|||||||
* be nice, but not trivial, to improve that).
|
* be nice, but not trivial, to improve that).
|
||||||
*/
|
*/
|
||||||
#if defined(HAVE__BUILTIN_TYPES_COMPATIBLE_P)
|
#if defined(HAVE__BUILTIN_TYPES_COMPATIBLE_P)
|
||||||
#define unconstify(underlying_type, var) \
|
#define unconstify(underlying_type, expr) \
|
||||||
(StaticAssertExpr(__builtin_types_compatible_p(__typeof(var), const underlying_type), \
|
(StaticAssertExpr(__builtin_types_compatible_p(__typeof(expr), const underlying_type), \
|
||||||
"wrong cast"), \
|
"wrong cast"), \
|
||||||
(underlying_type) (var))
|
(underlying_type) (expr))
|
||||||
#else
|
#else
|
||||||
#define unconstify(underlying_type, var) \
|
#define unconstify(underlying_type, expr) \
|
||||||
((underlying_type) (var))
|
((underlying_type) (expr))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ----------------------------------------------------------------
|
/* ----------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user