1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-28 18:48:04 +03:00

Add declaration-level assertions for compile-time checks

Those new assertions can be used at file scope, outside of any function
for compilation checks.  This commit provides implementations for C and
C++, and fallback implementations.

Author: Peter Smith
Reviewed-by: Andres Freund, Kyotaro Horiguchi, Dagfinn Ilmari Mannsåker,
Michael Paquier
Discussion: https://postgr.es/m/201DD0641B056142AC8C6645EC1B5F62014B8E8030@SYD1217
This commit is contained in:
Michael Paquier
2020-02-03 14:48:42 +09:00
parent 6148e2b9a6
commit f1f10a1ba9
7 changed files with 76 additions and 12 deletions

View File

@@ -119,14 +119,7 @@ PageIsVerified(Page page, BlockNumber blkno)
return true;
}
/*
* Check all-zeroes case. Luckily BLCKSZ is guaranteed to always be a
* multiple of size_t - and it's much faster to compare memory using the
* native word size.
*/
StaticAssertStmt(BLCKSZ == (BLCKSZ / sizeof(size_t)) * sizeof(size_t),
"BLCKSZ has to be a multiple of sizeof(size_t)");
/* Check all-zeroes case */
all_zeroes = true;
pagebytes = (size_t *) page;
for (i = 0; i < (BLCKSZ / sizeof(size_t)); i++)