Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libbpf: Define __WORDSIZE if not available

Some systems, such as Android, don't have a define for __WORDSIZE, do it
in terms of __SIZEOF_LONG__, as done in perf since 2012:

http://git.kernel.org/torvalds/c/3f34f6c0233ae055b5

For reference: https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html

I build tested it here and Andrii did some Travis CI build tests too.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200608161150.GA3073@kernel.org

authored by

Arnaldo Carvalho de Melo and committed by
Daniel Borkmann
8ca8d4a8 042b1545

+3 -4
+3 -4
tools/lib/bpf/hashmap.h
··· 10 10 11 11 #include <stdbool.h> 12 12 #include <stddef.h> 13 - #ifdef __GLIBC__ 14 - #include <bits/wordsize.h> 15 - #else 16 - #include <bits/reg.h> 13 + #include <limits.h> 14 + #ifndef __WORDSIZE 15 + #define __WORDSIZE (__SIZEOF_LONG__ * 8) 17 16 #endif 18 17 19 18 static inline size_t hash_bits(size_t h, int bits)