]> git.pld-linux.org Git - packages/kernel-tools.git/blob - kernel-tools-bpf-hashmap.patch
e5300b1f96dac17f2eb0176a8ce2ac9120d36a72
[packages/kernel-tools.git] / kernel-tools-bpf-hashmap.patch
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
6 @@ -10,17 +10,12 @@
7  
8  #include <stdbool.h>
9  #include <stddef.h>
10 -#ifdef __GLIBC__
11 -#include <bits/wordsize.h>
12 -#else
13 -#include <bits/reg.h>
14 -#endif
15  #include "libbpf_internal.h"
16  
17  static inline size_t hash_bits(size_t h, int bits)
18  {
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);
22  }
23  
24  typedef size_t (*hashmap_hash_fn)(const void *key, void *ctx);
This page took 0.049694 seconds and 2 git commands to generate.