Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / perf / util / mem-info.h
blobdf75e94ed3d02e779c4ca9f7bffd55fa2e82e417
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __PERF_MEM_INFO_H
3 #define __PERF_MEM_INFO_H
5 #include <linux/refcount.h>
6 #include <linux/perf_event.h>
7 #include <internal/rc_check.h>
8 #include "map_symbol.h"
10 DECLARE_RC_STRUCT(mem_info) {
11 struct addr_map_symbol iaddr;
12 struct addr_map_symbol daddr;
13 union perf_mem_data_src data_src;
14 refcount_t refcnt;
17 struct mem_info *mem_info__new(void);
18 struct mem_info *mem_info__clone(struct mem_info *mi);
19 struct mem_info *mem_info__get(struct mem_info *mi);
20 void mem_info__put(struct mem_info *mi);
22 static inline void __mem_info__zput(struct mem_info **mi)
24 mem_info__put(*mi);
25 *mi = NULL;
28 #define mem_info__zput(mi) __mem_info__zput(&mi)
30 static inline struct addr_map_symbol *mem_info__iaddr(struct mem_info *mi)
32 return &RC_CHK_ACCESS(mi)->iaddr;
35 static inline struct addr_map_symbol *mem_info__daddr(struct mem_info *mi)
37 return &RC_CHK_ACCESS(mi)->daddr;
40 static inline union perf_mem_data_src *mem_info__data_src(struct mem_info *mi)
42 return &RC_CHK_ACCESS(mi)->data_src;
45 static inline const union perf_mem_data_src *mem_info__const_data_src(const struct mem_info *mi)
47 return &RC_CHK_ACCESS(mi)->data_src;
50 static inline refcount_t *mem_info__refcnt(struct mem_info *mi)
52 return &RC_CHK_ACCESS(mi)->refcnt;
55 #endif /* __PERF_MEM_INFO_H */