lkml.org 
[lkml]   [2022]   [Jun]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH bpf-next] libbpf: Include linux/log2.h to use is_pow_of_2()
Date
is_pow_of_2() is already defined in tools/include/linux/log2.h [1],
so no need to define it again in tools/lib/bpf/libbpf_internal.h,
just include linux/log2.h directly.

[1] https://lore.kernel.org/bpf/20220619171248.GC3362@bug/

Suggested-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
tools/lib/bpf/libbpf_internal.h | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h
index a1ad145..021946a 100644
--- a/tools/lib/bpf/libbpf_internal.h
+++ b/tools/lib/bpf/libbpf_internal.h
@@ -13,6 +13,7 @@
#include <limits.h>
#include <errno.h>
#include <linux/err.h>
+#include <linux/log2.h>
#include <fcntl.h>
#include <unistd.h>
#include "libbpf_legacy.h"
@@ -582,9 +583,4 @@ struct bpf_link * usdt_manager_attach_usdt(struct usdt_manager *man,
const char *usdt_provider, const char *usdt_name,
__u64 usdt_cookie);

-static inline bool is_pow_of_2(size_t x)
-{
- return x && (x & (x - 1)) == 0;
-}
-
#endif /* __LIBBPF_LIBBPF_INTERNAL_H */
--
2.1.0
\
 
 \ /
  Last update: 2022-06-20 09:59    [W:0.068 / U:1.588 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site