Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: xz/src/liblzma/check/crc64_tablegen.c

Issue 2869016: Add an unpatched version of xz, XZ Utils, to /trunk/deps/third_party (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « xz/src/liblzma/check/crc64_table_le.h ('k') | xz/src/liblzma/check/crc64_x86.S » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file crc64_tablegen.c
4 /// \brief Generate crc64_table_le.h and crc64_table_be.h
5 ///
6 /// Compiling: gcc -std=c99 -o crc64_tablegen crc64_tablegen.c
7 /// Add -DWORDS_BIGENDIAN to generate big endian table.
8 //
9 // Author: Lasse Collin
10 //
11 // This file has been put into the public domain.
12 // You can do whatever you want with this file.
13 //
14 ///////////////////////////////////////////////////////////////////////////////
15
16 #include <stdio.h>
17 #include "../../common/tuklib_integer.h"
18
19
20 static uint64_t crc64_table[4][256];
21
22
23 extern void
24 init_crc64_table(void)
25 {
26 static const uint64_t poly64 = UINT64_C(0xC96C5795D7870F42);
27
28 for (size_t s = 0; s < 4; ++s) {
29 for (size_t b = 0; b < 256; ++b) {
30 uint64_t r = s == 0 ? b : crc64_table[s - 1][b];
31
32 for (size_t i = 0; i < 8; ++i) {
33 if (r & 1)
34 r = (r >> 1) ^ poly64;
35 else
36 r >>= 1;
37 }
38
39 crc64_table[s][b] = r;
40 }
41 }
42
43 #ifdef WORDS_BIGENDIAN
44 for (size_t s = 0; s < 4; ++s)
45 for (size_t b = 0; b < 256; ++b)
46 crc64_table[s][b] = bswap64(crc64_table[s][b]);
47 #endif
48
49 return;
50 }
51
52
53 static void
54 print_crc64_table(void)
55 {
56 printf("/* This file has been automatically generated by "
57 "crc64_tablegen.c. */\n\n"
58 "const uint64_t lzma_crc64_table[4][256] = {\n\t{");
59
60 for (size_t s = 0; s < 4; ++s) {
61 for (size_t b = 0; b < 256; ++b) {
62 if ((b % 2) == 0)
63 printf("\n\t\t");
64
65 printf("UINT64_C(0x%016" PRIX64 ")",
66 crc64_table[s][b]);
67
68 if (b != 255)
69 printf(",%s", (b+1) % 2 == 0 ? "" : " ");
70 }
71
72 if (s == 3)
73 printf("\n\t}\n};\n");
74 else
75 printf("\n\t}, {");
76 }
77
78 return;
79 }
80
81
82 int
83 main(void)
84 {
85 init_crc64_table();
86 print_crc64_table();
87 return 0;
88 }
OLDNEW
« no previous file with comments | « xz/src/liblzma/check/crc64_table_le.h ('k') | xz/src/liblzma/check/crc64_x86.S » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698