diff options
author | Kevin Grittner <kgrittn@postgresql.org> | 2016-04-09 08:17:22 -0500 |
---|---|---|
committer | Kevin Grittner <kgrittn@postgresql.org> | 2016-04-09 08:17:22 -0500 |
commit | 56dffb5a73ab157fc8d35a76c1170d656a051f14 (patch) | |
tree | 45796c96e43b51bebd97544b6162408fd2650c7e /src | |
parent | 1ff3f420d470fae46759e948a20e9550af012816 (diff) | |
download | postgresql-56dffb5a73ab157fc8d35a76c1170d656a051f14.tar.gz postgresql-56dffb5a73ab157fc8d35a76c1170d656a051f14.zip |
Turn special page pointer validation to static inline function
Inclusion of multiple macros inside another macro was pushing MSVC
past its size liimit. Reported by buildfarm.
Diffstat (limited to 'src')
-rw-r--r-- | src/include/storage/bufpage.h | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/include/storage/bufpage.h b/src/include/storage/bufpage.h index 2ce3be765c0..bdf7b0d3c58 100644 --- a/src/include/storage/bufpage.h +++ b/src/include/storage/bufpage.h @@ -298,14 +298,31 @@ typedef PageHeaderData *PageHeader; ((uint16) (PageGetPageSize(page) - ((PageHeader)(page))->pd_special)) /* + * Using assertions, validate that the page special pointer is OK. + * + * This is intended to catch use of the pointer before page initialization. + * It is implemented as a function do to the limitations of the MSVC compiler, + * which choked on doing all these tests within another macro. We return true + * so that MacroAssert() can be used while still getting the specifics from + * the macro failure within this function. + */ +static inline bool +PageValidateSpecialPointer(Page page) +{ + Assert(PageIsValid(page)); + Assert(((PageHeader) (page))->pd_special <= BLCKSZ); + Assert(((PageHeader) (page))->pd_special >= SizeOfPageHeaderData); + + return true; +} + +/* * PageGetSpecialPointer * Returns pointer to special space on a page. */ #define PageGetSpecialPointer(page) \ ( \ - AssertMacro(PageIsValid(page)), \ - AssertMacro(((PageHeader) (page))->pd_special <= BLCKSZ), \ - AssertMacro(((PageHeader) (page))->pd_special >= SizeOfPageHeaderData), \ + AssertMacro(PageValidateSpecialPointer(page)), \ (char *) ((char *) (page) + ((PageHeader) (page))->pd_special) \ ) |