BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpftool: fix C++ additions to skeleton
@ 2022-02-16 23:35 Andrii Nakryiko
  2022-02-17  1:10 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Andrii Nakryiko @ 2022-02-16 23:35 UTC (permalink / raw)
  To: bpf, ast, daniel; +Cc: andrii, kernel-team

Mark C++-specific T::open() and other methods as static inline to avoid
symbol redefinition when multiple files use the same skeleton header in
an application.

Fixes: bb8ffe61ea45 ("bpftool: Add C++-specific open/load/etc skeleton wrappers")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
 tools/bpf/bpftool/gen.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
index e461059a72ee..f8c1413523a3 100644
--- a/tools/bpf/bpftool/gen.c
+++ b/tools/bpf/bpftool/gen.c
@@ -834,13 +834,13 @@ static int do_skeleton(int argc, char **argv)
 		\n\
 									    \n\
 		#ifdef __cplusplus					    \n\
-			static struct %1$s *open(const struct bpf_object_open_opts *opts = nullptr);\n\
-			static struct %1$s *open_and_load();		    \n\
-			static int load(struct %1$s *skel);		    \n\
-			static int attach(struct %1$s *skel);		    \n\
-			static void detach(struct %1$s *skel);		    \n\
-			static void destroy(struct %1$s *skel);		    \n\
-			static const void *elf_bytes(size_t *sz);	    \n\
+			static inline struct %1$s *open(const struct bpf_object_open_opts *opts = nullptr);\n\
+			static inline struct %1$s *open_and_load();	    \n\
+			static inline int load(struct %1$s *skel);	    \n\
+			static inline int attach(struct %1$s *skel);	    \n\
+			static inline void detach(struct %1$s *skel);	    \n\
+			static inline void destroy(struct %1$s *skel);	    \n\
+			static inline const void *elf_bytes(size_t *sz);    \n\
 		#endif /* __cplusplus */				    \n\
 		};							    \n\
 									    \n\
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-17  1:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-16 23:35 [PATCH bpf-next] bpftool: fix C++ additions to skeleton Andrii Nakryiko
2022-02-17  1:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox