comparison crc32qw.c @ 0:422835bc1aca

*: checkin
author Paper <paper@tflc.us>
date Mon, 09 Feb 2026 01:15:00 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:422835bc1aca
1 #include "crc32i.h"
2
3 uint32_t crc32qw_r(uint32_t crc, const unsigned char *message, size_t sz)
4 {
5 while (sz >= 4) {
6 union {
7 unsigned char b[4];
8 uint32_t w;
9 } w;
10
11 #if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
12 /* Tell GCC that we will be aliasing */
13 w.w = *(__attribute__((__may_alias__)) uint32_t *)message;
14 #else
15 /* ... */
16 w.b[0] = message[0];
17 w.b[1] = message[1];
18 w.b[2] = message[2];
19 w.b[3] = message[3];
20 #endif
21
22 crc ^= w.w;
23
24 crc = (crc >> 8) ^ crc32_tab[crc & 0xFF];
25 crc = (crc >> 8) ^ crc32_tab[crc & 0xFF];
26 crc = (crc >> 8) ^ crc32_tab[crc & 0xFF];
27 crc = (crc >> 8) ^ crc32_tab[crc & 0xFF];
28
29 message += 4;
30 sz -= 4;
31 }
32
33 if (!sz) return crc;
34
35 return crc32c_r(crc, message, sz);
36 }