| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-fdump-tree-crc-details -O2" } */ |
| 3 |
/* { dg-require-effective-target int32plus } */ |
| 4 |
|
| 5 |
// File - utils.ii |
| 6 |
/* We don't support the case when CRC variable's size is different from the |
| 7 |
calculated CRC (I.e. in this case CRC 16 is calculated.) */ |
| 8 |
|
| 9 |
void crc_byte(const char data, unsigned int *crc16) |
| 10 |
{ |
| 11 |
int k; |
| 12 |
unsigned c,d ; |
| 13 |
|
| 14 |
c = data << 8 ; |
| 15 |
d = c; |
| 16 |
|
| 17 |
for (k = 0; k < 8; k++) { |
| 18 |
*crc16 = (c & 0x8000) ^ *crc16; |
| 19 |
|
| 20 |
if (*crc16 & 0x8000) { |
| 21 |
*crc16 = *crc16 << 1; |
| 22 |
*crc16 = *crc16 ^ 0x8005; |
| 23 |
} else |
| 24 |
*crc16 = *crc16 << 1; |
| 25 |
|
| 26 |
d = d << 1; |
| 27 |
c = d; |
| 28 |
} |
| 29 |
} |
| 30 |
/* { dg-final { scan-tree-dump "maybe contains CRC calculation." "crc" } } */ |