aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/check/crc32_tablegen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/liblzma/check/crc32_tablegen.c')
-rw-r--r--src/liblzma/check/crc32_tablegen.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/liblzma/check/crc32_tablegen.c b/src/liblzma/check/crc32_tablegen.c
index 0cbfecd8..56bc5c7f 100644
--- a/src/liblzma/check/crc32_tablegen.c
+++ b/src/liblzma/check/crc32_tablegen.c
@@ -5,6 +5,7 @@
///
/// Compiling: gcc -std=c99 -o crc32_tablegen crc32_tablegen.c
/// Add -DWORDS_BIGENDIAN to generate big endian table.
+/// Add -DLZ_HASH_TABLE to generate lz_encoder_hash_table.h (little endian).
//
// Author: Lasse Collin
//
@@ -82,10 +83,39 @@ print_crc32_table(void)
}
+static void
+print_lz_table(void)
+{
+ printf("/* This file has been automatically generated by "
+ "crc32_tablegen.c. */\n\n"
+ "const uint32_t lzma_lz_hash_table[256] = {");
+
+ for (size_t b = 0; b < 256; ++b) {
+ if ((b % 4) == 0)
+ printf("\n\t");
+
+ printf("0x%08" PRIX32, crc32_table[0][b]);
+
+ if (b != 255)
+ printf(",%s", (b+1) % 4 == 0 ? "" : " ");
+ }
+
+ printf("\n};\n");
+
+ return;
+}
+
+
int
main(void)
{
init_crc32_table();
+
+#ifdef LZ_HASH_TABLE
+ print_lz_table();
+#else
print_crc32_table();
+#endif
+
return 0;
}