comparison src/core/ngx_crc32.h @ 790:f9a971440614

ngx_crc32()
author Igor Sysoev <igor@sysoev.ru>
date Wed, 18 Oct 2006 19:00:21 +0000
parents
children 8d39da951bbd
comparison
equal deleted inserted replaced
789:604f9671fae6 790:f9a971440614
1
2 /*
3 * Copyright (C) Igor Sysoev
4 */
5
6
7 #ifndef _NGX_CRC32_H_INCLUDED_
8 #define _NGX_CRC32_H_INCLUDED_
9
10
11 #include <ngx_config.h>
12 #include <ngx_core.h>
13
14
15 extern uint32_t ngx_crc32_table[];
16
17
18 static ngx_inline uint32_t
19 ngx_crc32(u_char *p, size_t len)
20 {
21 uint32_t crc;
22
23 crc = 0xffffffff;
24
25 while (len--) {
26 crc = ngx_crc32_table[(crc ^ *p++) & 0xff] ^ (crc >> 8);
27 }
28
29 return crc ^ 0xffffffff;
30 }
31
32
33 #endif /* _NGX_CRC32_H_INCLUDED_ */