Skip to content

Commit 611edf1

Browse files
Yuze Chianakryiko
authored andcommitted
libbpf: Fix is_pow_of_2
Move the correct definition from linker.c into libbpf_internal.h. Fixes: 0087a68 ("libbpf: Automatically fix up BPF_MAP_TYPE_RINGBUF size, if necessary") Reported-by: Yuze Chi <chiyuze@google.com> Signed-off-by: Yuze Chi <chiyuze@google.com> Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20220603055156.2830463-1-irogers@google.com
1 parent e6ff92f commit 611edf1

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

tools/lib/bpf/libbpf.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5071,11 +5071,6 @@ bpf_object__populate_internal_map(struct bpf_object *obj, struct bpf_map *map)
50715071

50725072
static void bpf_map__destroy(struct bpf_map *map);
50735073

5074-
static bool is_pow_of_2(size_t x)
5075-
{
5076-
return x && (x & (x - 1));
5077-
}
5078-
50795074
static size_t adjust_ringbuf_sz(size_t sz)
50805075
{
50815076
__u32 page_sz = sysconf(_SC_PAGE_SIZE);

tools/lib/bpf/libbpf_internal.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,4 +580,9 @@ struct bpf_link * usdt_manager_attach_usdt(struct usdt_manager *man,
580580
const char *usdt_provider, const char *usdt_name,
581581
__u64 usdt_cookie);
582582

583+
static inline bool is_pow_of_2(size_t x)
584+
{
585+
return x && (x & (x - 1)) == 0;
586+
}
587+
583588
#endif /* __LIBBPF_LIBBPF_INTERNAL_H */

tools/lib/bpf/linker.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -697,11 +697,6 @@ static int linker_load_obj_file(struct bpf_linker *linker, const char *filename,
697697
return err;
698698
}
699699

700-
static bool is_pow_of_2(size_t x)
701-
{
702-
return x && (x & (x - 1)) == 0;
703-
}
704-
705700
static int linker_sanity_check_elf(struct src_obj *obj)
706701
{
707702
struct src_sec *sec;

0 commit comments

Comments
 (0)