summaryrefslogtreecommitdiff
path: root/tools/perf/util/rblist.h
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2012-08-05 10:39:12 (GMT)
committerIngo Molnar <mingo@kernel.org>2012-08-05 10:39:12 (GMT)
commit8a06bf14008fbf55a86105b8569494f4beeb8762 (patch)
tree74c0313294eb9dc2bb409ce5ea154b478c6628cd /tools/perf/util/rblist.h
parente7882d6c40874a5b5033ca85f7508a602a60b662 (diff)
parent7f309ed6453926a81e2a97d274f67f1e48f0d74c (diff)
downloadlinux-8a06bf14008fbf55a86105b8569494f4beeb8762.tar.xz
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/core fixes and some late updates from Arnaldo Carvalho de Melo: * Make clean brace expansion fix for some shells, from Palmer Cox * Warn user just once per guest kernel when not finding kernel info, from David Ahern * perf test fix from Jiri Olsa * Fix error handling on event creation in perf top, from David Ahern * Fix check on perf_target__strnerror, from Namhyung Kim * Save the whole cmdline, from David Ahern * Prep work for the DWARF CFI post unwinder, so that it doesn't uses perf_session in lots of places, just evlist/evsel is enough. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/util/rblist.h')
-rw-r--r--tools/perf/util/rblist.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/tools/perf/util/rblist.h b/tools/perf/util/rblist.h
new file mode 100644
index 0000000..6d0cae5
--- /dev/null
+++ b/tools/perf/util/rblist.h
@@ -0,0 +1,47 @@
+#ifndef __PERF_RBLIST_H
+#define __PERF_RBLIST_H
+
+#include <linux/rbtree.h>
+#include <stdbool.h>
+
+/*
+ * create node structs of the form:
+ * struct my_node {
+ * struct rb_node rb_node;
+ * ... my data ...
+ * };
+ *
+ * create list structs of the form:
+ * struct mylist {
+ * struct rblist rblist;
+ * ... my data ...
+ * };
+ */
+
+struct rblist {
+ struct rb_root entries;
+ unsigned int nr_entries;
+
+ int (*node_cmp)(struct rb_node *rbn, const void *entry);
+ struct rb_node *(*node_new)(struct rblist *rlist, const void *new_entry);
+ void (*node_delete)(struct rblist *rblist, struct rb_node *rb_node);
+};
+
+void rblist__init(struct rblist *rblist);
+void rblist__delete(struct rblist *rblist);
+int rblist__add_node(struct rblist *rblist, const void *new_entry);
+void rblist__remove_node(struct rblist *rblist, struct rb_node *rb_node);
+struct rb_node *rblist__find(struct rblist *rblist, const void *entry);
+struct rb_node *rblist__entry(const struct rblist *rblist, unsigned int idx);
+
+static inline bool rblist__empty(const struct rblist *rblist)
+{
+ return rblist->nr_entries == 0;
+}
+
+static inline unsigned int rblist__nr_entries(const struct rblist *rblist)
+{
+ return rblist->nr_entries;
+}
+
+#endif /* __PERF_RBLIST_H */