From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Cc: Caleb Callaway <caleb.callaway@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 2/3] intel_gpu_top: Rename STDOUT to TEXT Date: Fri, 3 Feb 2023 11:16:35 +0000 [thread overview] Message-ID: <20230203111636.4138202-3-tvrtko.ursulin@linux.intel.com> (raw) In-Reply-To: <20230203111636.4138202-1-tvrtko.ursulin@linux.intel.com> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Internal cleanup only - the name text is more accurate given the output can also go to a file. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Caleb Callaway <caleb.callaway@intel.com> --- tools/intel_gpu_top.c | 54 +++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index e2a7f4753099..a980cc7043dc 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -1282,7 +1282,7 @@ usage(const char *appname) static enum { INTERACTIVE, - STDOUT, + TEXT, JSON } output_mode; @@ -1387,33 +1387,31 @@ json_add_member(const struct cnt_group *parent, struct cnt_item *item, return 1; } -static unsigned int stdout_level; +static unsigned int text_level; -#define STDOUT_HEADER_REPEAT 20 -static unsigned int stdout_lines = STDOUT_HEADER_REPEAT; -static bool stdout_header_repeat; +#define TEXT_HEADER_REPEAT 20 +static unsigned int text_lines = TEXT_HEADER_REPEAT; +static bool text_header_repeat; -static void -stdout_open_struct(const char *name) +static void text_open_struct(const char *name) { - stdout_level++; - assert(stdout_level > 0); + text_level++; + assert(text_level > 0); } -static void -stdout_close_struct(void) +static void text_close_struct(void) { - assert(stdout_level > 0); - if (--stdout_level == 0) { - stdout_lines++; + assert(text_level > 0); + if (--text_level == 0) { + text_lines++; fputs("\n", out); fflush(out); } } static unsigned int -stdout_add_member(const struct cnt_group *parent, struct cnt_item *item, - unsigned int headers) +text_add_member(const struct cnt_group *parent, struct cnt_item *item, + unsigned int headers) { unsigned int fmt_tot = item->fmt_width + (item->fmt_precision ? 1 : 0); char buf[fmt_tot + 1]; @@ -1565,10 +1563,10 @@ static const struct print_operations json_pops = { .print_group = print_group, }; -static const struct print_operations stdout_pops = { - .open_struct = stdout_open_struct, - .close_struct = stdout_close_struct, - .add_member = stdout_add_member, +static const struct print_operations text_pops = { + .open_struct = text_open_struct, + .close_struct = text_close_struct, + .add_member = text_add_member, .print_group = print_group, }; @@ -1584,9 +1582,9 @@ static bool print_groups(struct cnt_group **groups) static bool headers_printed = false; bool print_data = true; - if (output_mode == STDOUT && - (stdout_header_repeat || !headers_printed)) { - unsigned int headers = stdout_lines % STDOUT_HEADER_REPEAT + 1; + if (output_mode == TEXT && + (text_header_repeat || !headers_printed)) { + unsigned int headers = text_lines % TEXT_HEADER_REPEAT + 1; if (headers == 1 || headers == 2) for (struct cnt_group **grp = groups; *grp; grp++) @@ -2492,7 +2490,7 @@ int main(int argc, char **argv) list_device = true; break; case 'l': - output_mode = STDOUT; + output_mode = TEXT; break; case 'h': usage(argv[0]); @@ -2505,7 +2503,7 @@ int main(int argc, char **argv) } if (output_mode == INTERACTIVE && (output_path || isatty(1) != 1)) - output_mode = STDOUT; + output_mode = TEXT; if (output_path && strcmp(output_path, "-")) { out = fopen(output_path, "w"); @@ -2519,7 +2517,7 @@ int main(int argc, char **argv) out = stdout; } - stdout_header_repeat = output_mode == STDOUT && isatty(fileno(out)); + text_header_repeat = output_mode == TEXT && isatty(fileno(out)); if (signal(SIGINT, sigint_handler) == SIG_ERR) fprintf(stderr, "Failed to install signal handler!\n"); @@ -2531,8 +2529,8 @@ int main(int argc, char **argv) pops = &term_pops; interactive_stdin(); break; - case STDOUT: - pops = &stdout_pops; + case TEXT: + pops = &text_pops; break; case JSON: pops = &json_pops; -- 2.34.1
WARNING: multiple messages have this Message-ID (diff)
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> To: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Cc: Caleb Callaway <caleb.callaway@intel.com>, Tvrtko Ursulin <tvrtko.ursulin@intel.com> Subject: [igt-dev] [PATCH i-g-t 2/3] intel_gpu_top: Rename STDOUT to TEXT Date: Fri, 3 Feb 2023 11:16:35 +0000 [thread overview] Message-ID: <20230203111636.4138202-3-tvrtko.ursulin@linux.intel.com> (raw) In-Reply-To: <20230203111636.4138202-1-tvrtko.ursulin@linux.intel.com> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Internal cleanup only - the name text is more accurate given the output can also go to a file. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Caleb Callaway <caleb.callaway@intel.com> --- tools/intel_gpu_top.c | 54 +++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index e2a7f4753099..a980cc7043dc 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -1282,7 +1282,7 @@ usage(const char *appname) static enum { INTERACTIVE, - STDOUT, + TEXT, JSON } output_mode; @@ -1387,33 +1387,31 @@ json_add_member(const struct cnt_group *parent, struct cnt_item *item, return 1; } -static unsigned int stdout_level; +static unsigned int text_level; -#define STDOUT_HEADER_REPEAT 20 -static unsigned int stdout_lines = STDOUT_HEADER_REPEAT; -static bool stdout_header_repeat; +#define TEXT_HEADER_REPEAT 20 +static unsigned int text_lines = TEXT_HEADER_REPEAT; +static bool text_header_repeat; -static void -stdout_open_struct(const char *name) +static void text_open_struct(const char *name) { - stdout_level++; - assert(stdout_level > 0); + text_level++; + assert(text_level > 0); } -static void -stdout_close_struct(void) +static void text_close_struct(void) { - assert(stdout_level > 0); - if (--stdout_level == 0) { - stdout_lines++; + assert(text_level > 0); + if (--text_level == 0) { + text_lines++; fputs("\n", out); fflush(out); } } static unsigned int -stdout_add_member(const struct cnt_group *parent, struct cnt_item *item, - unsigned int headers) +text_add_member(const struct cnt_group *parent, struct cnt_item *item, + unsigned int headers) { unsigned int fmt_tot = item->fmt_width + (item->fmt_precision ? 1 : 0); char buf[fmt_tot + 1]; @@ -1565,10 +1563,10 @@ static const struct print_operations json_pops = { .print_group = print_group, }; -static const struct print_operations stdout_pops = { - .open_struct = stdout_open_struct, - .close_struct = stdout_close_struct, - .add_member = stdout_add_member, +static const struct print_operations text_pops = { + .open_struct = text_open_struct, + .close_struct = text_close_struct, + .add_member = text_add_member, .print_group = print_group, }; @@ -1584,9 +1582,9 @@ static bool print_groups(struct cnt_group **groups) static bool headers_printed = false; bool print_data = true; - if (output_mode == STDOUT && - (stdout_header_repeat || !headers_printed)) { - unsigned int headers = stdout_lines % STDOUT_HEADER_REPEAT + 1; + if (output_mode == TEXT && + (text_header_repeat || !headers_printed)) { + unsigned int headers = text_lines % TEXT_HEADER_REPEAT + 1; if (headers == 1 || headers == 2) for (struct cnt_group **grp = groups; *grp; grp++) @@ -2492,7 +2490,7 @@ int main(int argc, char **argv) list_device = true; break; case 'l': - output_mode = STDOUT; + output_mode = TEXT; break; case 'h': usage(argv[0]); @@ -2505,7 +2503,7 @@ int main(int argc, char **argv) } if (output_mode == INTERACTIVE && (output_path || isatty(1) != 1)) - output_mode = STDOUT; + output_mode = TEXT; if (output_path && strcmp(output_path, "-")) { out = fopen(output_path, "w"); @@ -2519,7 +2517,7 @@ int main(int argc, char **argv) out = stdout; } - stdout_header_repeat = output_mode == STDOUT && isatty(fileno(out)); + text_header_repeat = output_mode == TEXT && isatty(fileno(out)); if (signal(SIGINT, sigint_handler) == SIG_ERR) fprintf(stderr, "Failed to install signal handler!\n"); @@ -2531,8 +2529,8 @@ int main(int argc, char **argv) pops = &term_pops; interactive_stdin(); break; - case STDOUT: - pops = &stdout_pops; + case TEXT: + pops = &text_pops; break; case JSON: pops = &json_pops; -- 2.34.1
next prev parent reply other threads:[~2023-02-03 11:16 UTC|newest] Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-03 11:16 [Intel-gfx] [PATCH i-g-t 0/3] More intel_gpu_top improvements Tvrtko Ursulin 2023-02-03 11:16 ` [igt-dev] " Tvrtko Ursulin 2023-02-03 11:16 ` [Intel-gfx] [PATCH i-g-t 1/3] intel_gpu_top: Do not repeat header lines in non-interactive output Tvrtko Ursulin 2023-02-03 11:16 ` [igt-dev] " Tvrtko Ursulin 2023-02-07 13:25 ` [Intel-gfx] " Kamil Konieczny 2023-02-07 13:25 ` [igt-dev] " Kamil Konieczny 2023-02-08 12:31 ` Kamil Konieczny 2023-02-08 12:31 ` [igt-dev] " Kamil Konieczny 2023-02-09 8:24 ` Tvrtko Ursulin 2023-02-09 8:24 ` [igt-dev] " Tvrtko Ursulin 2023-02-03 11:16 ` Tvrtko Ursulin [this message] 2023-02-03 11:16 ` [igt-dev] [PATCH i-g-t 2/3] intel_gpu_top: Rename STDOUT to TEXT Tvrtko Ursulin 2023-02-07 13:15 ` [Intel-gfx] " Kamil Konieczny 2023-02-07 13:15 ` Kamil Konieczny 2023-02-03 11:16 ` [Intel-gfx] [PATCH i-g-t 3/3] intel_gpu_top: Add CVS output format Tvrtko Ursulin 2023-02-03 11:16 ` [igt-dev] " Tvrtko Ursulin 2023-02-03 11:22 ` [Intel-gfx] " Ville Syrjälä 2023-02-03 11:22 ` Ville Syrjälä 2023-02-03 11:27 ` [Intel-gfx] " Tvrtko Ursulin 2023-02-03 11:27 ` Tvrtko Ursulin 2023-02-03 11:30 ` [Intel-gfx] [PATCH i-g-t 3/3] intel_gpu_top: Add CSV " Tvrtko Ursulin 2023-02-03 11:30 ` [igt-dev] " Tvrtko Ursulin 2023-02-03 11:31 ` [Intel-gfx] " Tvrtko Ursulin 2023-02-03 11:31 ` [igt-dev] " Tvrtko Ursulin 2023-02-07 13:29 ` [Intel-gfx] " Kamil Konieczny 2023-02-07 13:29 ` [igt-dev] " Kamil Konieczny 2023-02-03 14:49 ` [igt-dev] ✓ Fi.CI.BAT: success for More intel_gpu_top improvements (rev3) Patchwork 2023-02-04 17:27 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230203111636.4138202-3-tvrtko.ursulin@linux.intel.com \ --to=tvrtko.ursulin@linux.intel.com \ --cc=Intel-gfx@lists.freedesktop.org \ --cc=caleb.callaway@intel.com \ --cc=igt-dev@lists.freedesktop.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.