Skip to contentSkip to conversation

bpftool: fix C++ additions to skeleton

PATCH Applied Andrii Nakryiko 2 participants 2 messages Feb 16, 2022 – Feb 17, 2022

Subsystems (2)
lore
Share & tools
lore

Andrii Nakryiko

author maintainer
#0 lore raw

PATCH 1/1 bpftool: fix C++ additions to skeleton

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")
---
 tools/bpf/bpftool/gen.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
tools/bpf/bpftool/gen.c +7 -7
index e461059a72ee..f8c1413523a3 100644
@@ -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\
Signature · 1 line
2.30.2
#1 lore raw
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:

Quoted 8 lines · On Wed, 16 Feb 2022 15:35:40 -0800 you wrote:

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")

[...]

Here is the summary with links:
- [bpf-next] bpftool: fix C++ additions to skeleton

    https://git.kernel.org/bpf/bpf-next/c/9b6eb0478dfa

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html