Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[firefly-linux-kernel-4.4.55.git] / tools / perf / util / target.h
1 #ifndef _PERF_TARGET_H
2 #define _PERF_TARGET_H
3
4 #include <stdbool.h>
5 #include <sys/types.h>
6
7 struct target {
8         const char   *pid;
9         const char   *tid;
10         const char   *cpu_list;
11         const char   *uid_str;
12         uid_t        uid;
13         bool         system_wide;
14         bool         uses_mmap;
15 };
16
17 enum target_errno {
18         TARGET_ERRNO__SUCCESS           = 0,
19
20         /*
21          * Choose an arbitrary negative big number not to clash with standard
22          * errno since SUS requires the errno has distinct positive values.
23          * See 'Issue 6' in the link below.
24          *
25          * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html
26          */
27         __TARGET_ERRNO__START           = -10000,
28
29         /* for target__validate() */
30         TARGET_ERRNO__PID_OVERRIDE_CPU  = __TARGET_ERRNO__START,
31         TARGET_ERRNO__PID_OVERRIDE_UID,
32         TARGET_ERRNO__UID_OVERRIDE_CPU,
33         TARGET_ERRNO__PID_OVERRIDE_SYSTEM,
34         TARGET_ERRNO__UID_OVERRIDE_SYSTEM,
35
36         /* for target__parse_uid() */
37         TARGET_ERRNO__INVALID_UID,
38         TARGET_ERRNO__USER_NOT_FOUND,
39
40         __TARGET_ERRNO__END,
41 };
42
43 enum target_errno target__validate(struct target *target);
44 enum target_errno target__parse_uid(struct target *target);
45
46 int target__strerror(struct target *target, int errnum, char *buf, size_t buflen);
47
48 static inline bool target__has_task(struct target *target)
49 {
50         return target->tid || target->pid || target->uid_str;
51 }
52
53 static inline bool target__has_cpu(struct target *target)
54 {
55         return target->system_wide || target->cpu_list;
56 }
57
58 static inline bool target__none(struct target *target)
59 {
60         return !target__has_task(target) && !target__has_cpu(target);
61 }
62
63 #endif /* _PERF_TARGET_H */