Skip to content

Commit

Permalink
Fix compilation on Windows
Browse files Browse the repository at this point in the history
For some unknown reasons, `MurmurHash` name doesn't work on Window
  • Loading branch information
IvanNardi committed Aug 14, 2023
1 parent cfbb7a4 commit b473f88
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/lib/ndpi_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ bool ndpi_filter_add(ndpi_filter *f, u_int32_t value) {
/* ******************************************* */

bool ndpi_filter_add_string(ndpi_filter *f, char *string) {
return(ndpi_filter_add(f, MurmurHash(string, strlen(string), 0xD6DFE7)));
return(ndpi_filter_add(f, MurmurHash3(string, strlen(string), 0xD6DFE7)));
}

/* ******************************************* */
Expand All @@ -76,7 +76,7 @@ bool ndpi_filter_contains(ndpi_filter *f, u_int32_t value) {
/* ******************************************* */

bool ndpi_filter_contains_string(ndpi_filter *f, char *string) {
return(ndpi_filter_contains(f, MurmurHash(string, strlen(string), 0xD6DFE7)));
return(ndpi_filter_contains(f, MurmurHash3(string, strlen(string), 0xD6DFE7)));
}

/* ******************************************* */
Expand Down
2 changes: 1 addition & 1 deletion src/lib/third_party/include/MurmurHash3.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

#include <stdint.h>

uint32_t MurmurHash(const void * key, uint32_t len, uint32_t seed);
uint32_t MurmurHash3(const void * key, uint32_t len, uint32_t seed);

#endif
2 changes: 1 addition & 1 deletion src/lib/third_party/src/hll/MurmurHash3.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ xo*/

#define ROTL32(x, r) ((x) << (r)) | ((x) >> (32 - (r)))

u_int32_t MurmurHash(const void *key, u_int32_t len, u_int32_t seed) {
u_int32_t MurmurHash3(const void *key, u_int32_t len, u_int32_t seed) {
const u_int8_t *data = (const u_int8_t *)key;
const int32_t nblocks = (int32_t)len / 4;

Expand Down
2 changes: 1 addition & 1 deletion src/lib/third_party/src/hll/hll.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static __inline int _hll_add_hash(struct ndpi_hll *hll, u_int32_t hash) {

/* Return: 0 = nothing changed, 1 = ranking changed */
int hll_add(struct ndpi_hll *hll, const void *buf, size_t size) {
u_int32_t hash = MurmurHash((const char *)buf, (u_int32_t)size, 0x5f61767a);
u_int32_t hash = MurmurHash3((const char *)buf, (u_int32_t)size, 0x5f61767a);

return(_hll_add_hash(hll, hash));
}
Expand Down
1 change: 1 addition & 0 deletions windows/nDPI.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@
<ClCompile Include="..\src\lib\third_party\src\ndpi_sha1.c" />
<ClCompile Include="..\src\lib\third_party\src\sha1-fast.c" />
<ClCompile Include="..\src\lib\third_party\src\strptime.c" />
<ClCompile Include="..\src\lib\third_party\src\hll\MurmurHash3.c" />
<ClCompile Include="src\getopt.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</ClCompile>
Expand Down
3 changes: 3 additions & 0 deletions windows/nDPI.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@
<ClCompile Include="..\src\lib\third_party\src\strptime.c">
<Filter>third_party</Filter>
</ClCompile>
<ClCompile Include="..\src\lib\third_party\src\hll\MurmurHash3.c" />
<Filter>third_party</Filter>
</ClCompile>
<ClCompile Include="..\src\lib\protocols\tocaboca.c" />
<ClCompile Include="..\src\lib\protocols\raknet.c" />
<ClCompile Include="..\src\lib\protocols\sd_rtn.c" />
Expand Down

0 comments on commit b473f88

Please sign in to comment.