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

Side by Side Diff: xz/src/liblzma/check/crc32_small.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/crc32_fast.c ('k') | xz/src/liblzma/check/crc32_table.c » ('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 crc32_small.c
4 /// \brief CRC32 calculation (size-optimized)
5 //
6 // Author: Lasse Collin
7 //
8 // This file has been put into the public domain.
9 // You can do whatever you want with this file.
10 //
11 ///////////////////////////////////////////////////////////////////////////////
12
13 #include "check.h"
14
15
16 uint32_t lzma_crc32_table[1][256];
17
18
19 static void
20 crc32_init(void)
21 {
22 static const uint32_t poly32 = UINT32_C(0xEDB88320);
23
24 for (size_t b = 0; b < 256; ++b) {
25 uint32_t r = b;
26 for (size_t i = 0; i < 8; ++i) {
27 if (r & 1)
28 r = (r >> 1) ^ poly32;
29 else
30 r >>= 1;
31 }
32
33 lzma_crc32_table[0][b] = r;
34 }
35
36 return;
37 }
38
39
40 extern void
41 lzma_crc32_init(void)
42 {
43 mythread_once(crc32_init);
44 return;
45 }
46
47
48 extern LZMA_API(uint32_t)
49 lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
50 {
51 lzma_crc32_init();
52
53 crc = ~crc;
54
55 while (size != 0) {
56 crc = lzma_crc32_table[0][*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
57 --size;
58 }
59
60 return ~crc;
61 }
OLDNEW
« no previous file with comments | « xz/src/liblzma/check/crc32_fast.c ('k') | xz/src/liblzma/check/crc32_table.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698