You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pe...@apache.org on 2022/07/04 13:15:44 UTC
[celix] 01/01: Fix hash when sizeof(long) == 4.
This is an automated email from the ASF dual-hosted git repository.
pengzheng pushed a commit to branch hotfix/long_hash
in repository https://gitbox.apache.org/repos/asf/celix.git
commit 0ac43f12e43d13e64505575fb5fb7300cfa662a8
Author: PengZheng <ho...@gmail.com>
AuthorDate: Mon Jul 4 21:14:20 2022 +0800
Fix hash when sizeof(long) == 4.
Also remove cmake as conan tool_requires.
---
conanfile.py | 2 --
libs/utils/src/celix_hash_map.c | 2 +-
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/conanfile.py b/conanfile.py
index 014bb357..0deb7979 100644
--- a/conanfile.py
+++ b/conanfile.py
@@ -37,8 +37,6 @@ class CelixConan(ConanFile):
"It is a framework to develop (dynamic) modular software applications " \
"using component and/or service-oriented programming."
- tool_requires = "cmake/3.17.5"
-
options = {
"enable_testing": [True, False],
"enable_code_coverage": [True, False],
diff --git a/libs/utils/src/celix_hash_map.c b/libs/utils/src/celix_hash_map.c
index ed5ff4bc..591aa114 100644
--- a/libs/utils/src/celix_hash_map.c
+++ b/libs/utils/src/celix_hash_map.c
@@ -91,7 +91,7 @@ static unsigned int celix_stringHashMap_hash(const celix_hash_map_key_t* key) {
}
static unsigned int celix_longHashMap_hash(const celix_hash_map_key_t* key) {
- return key->longKey ^ (key->longKey >> 32);
+ return __builtin_choose_expr(sizeof(long) == 4, key->longKey ^ (key->longKey >> 16), key->longKey ^ (key->longKey >> 32));
}
static bool celix_stringHashMap_equals(const celix_hash_map_key_t* key1, const celix_hash_map_key_t* key2) {