3 * Copyright (C) Igor Sysoev
7 #ifndef _NGX_CRC32_H_INCLUDED_
8 #define _NGX_CRC32_H_INCLUDED_
11 #include <ngx_config.h>
15 extern uint32_t *ngx_crc32_table_short;
16 extern uint32_t ngx_crc32_table256[];
19 static ngx_inline uint32_t
20 ngx_crc32_short(u_char *p, size_t len)
29 crc = ngx_crc32_table_short[(crc ^ (c & 0xf)) & 0xf] ^ (crc >> 4);
30 crc = ngx_crc32_table_short[(crc ^ (c >> 4)) & 0xf] ^ (crc >> 4);
33 return crc ^ 0xffffffff;
37 static ngx_inline uint32_t
38 ngx_crc32_long(u_char *p, size_t len)
45 crc = ngx_crc32_table256[(crc ^ *p++) & 0xff] ^ (crc >> 8);
48 return crc ^ 0xffffffff;
52 #define ngx_crc32_init(crc) \
56 static ngx_inline void
57 ngx_crc32_update(uint32_t *crc, u_char *p, size_t len)
64 c = ngx_crc32_table256[(c ^ *p++) & 0xff] ^ (c >> 8);
71 #define ngx_crc32_final(crc) \
75 ngx_int_t ngx_crc32_table_init(void);
78 #endif /* _NGX_CRC32_H_INCLUDED_ */