Skip to content

Commit

Permalink
bpftool: Fix C++ additions to skeleton
Browse files Browse the repository at this point in the history
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: bb8ffe6 ("bpftool: Add C++-specific open/load/etc skeleton wrappers")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220216233540.216642-1-andrii@kernel.org
  • Loading branch information
anakryiko authored and Alexei Starovoitov committed Feb 17, 2022
1 parent f76d850 commit 9b6eb04
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tools/bpf/bpftool/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down

0 comments on commit 9b6eb04

Please sign in to comment.