Skip to content

Commit 8ca8d4a

Browse files
acmelborkmann
authored andcommitted
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 <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 042b154 commit 8ca8d4a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

tools/lib/bpf/hashmap.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010

1111
#include <stdbool.h>
1212
#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)
1716
#endif
1817

1918
static inline size_t hash_bits(size_t h, int bits)

0 commit comments

Comments
 (0)