Debian Codegraph @

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

raw
1 /* { dg-do compile } */
2 /* { dg-options "-fdump-tree-crc-details -O2" } */
3 /* { dg-require-effective-target int32plus } */
4
5 #include <stdint.h>
6 #include <stddef.h>
7 // File - misc
8 uint32_t _crc32(uint32_t crc, uint32_t data) {
9 int i;
10 crc = crc ^ data;
11
12 for (i = 0; i < 32; i++) {
13 if (crc & 0x80000000)
14 crc = (crc << 1) ^ 0x04C11DB7;
15 else
16 crc = (crc << 1);
17 }
18
19 return crc;
20 }
21
22 uint32_t stm_crc32(const uint8_t *data, size_t size) {
23 uint32_t crc = 0xffffffff;
24 const uint32_t *pend = (const uint32_t *) (data + size);
25 for (const uint32_t *p = (const uint32_t *) (data); p < pend; p++)
26 crc = _crc32(crc, *p);
27 return crc;
28 }
29
30 /* { dg-final { scan-tree-dump-times "calculates CRC!" 2 "crc" } } */