func checkSum(data []byte) uint32 {
table := crc32.MakeTable(crc32.Castagnoli)
return crc32.Update(0xffffffff, table, data)
}
u32 calc_checksum(void *rambuffer, u8 length)
{
unsigned int len = (4096 - 512) + 4096 * length;
return crc32c(WB_CKSUM_SEED, rambuffer + 512, len);
}
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Joe,So the tables are the same but the output values are different?Go version emits 279b567f but the C version emits 0x8d4ae087 right?
Hi Joe,
Sorry I don't get it.I am using Intel CPU that's LE.So the endian isn't relevant to this problem.In the first place, how do you create 0xeac7d932 from c1a76c6f by byte swap?- Akira
func update(crc uint32, tab *Table, p []byte) uint32 { crc = ^crc for _, v := range p { crc = tab[byte(crc)^v] ^ (crc >> 8) } return ^crc }
* Same crc32 function was used in 5 other places in the kernel.
* I made one version, and deleted the others.
* There are various incantations of crc32(). Some use a seed of 0 or ~0.
* Some xor at the end with ~0. The generic crc32() function takes
* seed as an argument, and doesn't xor at the end. Then individual
* users can do whatever they need.
* drivers/net/smc9194.c uses seed ~0, doesn't xor with ~0.
* fs/jffs2 uses seed 0, doesn't xor with ~0.
* fs/partitions/efi.c uses seed ~0, xor's with ~0.
Thanks for your help.describes as follows. Linux kernel's crc32 design appears to allow users to choosewhether to complement or not. Very confusing but I finally understand. Thanks again.* Same crc32 function was used in 5 other places in the kernel.
* I made one version, and deleted the others.
* There are various incantations of crc32(). Some use a seed of 0 or ~0.
* Some xor at the end with ~0. The generic crc32() function takes
* seed as an argument, and doesn't xor at the end. Then individual
* users can do whatever they need.
* drivers/net/smc9194.c uses seed ~0, doesn't xor with ~0.
* fs/jffs2 uses seed 0, doesn't xor with ~0.
* fs/partitions/efi.c uses seed ~0, xor's with ~0.