2012-05-11 06:34:10

by Namhyung Kim

[permalink] [raw]
Subject: [tip:perf/core] perf ui: Make setup_browser() generic

Commit-ID: ca09b2e1b307724666577859eb460ac6d4c67330
Gitweb: http://git.kernel.org/tip/ca09b2e1b307724666577859eb460ac6d4c67330
Author: Namhyung Kim <[email protected]>
AuthorDate: Mon, 30 Apr 2012 13:55:05 +0900
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 2 May 2012 16:17:20 -0300

perf ui: Make setup_browser() generic

The setup_browser contained newt-related codes in it.

As gtk front-end added recently, it should be more generic to handle
both cases properly.

So move newt codes to the ui__init() for now.

Signed-off-by: Namhyung Kim <[email protected]>
Acked-by: Pekka Enberg <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/setup.c | 44 +++++++++++++++++++++++++-------------------
1 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c
index 85a69fa..becdcd0 100644
--- a/tools/perf/ui/setup.c
+++ b/tools/perf/ui/setup.c
@@ -93,14 +93,37 @@ static void newt_suspend(void *d __used)
newtResume();
}

+static void ui__exit(void);
+
+static void ui__signal(int sig)
+{
+ ui__exit();
+ psignal(sig, "perf");
+ exit(0);
+}
+
static int ui__init(void)
{
- int err = SLkp_init();
+ int err;

- if (err < 0)
+ newtInit();
+ err = SLkp_init();
+ if (err < 0) {
+ pr_err("TUI initialization failed.\n");
goto out;
+ }

SLkp_define_keysym((char *)"^(kB)", SL_KEY_UNTAB);
+
+ newtSetSuspendCallback(newt_suspend, NULL);
+ ui_helpline__init();
+ ui_browser__init();
+
+ signal(SIGSEGV, ui__signal);
+ signal(SIGFPE, ui__signal);
+ signal(SIGINT, ui__signal);
+ signal(SIGQUIT, ui__signal);
+ signal(SIGTERM, ui__signal);
out:
return err;
}
@@ -113,13 +136,6 @@ static void ui__exit(void)
SLang_reset_tty();
}

-static void ui__signal(int sig)
-{
- ui__exit();
- psignal(sig, "perf");
- exit(0);
-}
-
void setup_browser(bool fallback_to_pager)
{
if (!isatty(1) || !use_browser || dump_trace) {
@@ -130,17 +146,7 @@ void setup_browser(bool fallback_to_pager)
}

use_browser = 1;
- newtInit();
ui__init();
- newtSetSuspendCallback(newt_suspend, NULL);
- ui_helpline__init();
- ui_browser__init();
-
- signal(SIGSEGV, ui__signal);
- signal(SIGFPE, ui__signal);
- signal(SIGINT, ui__signal);
- signal(SIGQUIT, ui__signal);
- signal(SIGTERM, ui__signal);
}

void exit_browser(bool wait_for_ok)