| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-fdump-tree-crc-details -O2" } */ |
| 3 |
/* { dg-require-effective-target int32plus } */ |
| 4 |
|
| 5 |
// File - png_tools.i |
| 6 |
#include <stdint.h> |
| 7 |
|
| 8 |
uint32_t gen_grAb_crc(unsigned char *buf) |
| 9 |
{ |
| 10 |
uint32_t crc = 0xffffffff; |
| 11 |
uint32_t crc_table[256]; |
| 12 |
uint32_t c; |
| 13 |
int32_t n, k; |
| 14 |
for (n = 0; n < 256; n++) { |
| 15 |
c = (uint32_t) n; |
| 16 |
for (k = 0; k < 8; k++) { |
| 17 |
if (c & 1) |
| 18 |
c = ((uint32_t) 0xedb88320) ^ (c >> 1); |
| 19 |
else |
| 20 |
c = c >> 1; |
| 21 |
} |
| 22 |
crc_table[n] = c; |
| 23 |
} |
| 24 |
for (n = 0; n < 12; n++) |
| 25 |
crc = crc_table[(crc ^ buf[n]) & 0xff] ^ (crc >> 8); |
| 26 |
return crc ^ ((uint32_t) 0xffffffff); |
| 27 |
} |
| 28 |
|
| 29 |
/* { dg-final { scan-tree-dump "calculates CRC!" "crc" } } */ |