diff options
| -rw-r--r-- | crc32.c | 12 |
1 files changed, 12 insertions, 0 deletions
| @@ -237,6 +237,18 @@ unsigned long ZEXPORT crc32(crc, buf, len) | |||
| 237 | 237 | ||
| 238 | #ifdef BYFOUR | 238 | #ifdef BYFOUR |
| 239 | 239 | ||
| 240 | /* | ||
| 241 | This BYFOUR code accesses the passed unsigned char * buffer with a 32-bit | ||
| 242 | integer pointer type. This violates the strict aliasing rule, where a | ||
| 243 | compiler can assume, for optimization purposes, that two pointers to | ||
| 244 | fundamentally different types won't ever point to the same memory. This can | ||
| 245 | manifest as a problem only if one of the pointers is written to. This code | ||
| 246 | only reads from those pointers. So long as this code remains isolated in | ||
| 247 | this compilation unit, there won't be a problem. For this reason, this code | ||
| 248 | should not be copied and pasted into a compilation unit in which other code | ||
| 249 | writes to the buffer that is passed to these routines. | ||
| 250 | */ | ||
| 251 | |||
| 240 | /* ========================================================================= */ | 252 | /* ========================================================================= */ |
| 241 | #define DOLIT4 c ^= *buf4++; \ | 253 | #define DOLIT4 c ^= *buf4++; \ |
| 242 | c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ | 254 | c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ |
