2 * Copied from Linux kernel crypto/crc32c.c
3 * Copyright (c) 2004 Cisco Systems, Inc.
4 * Copyright (c) 2008 Herbert Xu <herbert@gondor.apana.org.au>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
14 * This is the CRC-32C table
18 * reflect input bytes = true
19 * reflect output bytes = true
22 static u32 crc32c_table
[256];
25 * Steps through buffer one byte at at time, calculates reflected
29 static inline u32
crc32c_le(u32 crc
, const char *data
, size_t length
)
32 crc
= crc32c_table
[(u8
)(crc
^ *data
++)] ^ (crc
>> 8);
37 static inline void btrfs_init_crc32c(void)
41 const u32 poly
= 0x82F63B78; /* Bit-reflected CRC32C polynomial */
43 for (i
= 0; i
< 256; i
++) {
45 for (j
= 0; j
< 8; j
++) {
46 v
= (v
>> 1) ^ ((v
& 1) ? poly
: 0);