xref: /openbmc/linux/tools/perf/util/dsos.h (revision f80be457)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __PERF_DSOS
3 #define __PERF_DSOS
4 
5 #include <stdbool.h>
6 #include <stdio.h>
7 #include <linux/list.h>
8 #include <linux/rbtree.h>
9 #include "rwsem.h"
10 
11 struct dso;
12 struct dso_id;
13 
14 /*
15  * DSOs are put into both a list for fast iteration and rbtree for fast
16  * long name lookup.
17  */
18 struct dsos {
19 	struct list_head    head;
20 	struct rb_root	    root;	/* rbtree root sorted by long name */
21 	struct rw_semaphore lock;
22 };
23 
24 void __dsos__add(struct dsos *dsos, struct dso *dso);
25 void dsos__add(struct dsos *dsos, struct dso *dso);
26 struct dso *__dsos__addnew(struct dsos *dsos, const char *name);
27 struct dso *__dsos__find(struct dsos *dsos, const char *name, bool cmp_short);
28 
29 struct dso *dsos__findnew_id(struct dsos *dsos, const char *name, struct dso_id *id);
30 
31 struct dso *__dsos__findnew_link_by_longname_id(struct rb_root *root, struct dso *dso,
32 						const char *name, struct dso_id *id);
33 
34 bool __dsos__read_build_ids(struct list_head *head, bool with_hits);
35 
36 size_t __dsos__fprintf_buildid(struct list_head *head, FILE *fp,
37 			       bool (skip)(struct dso *dso, int parm), int parm);
38 size_t __dsos__fprintf(struct list_head *head, FILE *fp);
39 
40 #endif /* __PERF_DSOS */
41