Back to home page

Nginx displayed by LXR

Source navigation ]
Diff markup ]
Identifier search ]
general search ]
 
 
Version: nginx-1.15.12 ]​[ nginx-1.16.0 ]​

0001 
0002 /*
0003  * Copyright (C) Igor Sysoev
0004  * Copyright (C) Nginx, Inc.
0005  */
0006 
0007 
0008 #ifndef _NGX_CRC_H_INCLUDED_
0009 #define _NGX_CRC_H_INCLUDED_
0010 
0011 
0012 #include <ngx_config.h>
0013 #include <ngx_core.h>
0014 
0015 
0016 /* 32-bit crc16 */
0017 
0018 static ngx_inline uint32_t
0019 ngx_crc(u_char *data, size_t len)
0020 {
0021     uint32_t  sum;
0022 
0023     for (sum = 0; len; len--) {
0024 
0025         /*
0026          * gcc 2.95.2 x86 and icc 7.1.006 compile
0027          * that operator into the single "rol" opcode,
0028          * msvc 6.0sp2 compiles it into four opcodes.
0029          */
0030         sum = sum >> 1 | sum << 31;
0031 
0032         sum += *data++;
0033     }
0034 
0035     return sum;
0036 }
0037 
0038 
0039 #endif /* _NGX_CRC_H_INCLUDED_ */