Commit 611edf1b authored by Yuze Chi's avatar Yuze Chi Committed by Andrii Nakryiko

libbpf: Fix is_pow_of_2

Move the correct definition from linker.c into libbpf_internal.h.

Fixes: 0087a681 ("libbpf: Automatically fix up BPF_MAP_TYPE_RINGBUF size, if necessary")
Reported-by: default avatarYuze Chi <chiyuze@google.com>
Signed-off-by: default avatarYuze Chi <chiyuze@google.com>
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220603055156.2830463-1-irogers@google.com
parent e6ff92f4
...@@ -5071,11 +5071,6 @@ bpf_object__populate_internal_map(struct bpf_object *obj, struct bpf_map *map) ...@@ -5071,11 +5071,6 @@ bpf_object__populate_internal_map(struct bpf_object *obj, struct bpf_map *map)
static void bpf_map__destroy(struct bpf_map *map); static void bpf_map__destroy(struct bpf_map *map);
static bool is_pow_of_2(size_t x)
{
return x && (x & (x - 1));
}
static size_t adjust_ringbuf_sz(size_t sz) static size_t adjust_ringbuf_sz(size_t sz)
{ {
__u32 page_sz = sysconf(_SC_PAGE_SIZE); __u32 page_sz = sysconf(_SC_PAGE_SIZE);
......
...@@ -580,4 +580,9 @@ struct bpf_link * usdt_manager_attach_usdt(struct usdt_manager *man, ...@@ -580,4 +580,9 @@ struct bpf_link * usdt_manager_attach_usdt(struct usdt_manager *man,
const char *usdt_provider, const char *usdt_name, const char *usdt_provider, const char *usdt_name,
__u64 usdt_cookie); __u64 usdt_cookie);
static inline bool is_pow_of_2(size_t x)
{
return x && (x & (x - 1)) == 0;
}
#endif /* __LIBBPF_LIBBPF_INTERNAL_H */ #endif /* __LIBBPF_LIBBPF_INTERNAL_H */
...@@ -697,11 +697,6 @@ static int linker_load_obj_file(struct bpf_linker *linker, const char *filename, ...@@ -697,11 +697,6 @@ static int linker_load_obj_file(struct bpf_linker *linker, const char *filename,
return err; return err;
} }
static bool is_pow_of_2(size_t x)
{
return x && (x & (x - 1)) == 0;
}
static int linker_sanity_check_elf(struct src_obj *obj) static int linker_sanity_check_elf(struct src_obj *obj)
{ {
struct src_sec *sec; struct src_sec *sec;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment