comparison src/core/ngx_crc.h @ 201:267ea1d98683

nginx-0.0.1-2003-11-30-23:03:18 import
author Igor Sysoev <igor@sysoev.ru>
date Sun, 30 Nov 2003 20:03:18 +0000
parents
children 0b67be7d4489
comparison
equal deleted inserted replaced
200:abeaebe0a33c 201:267ea1d98683
1 #ifndef _NGX_CRC_H_INCLUDED_
2 #define _NGX_CRC_H_INCLUDED_
3
4
5 /* 32-bit crc16 */
6
7 ngx_inline static uint32_t ngx_crc(char *data, size_t len)
8 {
9 uint32_t sum;
10
11 for (sum = 0; len; len--) {
12 /*
13 * gcc 2.95.2 x86 and icc 7.1.006 compile that operator
14 * into the single rol opcode.
15 * msvc 6.0sp2 compiles it into four opcodes.
16 */
17 sum = sum >> 1 | sum << 31;
18
19 sum += *data++;
20 }
21
22 return sum;
23 }
24
25
26 #endif /* _NGX_CRC_H_INCLUDED_ */