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) Austin Appleby
0004  */
0005 
0006 
0007 #include <ngx_config.h>
0008 #include <ngx_core.h>
0009 
0010 
0011 uint32_t
0012 ngx_murmur_hash2(u_char *data, size_t len)
0013 {
0014     uint32_t  h, k;
0015 
0016     h = 0 ^ len;
0017 
0018     while (len >= 4) {
0019         k  = data[0];
0020         k |= data[1] << 8;
0021         k |= data[2] << 16;
0022         k |= data[3] << 24;
0023 
0024         k *= 0x5bd1e995;
0025         k ^= k >> 24;
0026         k *= 0x5bd1e995;
0027 
0028         h *= 0x5bd1e995;
0029         h ^= k;
0030 
0031         data += 4;
0032         len -= 4;
0033     }
0034 
0035     switch (len) {
0036     case 3:
0037         h ^= data[2] << 16;
0038         /* fall through */
0039     case 2:
0040         h ^= data[1] << 8;
0041         /* fall through */
0042     case 1:
0043         h ^= data[0];
0044         h *= 0x5bd1e995;
0045     }
0046 
0047     h ^= h >> 13;
0048     h *= 0x5bd1e995;
0049     h ^= h >> 15;
0050 
0051     return h;
0052 }