aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/check/crc32_tablegen.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2009-10-02 11:03:26 +0300
committerLasse Collin <lasse.collin@tukaani.org>2009-10-02 11:03:26 +0300
commitc5f68b5cc79085a87f950fea53843e27f328068e (patch)
tree3de2840a1ac485bdb6b440a4f6236659f7962d8b /src/liblzma/check/crc32_tablegen.c
parentadd lzmainfo to gitignore (diff)
downloadxz-c5f68b5cc79085a87f950fea53843e27f328068e.tar.xz
Make liblzma produce the same output on both endiannesses.
Seems that it is a problem in some cases if the same version of XZ Utils produces different output on different endiannesses, so this commit fixes that problem. The output will still vary between different XZ Utils versions, but I cannot avoid that for now. This commit bloatens the code on big endian systems by 1 KiB, which should be OK since liblzma is bloated already. ;-)
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;
}