Skip to content

Commit 688f2f5

Browse files
Namhyung Kimacmel
authored andcommitted
perf ui: Introduce generic ui_progress helper
Make ui_progress functions generic so that UI frontend code will add its callbacks. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Pekka Enberg <penberg@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1352813436-14173-2-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 7da5c85 commit 688f2f5

6 files changed

Lines changed: 41 additions & 12 deletions

File tree

‎tools/perf/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ LIB_OBJS += $(OUTPUT)util/vdso.o
423423
LIB_OBJS += $(OUTPUT)util/stat.o
424424

425425
LIB_OBJS += $(OUTPUT)ui/helpline.o
426+
LIB_OBJS += $(OUTPUT)ui/progress.o
426427
LIB_OBJS += $(OUTPUT)ui/hist.o
427428
LIB_OBJS += $(OUTPUT)ui/stdio/hist.o
428429

‎tools/perf/ui/gtk/util.c‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,3 @@ struct perf_error_ops perf_gtk_eops = {
111111
.warning = perf_gtk__warning_statusbar,
112112
#endif
113113
};
114-
115-
/*
116-
* FIXME: Functions below should be implemented properly.
117-
* For now, just add stubs for NO_NEWT=1 build.
118-
*/
119-
#ifndef NEWT_SUPPORT
120-
void ui_progress__update(u64 curr __maybe_unused, u64 total __maybe_unused,
121-
const char *title __maybe_unused)
122-
{
123-
}
124-
#endif

‎tools/perf/ui/progress.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "../cache.h"
2+
#include "progress.h"
3+
4+
static void nop_progress_update(u64 curr __maybe_unused,
5+
u64 total __maybe_unused,
6+
const char *title __maybe_unused)
7+
{
8+
}
9+
10+
static struct ui_progress default_progress_fns =
11+
{
12+
.update = nop_progress_update,
13+
};
14+
15+
struct ui_progress *progress_fns = &default_progress_fns;
16+
17+
void ui_progress__update(u64 curr, u64 total, const char *title)
18+
{
19+
return progress_fns->update(curr, total, title);
20+
}

‎tools/perf/ui/progress.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33

44
#include <../types.h>
55

6+
struct ui_progress {
7+
void (*update)(u64, u64, const char *);
8+
};
9+
10+
extern struct ui_progress *progress_fns;
11+
12+
void ui_progress__init(void);
13+
614
void ui_progress__update(u64 curr, u64 total, const char *title);
715

816
#endif

‎tools/perf/ui/tui/progress.c‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "../ui.h"
55
#include "../browser.h"
66

7-
void ui_progress__update(u64 curr, u64 total, const char *title)
7+
static void tui_progress__update(u64 curr, u64 total, const char *title)
88
{
99
int bar, y;
1010
/*
@@ -30,3 +30,13 @@ void ui_progress__update(u64 curr, u64 total, const char *title)
3030
SLsmg_refresh();
3131
pthread_mutex_unlock(&ui__lock);
3232
}
33+
34+
static struct ui_progress tui_progress_fns =
35+
{
36+
.update = tui_progress__update,
37+
};
38+
39+
void ui_progress__init(void)
40+
{
41+
progress_fns = &tui_progress_fns;
42+
}

‎tools/perf/ui/tui/setup.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ int ui__init(void)
118118
newtSetSuspendCallback(newt_suspend, NULL);
119119
ui_helpline__init();
120120
ui_browser__init();
121+
ui_progress__init();
121122

122123
signal(SIGSEGV, ui__signal);
123124
signal(SIGFPE, ui__signal);

0 commit comments

Comments
 (0)