summaryrefslogtreecommitdiff
path: root/tools/lib/bpf/strset.h
diff options
context:
space:
mode:
authorAndrii Nakryiko <andrii@kernel.org>2021-03-18 22:40:28 +0300
committerAlexei Starovoitov <ast@kernel.org>2021-03-19 02:14:22 +0300
commit90d76d3ececc74bf43b2a97f178dadfa1e52be54 (patch)
tree8efd86b33ebb93bc89683b9a3410f3bcc6219e24 /tools/lib/bpf/strset.h
parent3b029e06f624efa90c9a4354e408acf134adb185 (diff)
downloadlinux-90d76d3ececc74bf43b2a97f178dadfa1e52be54.tar.xz
libbpf: Extract internal set-of-strings datastructure APIs
Extract BTF logic for maintaining a set of strings data structure, used for BTF strings section construction in writable mode, into separate re-usable API. This data structure is going to be used by bpf_linker to maintains ELF STRTAB section, which has the same layout as BTF strings section. Suggested-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20210318194036.3521577-5-andrii@kernel.org
Diffstat (limited to 'tools/lib/bpf/strset.h')
-rw-r--r--tools/lib/bpf/strset.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/lib/bpf/strset.h b/tools/lib/bpf/strset.h
new file mode 100644
index 000000000000..b6ddf77a83c2
--- /dev/null
+++ b/tools/lib/bpf/strset.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
+
+/* Copyright (c) 2021 Facebook */
+#ifndef __LIBBPF_STRSET_H
+#define __LIBBPF_STRSET_H
+
+#include <stdbool.h>
+#include <stddef.h>
+
+struct strset;
+
+struct strset *strset__new(size_t max_data_sz, const char *init_data, size_t init_data_sz);
+void strset__free(struct strset *set);
+
+const char *strset__data(const struct strset *set);
+size_t strset__data_size(const struct strset *set);
+
+int strset__find_str(struct strset *set, const char *s);
+int strset__add_str(struct strset *set, const char *s);
+
+#endif /* __LIBBPF_STRSET_H */