diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-05-06 09:02:32 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-05-06 12:00:58 -0400 |
commit | 8f48df69b4add63527cae646f2e40cf83c6ec0a0 (patch) | |
tree | f3233dcb03aff22e7b63a70dfe6219924fe485ed /tools | |
parent | 12199d8e20bb4a2ad164d2600bf199557d55c35c (diff) |
perf trace: Move open_flags beautifier to tools/perf/trace/beauty/
To reduce the size of builtin-trace.c.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-jt293541hv9od7gqw6lilioh@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-trace.c | 57 | ||||
-rw-r--r-- | tools/perf/trace/beauty/open_flags.c | 56 |
2 files changed, 57 insertions, 56 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index e7f2697e7ca6..a4e294e24f6a 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -542,62 +542,6 @@ static size_t syscall_arg__scnprintf_filename(char *bf, size_t size, | |||
542 | 542 | ||
543 | #define SCA_FILENAME syscall_arg__scnprintf_filename | 543 | #define SCA_FILENAME syscall_arg__scnprintf_filename |
544 | 544 | ||
545 | static size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size, | ||
546 | struct syscall_arg *arg) | ||
547 | { | ||
548 | int printed = 0, flags = arg->val; | ||
549 | |||
550 | if (!(flags & O_CREAT)) | ||
551 | arg->mask |= 1 << (arg->idx + 1); /* Mask the mode parm */ | ||
552 | |||
553 | if (flags == 0) | ||
554 | return scnprintf(bf, size, "RDONLY"); | ||
555 | #define P_FLAG(n) \ | ||
556 | if (flags & O_##n) { \ | ||
557 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ | ||
558 | flags &= ~O_##n; \ | ||
559 | } | ||
560 | |||
561 | P_FLAG(APPEND); | ||
562 | P_FLAG(ASYNC); | ||
563 | P_FLAG(CLOEXEC); | ||
564 | P_FLAG(CREAT); | ||
565 | P_FLAG(DIRECT); | ||
566 | P_FLAG(DIRECTORY); | ||
567 | P_FLAG(EXCL); | ||
568 | P_FLAG(LARGEFILE); | ||
569 | P_FLAG(NOATIME); | ||
570 | P_FLAG(NOCTTY); | ||
571 | #ifdef O_NONBLOCK | ||
572 | P_FLAG(NONBLOCK); | ||
573 | #elif O_NDELAY | ||
574 | P_FLAG(NDELAY); | ||
575 | #endif | ||
576 | #ifdef O_PATH | ||
577 | P_FLAG(PATH); | ||
578 | #endif | ||
579 | P_FLAG(RDWR); | ||
580 | #ifdef O_DSYNC | ||
581 | if ((flags & O_SYNC) == O_SYNC) | ||
582 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", "SYNC"); | ||
583 | else { | ||
584 | P_FLAG(DSYNC); | ||
585 | } | ||
586 | #else | ||
587 | P_FLAG(SYNC); | ||
588 | #endif | ||
589 | P_FLAG(TRUNC); | ||
590 | P_FLAG(WRONLY); | ||
591 | #undef P_FLAG | ||
592 | |||
593 | if (flags) | ||
594 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); | ||
595 | |||
596 | return printed; | ||
597 | } | ||
598 | |||
599 | #define SCA_OPEN_FLAGS syscall_arg__scnprintf_open_flags | ||
600 | |||
601 | static size_t syscall_arg__scnprintf_pipe_flags(char *bf, size_t size, | 545 | static size_t syscall_arg__scnprintf_pipe_flags(char *bf, size_t size, |
602 | struct syscall_arg *arg) | 546 | struct syscall_arg *arg) |
603 | { | 547 | { |
@@ -738,6 +682,7 @@ static size_t syscall_arg__scnprintf_getrandom_flags(char *bf, size_t size, | |||
738 | #include "trace/beauty/mmap.c" | 682 | #include "trace/beauty/mmap.c" |
739 | #include "trace/beauty/mode_t.c" | 683 | #include "trace/beauty/mode_t.c" |
740 | #include "trace/beauty/msg_flags.c" | 684 | #include "trace/beauty/msg_flags.c" |
685 | #include "trace/beauty/open_flags.c" | ||
741 | #include "trace/beauty/perf_event_open.c" | 686 | #include "trace/beauty/perf_event_open.c" |
742 | #include "trace/beauty/sched_policy.c" | 687 | #include "trace/beauty/sched_policy.c" |
743 | #include "trace/beauty/signum.c" | 688 | #include "trace/beauty/signum.c" |
diff --git a/tools/perf/trace/beauty/open_flags.c b/tools/perf/trace/beauty/open_flags.c new file mode 100644 index 000000000000..0f3679e0cdcf --- /dev/null +++ b/tools/perf/trace/beauty/open_flags.c | |||
@@ -0,0 +1,56 @@ | |||
1 | |||
2 | static size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size, | ||
3 | struct syscall_arg *arg) | ||
4 | { | ||
5 | int printed = 0, flags = arg->val; | ||
6 | |||
7 | if (!(flags & O_CREAT)) | ||
8 | arg->mask |= 1 << (arg->idx + 1); /* Mask the mode parm */ | ||
9 | |||
10 | if (flags == 0) | ||
11 | return scnprintf(bf, size, "RDONLY"); | ||
12 | #define P_FLAG(n) \ | ||
13 | if (flags & O_##n) { \ | ||
14 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ | ||
15 | flags &= ~O_##n; \ | ||
16 | } | ||
17 | |||
18 | P_FLAG(APPEND); | ||
19 | P_FLAG(ASYNC); | ||
20 | P_FLAG(CLOEXEC); | ||
21 | P_FLAG(CREAT); | ||
22 | P_FLAG(DIRECT); | ||
23 | P_FLAG(DIRECTORY); | ||
24 | P_FLAG(EXCL); | ||
25 | P_FLAG(LARGEFILE); | ||
26 | P_FLAG(NOATIME); | ||
27 | P_FLAG(NOCTTY); | ||
28 | #ifdef O_NONBLOCK | ||
29 | P_FLAG(NONBLOCK); | ||
30 | #elif O_NDELAY | ||
31 | P_FLAG(NDELAY); | ||
32 | #endif | ||
33 | #ifdef O_PATH | ||
34 | P_FLAG(PATH); | ||
35 | #endif | ||
36 | P_FLAG(RDWR); | ||
37 | #ifdef O_DSYNC | ||
38 | if ((flags & O_SYNC) == O_SYNC) | ||
39 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", "SYNC"); | ||
40 | else { | ||
41 | P_FLAG(DSYNC); | ||
42 | } | ||
43 | #else | ||
44 | P_FLAG(SYNC); | ||
45 | #endif | ||
46 | P_FLAG(TRUNC); | ||
47 | P_FLAG(WRONLY); | ||
48 | #undef P_FLAG | ||
49 | |||
50 | if (flags) | ||
51 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); | ||
52 | |||
53 | return printed; | ||
54 | } | ||
55 | |||
56 | #define SCA_OPEN_FLAGS syscall_arg__scnprintf_open_flags | ||