0
|
1
|
|
2 /*
|
|
3 * Copyright (C) Igor Sysoev
|
|
4 */
|
|
5
|
|
6
|
|
7 #ifndef _NGX_CRC_H_INCLUDED_
|
|
8 #define _NGX_CRC_H_INCLUDED_
|
|
9
|
|
10
|
|
11 /* 32-bit crc16 */
|
|
12
|
248
|
13 static ngx_inline uint32_t
|
|
14 ngx_crc(char *data, size_t len)
|
0
|
15 {
|
|
16 uint32_t sum;
|
|
17
|
|
18 for (sum = 0; len; len--) {
|
|
19
|
|
20 /*
|
248
|
21 * gcc 2.95.2 x86 and icc 7.1.006 compile
|
|
22 * that operator into the single "rol" opcode,
|
0
|
23 * msvc 6.0sp2 compiles it into four opcodes.
|
|
24 */
|
|
25 sum = sum >> 1 | sum << 31;
|
|
26
|
|
27 sum += *data++;
|
|
28 }
|
|
29
|
|
30 return sum;
|
|
31 }
|
|
32
|
|
33
|
|
34 #endif /* _NGX_CRC_H_INCLUDED_ */
|