#include "postgres.h"
#include "storage/checksum.h"
Go to the source code of this file.
Defines | |
#define | N_SUMS 32 |
#define | FNV_PRIME 16777619 |
#define | CHECKSUM_COMP(checksum, value) |
Functions | |
uint32 | checksum_block (char *data, uint32 size) |
Variables | |
static const uint32 | checksumBaseOffsets [N_SUMS] |
#define CHECKSUM_COMP | ( | checksum, | ||
value | ||||
) |
do {\ uint32 __tmp = (checksum) ^ (value);\ (checksum) = __tmp * FNV_PRIME ^ (__tmp >> 17);\ } while (0)
Definition at line 126 of file checksum.c.
Referenced by checksum_block().
#define FNV_PRIME 16777619 |
Definition at line 106 of file checksum.c.
#define N_SUMS 32 |
Definition at line 104 of file checksum.c.
Referenced by checksum_block().
Definition at line 132 of file checksum.c.
References Assert, CHECKSUM_COMP, checksumBaseOffsets, i, and N_SUMS.
Referenced by PageCalcChecksum16().
{ uint32 sums[N_SUMS]; uint32 (*dataArr)[N_SUMS] = (uint32 (*)[N_SUMS]) data; uint32 result = 0; int i, j; /* ensure that the size is compatible with the algorithm */ Assert((size % (sizeof(uint32)*N_SUMS)) == 0); /* initialize partial checksums to their corresponding offsets */ memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets)); /* main checksum calculation */ for (i = 0; i < size/sizeof(uint32)/N_SUMS; i++) for (j = 0; j < N_SUMS; j++) CHECKSUM_COMP(sums[j], dataArr[i][j]); /* finally add in two rounds of zeroes for additional mixing */ for (i = 0; i < 2; i++) for (j = 0; j < N_SUMS; j++) CHECKSUM_COMP(sums[j], 0); /* xor fold partial checksums together */ for (i = 0; i < N_SUMS; i++) result ^= sums[i]; return result; }
const uint32 checksumBaseOffsets[N_SUMS] [static] |
{ 0x5B1F36E9, 0xB8525960, 0x02AB50AA, 0x1DE66D2A, 0x79FF467A, 0x9BB9F8A3, 0x217E7CD2, 0x83E13D2C, 0xF8D4474F, 0xE39EB970, 0x42C6AE16, 0x993216FA, 0x7B093B5D, 0x98DAFF3C, 0xF718902A, 0x0B1C9CDB, 0xE58F764B, 0x187636BC, 0x5D7B3BB1, 0xE73DE7DE, 0x92BEC979, 0xCCA6C0B2, 0x304A0979, 0x85AA43D4, 0x783125BB, 0x6CA8EAA2, 0xE407EAC6, 0x4B5CFC3E, 0x9FBF8C76, 0x15CA20BE, 0xF2CA9FD3, 0x959BD756 }
Definition at line 112 of file checksum.c.
Referenced by checksum_block().