annotate src/core/ngx_crc.h @ 7981:0b5f12d5c531

PCRE2 library support. The PCRE2 library is now used by default if found, instead of the original PCRE library. If needed for some reason, this can be disabled with the --without-pcre2 configure option. To make it possible to specify paths to the library and include files via --with-cc-opt / --with-ld-opt, the library is first tested without any additional paths and options. If this fails, the pcre2-config script is used. Similarly to the original PCRE library, it is now possible to build PCRE2 from sources with nginx configure, by using the --with-pcre= option. It automatically detects if PCRE or PCRE2 sources are provided. Note that compiling PCRE2 10.33 and later requires inttypes.h. When compiling on Windows with MSVC, inttypes.h is only available starting with MSVC 2013. In older versions some replacement needs to be provided ("echo '#include <stdint.h>' > pcre2-10.xx/src/inttypes.h" is good enough for MSVC 2010). The interface on nginx side remains unchanged.
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 25 Dec 2021 01:07:15 +0300
parents d620f497c50f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
441
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 208
diff changeset
1
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 208
diff changeset
2 /*
444
42d11f017717 nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents: 441
diff changeset
3 * Copyright (C) Igor Sysoev
4412
d620f497c50f Copyright updated.
Maxim Konovalov <maxim@nginx.com>
parents: 792
diff changeset
4 * Copyright (C) Nginx, Inc.
441
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 208
diff changeset
5 */
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 208
diff changeset
6
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 208
diff changeset
7
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8 #ifndef _NGX_CRC_H_INCLUDED_
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
9 #define _NGX_CRC_H_INCLUDED_
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
10
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11
792
99858705b03f add includes
Igor Sysoev <igor@sysoev.ru>
parents: 789
diff changeset
12 #include <ngx_config.h>
99858705b03f add includes
Igor Sysoev <igor@sysoev.ru>
parents: 789
diff changeset
13 #include <ngx_core.h>
99858705b03f add includes
Igor Sysoev <igor@sysoev.ru>
parents: 789
diff changeset
14
99858705b03f add includes
Igor Sysoev <igor@sysoev.ru>
parents: 789
diff changeset
15
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
16 /* 32-bit crc16 */
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
17
776
5622cdd48e5b style fix
Igor Sysoev <igor@sysoev.ru>
parents: 467
diff changeset
18 static ngx_inline uint32_t
789
604f9671fae6 char* > u_char*
Igor Sysoev <igor@sysoev.ru>
parents: 776
diff changeset
19 ngx_crc(u_char *data, size_t len)
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
20 {
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
21 uint32_t sum;
208
0b67be7d4489 nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 201
diff changeset
22
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
23 for (sum = 0; len; len--) {
441
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 208
diff changeset
24
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
25 /*
776
5622cdd48e5b style fix
Igor Sysoev <igor@sysoev.ru>
parents: 467
diff changeset
26 * gcc 2.95.2 x86 and icc 7.1.006 compile
5622cdd48e5b style fix
Igor Sysoev <igor@sysoev.ru>
parents: 467
diff changeset
27 * that operator into the single "rol" opcode,
201
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
28 * msvc 6.0sp2 compiles it into four opcodes.
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
29 */
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
30 sum = sum >> 1 | sum << 31;
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
31
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
32 sum += *data++;
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
33 }
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
34
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
35 return sum;
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
36 }
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
37
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
38
267ea1d98683 nginx-0.0.1-2003-11-30-23:03:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
39 #endif /* _NGX_CRC_H_INCLUDED_ */