1 Fix broken hashmap implementation to ensure that hash_bits returns value fitting in
2 given bits (for bits > 0): multiplier is long long, so shift bits must be based on
3 long long, not __WORDSIZE.
4 --- linux-5.7/tools/lib/bpf/hashmap.h.orig 2020-06-01 01:49:15.000000000 +0200
5 +++ linux-5.7/tools/lib/bpf/hashmap.h 2020-06-21 15:22:07.298466419 +0200
11 -#include <bits/wordsize.h>
13 -#include <bits/reg.h>
15 #include "libbpf_internal.h"
17 static inline size_t hash_bits(size_t h, int bits)
19 /* shuffle bits and return requested number of upper bits */
20 - return (h * 11400714819323198485llu) >> (__WORDSIZE - bits);
21 + return (h * 11400714819323198485llu) >> (__SIZEOF_LONG_LONG__ * 8 - bits);
24 typedef size_t (*hashmap_hash_fn)(const void *key, void *ctx);