Arnaldo Carvalho de Melo | fd78260 | 2011-01-18 15:15:24 -0200 | [diff] [blame] | 1 | #ifndef __PERF_THREAD_MAP_H |
| 2 | #define __PERF_THREAD_MAP_H |
| 3 | |
| 4 | #include <sys/types.h> |
Arnaldo Carvalho de Melo | 9ae7d33 | 2012-01-19 14:07:23 -0200 | [diff] [blame] | 5 | #include <stdio.h> |
Arnaldo Carvalho de Melo | fd78260 | 2011-01-18 15:15:24 -0200 | [diff] [blame] | 6 | |
Jiri Olsa | 38e89d2 | 2015-06-23 00:36:02 +0200 | [diff] [blame^] | 7 | struct thread_map_data { |
| 8 | pid_t pid; |
| 9 | }; |
| 10 | |
Arnaldo Carvalho de Melo | fd78260 | 2011-01-18 15:15:24 -0200 | [diff] [blame] | 11 | struct thread_map { |
| 12 | int nr; |
Jiri Olsa | 38e89d2 | 2015-06-23 00:36:02 +0200 | [diff] [blame^] | 13 | struct thread_map_data map[]; |
Arnaldo Carvalho de Melo | fd78260 | 2011-01-18 15:15:24 -0200 | [diff] [blame] | 14 | }; |
| 15 | |
Arnaldo Carvalho de Melo | 641556c | 2014-10-10 12:03:46 -0300 | [diff] [blame] | 16 | struct thread_map *thread_map__new_dummy(void); |
Arnaldo Carvalho de Melo | fd78260 | 2011-01-18 15:15:24 -0200 | [diff] [blame] | 17 | struct thread_map *thread_map__new_by_pid(pid_t pid); |
| 18 | struct thread_map *thread_map__new_by_tid(pid_t tid); |
Arnaldo Carvalho de Melo | 0d37aa3 | 2012-01-19 14:08:15 -0200 | [diff] [blame] | 19 | struct thread_map *thread_map__new_by_uid(uid_t uid); |
| 20 | struct thread_map *thread_map__new(pid_t pid, pid_t tid, uid_t uid); |
David Ahern | b52956c | 2012-02-08 09:32:52 -0700 | [diff] [blame] | 21 | |
| 22 | struct thread_map *thread_map__new_str(const char *pid, |
| 23 | const char *tid, uid_t uid); |
| 24 | |
Arnaldo Carvalho de Melo | fd78260 | 2011-01-18 15:15:24 -0200 | [diff] [blame] | 25 | void thread_map__delete(struct thread_map *threads); |
Arnaldo Carvalho de Melo | 9ae7d33 | 2012-01-19 14:07:23 -0200 | [diff] [blame] | 26 | |
| 27 | size_t thread_map__fprintf(struct thread_map *threads, FILE *fp); |
| 28 | |
Namhyung Kim | b3a319d | 2013-03-11 16:43:14 +0900 | [diff] [blame] | 29 | static inline int thread_map__nr(struct thread_map *threads) |
| 30 | { |
| 31 | return threads ? threads->nr : 1; |
| 32 | } |
| 33 | |
Jiri Olsa | e13798c | 2015-06-23 00:36:02 +0200 | [diff] [blame] | 34 | static inline pid_t thread_map__pid(struct thread_map *map, int thread) |
| 35 | { |
Jiri Olsa | 38e89d2 | 2015-06-23 00:36:02 +0200 | [diff] [blame^] | 36 | return map->map[thread].pid; |
Jiri Olsa | e13798c | 2015-06-23 00:36:02 +0200 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | static inline void |
| 40 | thread_map__set_pid(struct thread_map *map, int thread, pid_t pid) |
| 41 | { |
Jiri Olsa | 38e89d2 | 2015-06-23 00:36:02 +0200 | [diff] [blame^] | 42 | map->map[thread].pid = pid; |
Jiri Olsa | e13798c | 2015-06-23 00:36:02 +0200 | [diff] [blame] | 43 | } |
Arnaldo Carvalho de Melo | fd78260 | 2011-01-18 15:15:24 -0200 | [diff] [blame] | 44 | #endif /* __PERF_THREAD_MAP_H */ |