]> git.kaiwu.me - nginx.git/commitdiff
rename ngx_crc32_init() to ngx_crc32_table_init()
authorIgor Sysoev <igor@sysoev.ru>
Fri, 7 Dec 2007 20:19:41 +0000 (20:19 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Fri, 7 Dec 2007 20:19:41 +0000 (20:19 +0000)
ngx_crc32_init(), ngx_crc32_update(), ngx_crc32_final()

src/core/nginx.c
src/core/ngx_crc32.c
src/core/ngx_crc32.h

index 579ee161bd7fec76c64c153781817973f5de4ce0..ae68605ef2e297ef72096f8c643d1f87f03b25dc 100644 (file)
@@ -273,9 +273,11 @@ main(int argc, char *const *argv)
         return 1;
     }
 
-    /* ngx_crc32_init() requires ngx_cacheline_size set in ngx_os_init() */
+    /*
+     * ngx_crc32_table_init() requires ngx_cacheline_size set in ngx_os_init()
+     */
 
-    if (ngx_crc32_init() != NGX_OK) {
+    if (ngx_crc32_table_init() != NGX_OK) {
         return 1;
     }
 
index 64b02ac7a69d2328f1e76779ced62ff9685a3226..624510cee3249fa9117fae99a8acdf6f4e7dde36 100644 (file)
@@ -102,7 +102,7 @@ uint32_t *ngx_crc32_table_short = ngx_crc32_table16;
 
 
 ngx_int_t
-ngx_crc32_init(void)
+ngx_crc32_table_init(void)
 {
     void  *p;
 
index 7d5279d36fd8e41d26076336b32d289f90ad3fd5..fe76156dc61be4b228b271b2da782596908c4446 100644 (file)
@@ -49,7 +49,30 @@ ngx_crc32_long(u_char *p, size_t len)
 }
 
 
-ngx_int_t ngx_crc32_init(void);
+#define ngx_crc32_init(crc)                                                   \
+    crc = 0xffffffff
+
+
+static void
+ngx_crc32_update(uint32_t *crc, u_char *p, size_t len)
+{
+    uint32_t  c;
+
+    c = *crc;
+
+    while (len--) {
+        c = ngx_crc32_table256[(c ^ *p++) & 0xff] ^ (c >> 8);
+    }
+
+    *crc = c;
+}
+
+
+#define ngx_crc32_final(crc)                                                  \
+    crc ^= 0xffffffff
+
+
+ngx_int_t ngx_crc32_table_init(void);
 
 
 #endif /* _NGX_CRC32_H_INCLUDED_ */