aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/check/crc64_tablegen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/liblzma/check/crc64_tablegen.c')
-rw-r--r--src/liblzma/check/crc64_tablegen.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/liblzma/check/crc64_tablegen.c b/src/liblzma/check/crc64_tablegen.c
new file mode 100644
index 00000000..0f1005f4
--- /dev/null
+++ b/src/liblzma/check/crc64_tablegen.c
@@ -0,0 +1,56 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+/// \file crc64_tablegen.c
+/// \brief Generates CRC64 crc64_table.c
+///
+/// Compiling: gcc -std=c99 -o crc64_tablegen crc64_tablegen.c crc64_init.c
+/// Add -DWORDS_BIGENDIAN to generate big endian table.
+//
+// This code has been put into the public domain.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#include <sys/types.h>
+#include <inttypes.h>
+#include <stdio.h>
+
+
+extern void lzma_crc64_init(void);
+
+extern uint64_t lzma_crc64_table[4][256];
+
+
+int
+main()
+{
+ lzma_crc64_init();
+
+ printf("/* This file has been automatically generated by "
+ "crc64_tablegen.c. */\n\n"
+ "#include <inttypes.h>\n\n"
+ "const uint64_t lzma_crc64_table[4][256] = {\n\t{");
+
+ for (size_t s = 0; s < 4; ++s) {
+ for (size_t b = 0; b < 256; ++b) {
+ if ((b % 2) == 0)
+ printf("\n\t\t");
+
+ printf("UINT64_C(0x%016" PRIX64 ")",
+ lzma_crc64_table[s][b]);
+
+ if (b != 255)
+ printf(", ");
+ }
+
+ if (s == 3)
+ printf("\n\t}\n};\n");
+ else
+ printf("\n\t}, {");
+ }
+
+ return 0;
+}