Blame src/crc/mdso_crc64.c

c19325
/****************************************************************/
c19325
/*  mdso: midipix dso scavenger                                 */
3e816c
/*  Copyright (C) 2015--2016  Z. Gilboa                         */
c19325
/*  Released under GPLv2 and GPLv3; see COPYING.MDSO.           */
c19325
/****************************************************************/
c19325
c19325
#include <stdint.h>
c19325
#include <unistd.h>
c19325
c19325
#include <mdso/mdso.h>
c19325
#include <mdso/mdso_crc64.h>
c19325
c19325
static const uint64_t crc64_table[256] = MDSO_CRC64_TABLE;
c19325
c19325
uint64_t mdso_crc64_mbstr(const unsigned char * str, size_t * symlen)
c19325
{
c19325
	const unsigned char *	ch;
c19325
	uint64_t		crc64;
c19325
c19325
	crc64	= 0 ^ 0xFFFFFFFFFFFFFFFF;
c19325
	ch	= str;
c19325
c19325
	while (*ch) {
c19325
		crc64 = (crc64 >> 8) ^ crc64_table[(crc64 ^ *ch) & 0xFF];
c19325
		ch++;
c19325
	}
c19325
c19325
	if (symlen)
c19325
		*symlen = ch - str;
c19325
c19325
	return (crc64 ^ 0xFFFFFFFFFFFFFFFF);
c19325
}