Debian Codegraph @

gcc/testsuite/gcc.dg/torture/crc-linux-1.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-fdump-tree-crc-details -w" } */
3 /* { dg-skip-if "" { *-*-* } { "-O0" "-O1" "-Os" "-O3" "-flto" } } */
4
5 #include <stdlib.h>
6 #define CRC32_POLY_BE 0x04c11db7
7 #define RETVAL_OUT_OF_MEMORY (-6)
8 #define RETVAL_NOT_BZIP_DATA (-2)
9 #define RETVAL_OK 0
10
11 struct bunzip_data {
12 unsigned int crc32Table[256];
13 };
14
15
16 int start_bunzip(struct bunzip_data **bdp, void *inbuf, long len,
17 long (*fill)(void*, unsigned long))
18 {
19 if (sizeof (unsigned int) <= 3)
20 exit (0);
21
22 struct bunzip_data *bd;
23 unsigned int i, j, c;
24
25 /* Figure out how much data to allocate */
26 i = sizeof(struct bunzip_data);
27
28 /* Allocate bunzip_data. Most fields initialize to zero. */
29 bd = *bdp = malloc(i);
30
31 /* ... */
32
33 /* Init the CRC32 table (big endian) */
34 for (i = 0; i < 256; i++) {
35 c = i << 24;
36 for (j = 8; j; j--)
37 c = c&0x80000000 ? (c << 1)^(CRC32_POLY_BE) : (c << 1);
38 bd->crc32Table[i] = c;
39 }
40
41 /* . . . */
42 return RETVAL_OK;
43 }
44
45 /* { dg-final { scan-tree-dump "calculates CRC!" "crc" } } */