Debian Codegraph @

gcc/testsuite/gcc.dg/crc-from-fedora-packages-28.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-fdump-tree-crc-details -O2" } */
3 /* { dg-require-effective-target int32plus } */
4
5 // File - crc32-2.i
6
7 #include <stdint.h>
8 #include <stddef.h>
9 void *xmalloc(size_t size) __attribute__ ((malloc));
10 uint32_t* crc32_filltable(uint32_t *crc_table, int endian)
11 {
12 uint32_t polynomial = endian ? 0x04c11db7 : 0xedb88320;
13 uint32_t c;
14 unsigned i, j;
15
16 if (!crc_table)
17 crc_table = xmalloc(256 * sizeof(uint32_t));
18
19 for (i = 0; i < 256; i++) {
20 c = endian ? (i << 24) : i;
21 for (j = 8; j; j--) {
22 if (endian)
23 c = (c&0x80000000) ? ((c << 1) ^ polynomial) : (c << 1);
24 else
25 c = (c&1) ? ((c >> 1) ^ polynomial) : (c >> 1);
26 }
27 *crc_table++ = c;
28 }
29
30 return crc_table - 256;
31 }