Releasing debian version 4.04+dfsg-9.
[syslinux-debian/hramrach.git] / core / fs / btrfs / crc32c.h
blob2c317384fa63663bd51d4654b3b6a65bc1f62bae
1 /*
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)
9 * any later version.
14 * This is the CRC-32C table
15 * Generated with:
16 * width = 32 bits
17 * poly = 0x1EDC6F41
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
26 * crc using table.
29 static inline u32 crc32c_le(u32 crc, const char *data, size_t length)
31 while (length--)
32 crc = crc32c_table[(u8)(crc ^ *data++)] ^ (crc >> 8);
34 return crc;
37 static inline void btrfs_init_crc32c(void)
39 int i, j;
40 u32 v;
41 const u32 poly = 0x82F63B78; /* Bit-reflected CRC32C polynomial */
43 for (i = 0; i < 256; i++) {
44 v = i;
45 for (j = 0; j < 8; j++) {
46 v = (v >> 1) ^ ((v & 1) ? poly : 0);
48 crc32c_table[i] = v;