scripts/include/hashtable.h | 4 +++- scripts/kconfig/expr.c | 5 +++-- scripts/kconfig/internal.h | 4 ---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/include/hashtable.h b/scripts/include/hashtable.h index 45abcb12bfce..a69332ccffcd 100644 --- a/scripts/include/hashtable.h +++ b/scripts/include/hashtable.h @@ -13,7 +13,9 @@ HASHTABLE_DECLARE(name, size) = \ { [0 ... ((size) - 1)] = HLIST_HEAD_INIT } -#define hash_head(table, key) (&(table)[(key) % HASH_SIZE(table)]) +#define HASH_KEY(key,size) (unsigned int)((unsigned int)(key)/(0x100000000ull/(size))) + +#define hash_head(table, key) (&(table)[HASH_KEY(key,HASH_SIZE(table))]) static inline void __hash_init(struct hlist_head *ht, unsigned int sz) { diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 2b91d16bf14f..19ca2ad10425 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -16,7 +16,8 @@ #define DEBUG_EXPR 0 -HASHTABLE_DEFINE(expr_hashtable, EXPR_HASHSIZE); +#define EXPR_HASHSIZE (1U << 14) +static HASHTABLE_DEFINE(expr_hashtable, EXPR_HASHSIZE); static struct expr *expr_eliminate_yn(struct expr *e); @@ -35,7 +36,7 @@ static struct expr *expr_lookup(enum expr_type type, void *l, void *r) struct expr *e; int hash; - hash = hash_32((unsigned int)type ^ hash_ptr(l) ^ hash_ptr(r)); + hash = hash_32((unsigned int)type + hash_ptr(l) + hash_ptr(r)); hash_for_each_possible(expr_hashtable, e, node, hash) { if (e->type == type && e->left._initdata == l && diff --git a/scripts/kconfig/internal.h b/scripts/kconfig/internal.h index d0ffce2dfbba..f244952496eb 100644 --- a/scripts/kconfig/internal.h +++ b/scripts/kconfig/internal.h @@ -11,10 +11,6 @@ extern HASHTABLE_DECLARE(sym_hashtable, SYMBOL_HASHSIZE); #define for_all_symbols(sym) \ hash_for_each(sym_hashtable, sym, node) -#define EXPR_HASHSIZE (1U << 14) - -extern HASHTABLE_DECLARE(expr_hashtable, EXPR_HASHSIZE); - void expr_invalidate_all(void); struct menu;