aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/target.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/target.h')
-rw-r--r--tools/perf/util/target.h45
1 files changed, 22 insertions, 23 deletions
diff --git a/tools/perf/util/target.h b/tools/perf/util/target.h
index a4be8575fda5..2d0c50690892 100644
--- a/tools/perf/util/target.h
+++ b/tools/perf/util/target.h
@@ -4,7 +4,7 @@
4#include <stdbool.h> 4#include <stdbool.h>
5#include <sys/types.h> 5#include <sys/types.h>
6 6
7struct perf_target { 7struct target {
8 const char *pid; 8 const char *pid;
9 const char *tid; 9 const char *tid;
10 const char *cpu_list; 10 const char *cpu_list;
@@ -12,10 +12,11 @@ struct perf_target {
12 uid_t uid; 12 uid_t uid;
13 bool system_wide; 13 bool system_wide;
14 bool uses_mmap; 14 bool uses_mmap;
15 bool force_per_cpu;
15}; 16};
16 17
17enum perf_target_errno { 18enum target_errno {
18 PERF_ERRNO_TARGET__SUCCESS = 0, 19 TARGET_ERRNO__SUCCESS = 0,
19 20
20 /* 21 /*
21 * Choose an arbitrary negative big number not to clash with standard 22 * Choose an arbitrary negative big number not to clash with standard
@@ -24,42 +25,40 @@ enum perf_target_errno {
24 * 25 *
25 * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html 26 * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html
26 */ 27 */
27 __PERF_ERRNO_TARGET__START = -10000, 28 __TARGET_ERRNO__START = -10000,
28 29
30 /* for target__validate() */
31 TARGET_ERRNO__PID_OVERRIDE_CPU = __TARGET_ERRNO__START,
32 TARGET_ERRNO__PID_OVERRIDE_UID,
33 TARGET_ERRNO__UID_OVERRIDE_CPU,
34 TARGET_ERRNO__PID_OVERRIDE_SYSTEM,
35 TARGET_ERRNO__UID_OVERRIDE_SYSTEM,
29 36
30 /* for perf_target__validate() */ 37 /* for target__parse_uid() */
31 PERF_ERRNO_TARGET__PID_OVERRIDE_CPU = __PERF_ERRNO_TARGET__START, 38 TARGET_ERRNO__INVALID_UID,
32 PERF_ERRNO_TARGET__PID_OVERRIDE_UID, 39 TARGET_ERRNO__USER_NOT_FOUND,
33 PERF_ERRNO_TARGET__UID_OVERRIDE_CPU,
34 PERF_ERRNO_TARGET__PID_OVERRIDE_SYSTEM,
35 PERF_ERRNO_TARGET__UID_OVERRIDE_SYSTEM,
36 40
37 /* for perf_target__parse_uid() */ 41 __TARGET_ERRNO__END,
38 PERF_ERRNO_TARGET__INVALID_UID,
39 PERF_ERRNO_TARGET__USER_NOT_FOUND,
40
41 __PERF_ERRNO_TARGET__END,
42}; 42};
43 43
44enum perf_target_errno perf_target__validate(struct perf_target *target); 44enum target_errno target__validate(struct target *target);
45enum perf_target_errno perf_target__parse_uid(struct perf_target *target); 45enum target_errno target__parse_uid(struct target *target);
46 46
47int perf_target__strerror(struct perf_target *target, int errnum, char *buf, 47int target__strerror(struct target *target, int errnum, char *buf, size_t buflen);
48 size_t buflen);
49 48
50static inline bool perf_target__has_task(struct perf_target *target) 49static inline bool target__has_task(struct target *target)
51{ 50{
52 return target->tid || target->pid || target->uid_str; 51 return target->tid || target->pid || target->uid_str;
53} 52}
54 53
55static inline bool perf_target__has_cpu(struct perf_target *target) 54static inline bool target__has_cpu(struct target *target)
56{ 55{
57 return target->system_wide || target->cpu_list; 56 return target->system_wide || target->cpu_list;
58} 57}
59 58
60static inline bool perf_target__none(struct perf_target *target) 59static inline bool target__none(struct target *target)
61{ 60{
62 return !perf_target__has_task(target) && !perf_target__has_cpu(target); 61 return !target__has_task(target) && !target__has_cpu(target);
63} 62}
64 63
65#endif /* _PERF_TARGET_H */ 64#endif /* _PERF_TARGET_H */