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

Side by Side Diff: vboot_firmware/lib/cgptlib/crc32.c

Issue 2833012: Move all system includes in vboot_firmware to sysincludes.h (Closed) Base URL: ssh://gitrw.chromium.org/vboot_reference.git
Patch Set: Oops, forgot the new header 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
« no previous file with comments | « vboot_firmware/include/utility.h ('k') | vboot_firmware/lib/cgptlib/include/cgptlib.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* CRC32 implementation by Gary S. Brown. See license claim below. */ 1 /* CRC32 implementation by Gary S. Brown. See license claim below. */
2 2
3 /* ============================================================= */ 3 /* ============================================================= */
4 /* COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or */ 4 /* COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or */
5 /* code or tables extracted from it, as desired without restriction. */ 5 /* code or tables extracted from it, as desired without restriction. */
6 /* */ 6 /* */
7 /* First, the polynomial itself and its table of feedback terms. The */ 7 /* First, the polynomial itself and its table of feedback terms. The */
8 /* polynomial is */ 8 /* polynomial is */
9 /* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */ 9 /* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */
10 /* */ 10 /* */
(...skipping 22 matching lines...) Expand all
33 /* tions for all combinations of data and CRC register values. */ 33 /* tions for all combinations of data and CRC register values. */
34 /* */ 34 /* */
35 /* The values must be right-shifted by eight bits by the "updcrc" */ 35 /* The values must be right-shifted by eight bits by the "updcrc" */
36 /* logic; the shift must be unsigned (bring in zeroes). On some */ 36 /* logic; the shift must be unsigned (bring in zeroes). On some */
37 /* hardware you could probably optimize the shift in assembler by */ 37 /* hardware you could probably optimize the shift in assembler by */
38 /* using byte-swap instructions. */ 38 /* using byte-swap instructions. */
39 /* polynomial $edb88320 */ 39 /* polynomial $edb88320 */
40 /* */ 40 /* */
41 /* -------------------------------------------------------------------- */ 41 /* -------------------------------------------------------------------- */
42 #include "crc32.h" 42 #include "crc32.h"
43 #include <stdint.h>
44 43
45 static uint32_t crc32_tab[] = { 44 static uint32_t crc32_tab[] = {
46 0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U, 45 0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U,
47 0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U, 46 0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U,
48 0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U, 47 0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U,
49 0x90bf1d91U, 0x1db71064U, 0x6ab020f2U, 0xf3b97148U, 0x84be41deU, 48 0x90bf1d91U, 0x1db71064U, 0x6ab020f2U, 0xf3b97148U, 0x84be41deU,
50 0x1adad47dU, 0x6ddde4ebU, 0xf4d4b551U, 0x83d385c7U, 0x136c9856U, 49 0x1adad47dU, 0x6ddde4ebU, 0xf4d4b551U, 0x83d385c7U, 0x136c9856U,
51 0x646ba8c0U, 0xfd62f97aU, 0x8a65c9ecU, 0x14015c4fU, 0x63066cd9U, 50 0x646ba8c0U, 0xfd62f97aU, 0x8a65c9ecU, 0x14015c4fU, 0x63066cd9U,
52 0xfa0f3d63U, 0x8d080df5U, 0x3b6e20c8U, 0x4c69105eU, 0xd56041e4U, 51 0xfa0f3d63U, 0x8d080df5U, 0x3b6e20c8U, 0x4c69105eU, 0xd56041e4U,
53 0xa2677172U, 0x3c03e4d1U, 0x4b04d447U, 0xd20d85fdU, 0xa50ab56bU, 52 0xa2677172U, 0x3c03e4d1U, 0x4b04d447U, 0xd20d85fdU, 0xa50ab56bU,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 /* Returns a 32-bit CRC of the contents of the buffer. */ 99 /* Returns a 32-bit CRC of the contents of the buffer. */
101 uint32_t Crc32(const void *buffer, uint32_t len) { 100 uint32_t Crc32(const void *buffer, uint32_t len) {
102 uint8_t *byte = (uint8_t*)buffer; 101 uint8_t *byte = (uint8_t*)buffer;
103 uint32_t i; 102 uint32_t i;
104 uint32_t value = ~0U; 103 uint32_t value = ~0U;
105 104
106 for (i = 0; i < len; ++i) 105 for (i = 0; i < len; ++i)
107 value = crc32_tab[(value ^ byte[i]) & 0xff] ^ (value >> 8); 106 value = crc32_tab[(value ^ byte[i]) & 0xff] ^ (value >> 8);
108 return value ^ ~0U; 107 return value ^ ~0U;
109 } 108 }
OLDNEW
« no previous file with comments | « vboot_firmware/include/utility.h ('k') | vboot_firmware/lib/cgptlib/include/cgptlib.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698