643
643
struct CheckSum : ULONG
645
static uint32_t CalcTableChecksum (ULONG *Table, uint32_t Length)
645
/* This is reference implementation from the spec. */
646
static inline uint32_t CalcTableChecksum (const ULONG *Table, uint32_t Length)
647
648
uint32_t Sum = 0L;
648
ULONG *EndPtr = Table+((Length+3) & ~3) / ULONG::static_size;
649
const ULONG *EndPtr = Table+((Length+3) & ~3) / ULONG::static_size;
650
651
while (Table < EndPtr)
656
/* Note: data should be 4byte aligned and have 4byte padding at the end. */
657
inline void set_for_data (const void *data, unsigned int length)
658
{ set (CalcTableChecksum ((const ULONG *) data, length)); }
655
661
DEFINE_SIZE_STATIC (4);