/*====================================================================*
*
* uint32_t checksum32 (const int32_t memory [], size_t extent, uint32_t checksum);
*
* memory.h
*
* compute the 32 bit checksum of a memory segment; the checksum
* is the one's complement of the XOR of all 32 bit words;
*
* this checksum is returned in host byte order on the assumption
* that the memory segment is stored little endian;
*
*. Motley Tools by Charles Maier <cmaier@cmassoc.net>;
*: Published 2001-2006 by Charles Maier Associates Limited;
*; Released under the GNU General Public Licence v2 and later;
*
* Contributor(s):
* Charles Maier <charles.maier@atheros.com>
* Alex Vasquez <alex.vasquez@atheros.com>
*
*--------------------------------------------------------------------*/
#ifndef CHECKSUM32_SOURCE
#define CHECKSUM32_SOURCE
#include <stdint.h>
#include "../tools/memory.h"
uint32_t checksum32 (register const uint32_t memory [], register size_t extent, uint32_t checksum)
{
while (extent-- > 0)
{
checksum ^= LE32TOH (*memory);
memory++;
}
return (~checksum);
}
#endif