summaryrefslogtreecommitdiffstats
path: root/lib/gen_crc32table.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gen_crc32table.c')
-rw-r--r--lib/gen_crc32table.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/gen_crc32table.c b/lib/gen_crc32table.c
index eced7696eb7c..99ac744848fb 100644
--- a/lib/gen_crc32table.c
+++ b/lib/gen_crc32table.c
@@ -4,8 +4,17 @@
#define ENTRIES_PER_LINE 4
+#if CRC_LE_BITS <= 8
#define LE_TABLE_SIZE (1 << CRC_LE_BITS)
+#else
+#define LE_TABLE_SIZE 256
+#endif
+
+#if CRC_BE_BITS <= 8
#define BE_TABLE_SIZE (1 << CRC_BE_BITS)
+#else
+#define BE_TABLE_SIZE 256
+#endif
static uint32_t crc32table_le[4][256];
static uint32_t crc32table_be[4][256];
@@ -24,7 +33,7 @@ static void crc32init_le(void)
crc32table_le[0][0] = 0;
- for (i = 1 << (CRC_LE_BITS - 1); i; i >>= 1) {
+ for (i = LE_TABLE_SIZE >> 1; i; i >>= 1) {
crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
for (j = 0; j < LE_TABLE_SIZE; j += 2 * i)
crc32table_le[0][i + j] = crc ^ crc32table_le[0][j];
OpenPOWER on IntegriCloud