annotate src/core/ngx_crc32.h @ 2945:87da6664fb49 stable-0.7

merge r2897, r2898, r2899, r2901, r2902, r2904, r2905, r2906, r2907, r2909, r2910, r2922, r2923, r2924, r2925, r2929: various win32 fixes: *) use no-threads for Unix builds only *) Win32 returns ERROR_PATH_NOT_FOUND instead of ERROR_FILE_NOT_FOUND *) add trailing zero to a file name in ngx_win32_rename_file() *) fix logging in ngx_win32_rename_file() *) allow shared memory segments more than 4G *) fix memory leak in successful case *) log shared memory name in failure case *) test that zone has the same addresses in different processes *) add drive letter for Win32 root path *) log GetExitCodeProcess()'s errno *) test premature process termination *) fix debug logging *) exit if no workers could not be started *) do not quit old workers if no new workers could not be started *) a signaller process should stop configuration processing just after it is able to get pid file, this allows to not open log files, etc. *) win32 master process had aready closed listening sockets
author Igor Sysoev <igor@sysoev.ru>
date Mon, 15 Jun 2009 09:48:15 +0000
parents d6afb8723155
children d620f497c50f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
790
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
2 /*
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
3 * Copyright (C) Igor Sysoev
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
4 */
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
5
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
6
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
7 #ifndef _NGX_CRC32_H_INCLUDED_
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8 #define _NGX_CRC32_H_INCLUDED_
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
9
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
10
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11 #include <ngx_config.h>
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
12 #include <ngx_core.h>
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
13
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
14
793
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
15 extern uint32_t *ngx_crc32_table_short;
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
16 extern uint32_t ngx_crc32_table256[];
790
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
17
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
18
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
19 static ngx_inline uint32_t
793
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
20 ngx_crc32_short(u_char *p, size_t len)
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
21 {
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
22 u_char c;
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
23 uint32_t crc;
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
24
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
25 crc = 0xffffffff;
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
26
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
27 while (len--) {
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
28 c = *p++;
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
29 crc = ngx_crc32_table_short[(crc ^ (c & 0xf)) & 0xf] ^ (crc >> 4);
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
30 crc = ngx_crc32_table_short[(crc ^ (c >> 4)) & 0xf] ^ (crc >> 4);
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
31 }
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
32
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
33 return crc ^ 0xffffffff;
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
34 }
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
35
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
36
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
37 static ngx_inline uint32_t
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
38 ngx_crc32_long(u_char *p, size_t len)
790
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
39 {
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
40 uint32_t crc;
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
41
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
42 crc = 0xffffffff;
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
43
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
44 while (len--) {
793
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
45 crc = ngx_crc32_table256[(crc ^ *p++) & 0xff] ^ (crc >> 8);
790
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
46 }
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
47
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
48 return crc ^ 0xffffffff;
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
49 }
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
50
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
51
1694
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
52 #define ngx_crc32_init(crc) \
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
53 crc = 0xffffffff
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
54
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
55
1697
d6afb8723155 fix r1695
Igor Sysoev <igor@sysoev.ru>
parents: 1694
diff changeset
56 static ngx_inline void
1694
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
57 ngx_crc32_update(uint32_t *crc, u_char *p, size_t len)
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
58 {
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
59 uint32_t c;
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
60
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
61 c = *crc;
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
62
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
63 while (len--) {
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
64 c = ngx_crc32_table256[(c ^ *p++) & 0xff] ^ (c >> 8);
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
65 }
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
66
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
67 *crc = c;
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
68 }
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
69
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
70
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
71 #define ngx_crc32_final(crc) \
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
72 crc ^= 0xffffffff
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
73
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
74
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
75 ngx_int_t ngx_crc32_table_init(void);
793
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
76
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
77
790
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
78 #endif /* _NGX_CRC32_H_INCLUDED_ */