perf tools: Add reference counting for thread_map object
[deliverable/linux.git] / tools / perf / util / thread_map.h
CommitLineData
fd78260b
ACM
1#ifndef __PERF_THREAD_MAP_H
2#define __PERF_THREAD_MAP_H
3
4#include <sys/types.h>
9ae7d335 5#include <stdio.h>
186fbb74 6#include <linux/atomic.h>
fd78260b 7
38e89d2b
JO
8struct thread_map_data {
9 pid_t pid;
10};
11
fd78260b 12struct thread_map {
186fbb74 13 atomic_t refcnt;
fd78260b 14 int nr;
38e89d2b 15 struct thread_map_data map[];
fd78260b
ACM
16};
17
641556c9 18struct thread_map *thread_map__new_dummy(void);
fd78260b
ACM
19struct thread_map *thread_map__new_by_pid(pid_t pid);
20struct thread_map *thread_map__new_by_tid(pid_t tid);
0d37aa34
ACM
21struct thread_map *thread_map__new_by_uid(uid_t uid);
22struct thread_map *thread_map__new(pid_t pid, pid_t tid, uid_t uid);
b52956c9 23
186fbb74
JO
24struct thread_map *thread_map__get(struct thread_map *map);
25void thread_map__put(struct thread_map *map);
26
b52956c9
DA
27struct thread_map *thread_map__new_str(const char *pid,
28 const char *tid, uid_t uid);
29
9ae7d335
ACM
30size_t thread_map__fprintf(struct thread_map *threads, FILE *fp);
31
b3a319d5
NK
32static inline int thread_map__nr(struct thread_map *threads)
33{
34 return threads ? threads->nr : 1;
35}
36
e13798c7
JO
37static inline pid_t thread_map__pid(struct thread_map *map, int thread)
38{
38e89d2b 39 return map->map[thread].pid;
e13798c7
JO
40}
41
42static inline void
43thread_map__set_pid(struct thread_map *map, int thread, pid_t pid)
44{
38e89d2b 45 map->map[thread].pid = pid;
e13798c7 46}
fd78260b 47#endif /* __PERF_THREAD_MAP_H */
This page took 0.32346 seconds and 5 git commands to generate.