int bitcount(long i) { i = ((i & 0xAAAAAAAA) >> 1) + (i & 0x55555555); i = ((i & 0xCCCCCCCC) >> 2) + (i & 0x33333333); i = ((i & 0xF0F0F0F0) >> 4) + (i & 0x0F0F0F0F); i = ((i & 0xFF00FF00) >> 8) + (i & 0x00FF00FF); i = ((i & 0xFFFF0000) >> 16) + (i & 0x0000FFFF); return (int)i; } #ifdef TEST #include #include #define plural_text(n) &"s"[(1 == (n))] void main(int argc, char *argv[]) { long n; while(--argc) { int i; n = atol(*++argv); i = bitcount(n); printf("%ld contains %d bit%s set\n", n, i, plural_text(i)); } } #endif /* TEST */ img src='/cgit.png' alt='cgit logo'/> index : net-next.git
net-next plumbingsTobias Klauser
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMickaël Salaün <mic@digikod.net>2017-02-10 00:21:40 +0100
committerDavid S. Miller <davem@davemloft.net>2017-02-10 15:56:07 -0500
commite5ff7c4019c6cb6e86bc9d6d16e8a8f921133c70 (patch)
treec3060074ae5ccfa0ddb873d09ab08e4992de855a
parent10ecc728fe12dbd206e2d4d8b6e96082632b969c (diff)
bpf: Use bpf_map_lookup_elem() from the library
Replace bpf_map_lookup() with bpf_map_lookup_elem() calls. Signed-off-by: Mickaël Salaün <mic@digikod.net> Cc: Alexei Starovoitov <ast@fb.com> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--tools/lib/bpf/bpf.c2
-rw-r--r--tools/lib/bpf/bpf.h2
-rw-r--r--tools/testing/selftests/bpf/bpf_sys.h11
-rw-r--r--tools/testing/selftests/bpf/test_lpm_map.c16
-rw-r--r--tools/testing/selftests/bpf/test_lru_map.c28
-rw-r--r--tools/testing/selftests/bpf/test_maps.c30
6 files changed, 39 insertions, 50 deletions
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c