diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/Makefile | 1 | ||||
-rw-r--r-- | tools/perf/util/ui/browser.c | 7 | ||||
-rw-r--r-- | tools/perf/util/ui/helpline.c | 5 | ||||
-rw-r--r-- | tools/perf/util/ui/setup.c | 3 | ||||
-rw-r--r-- | tools/perf/util/ui/ui.h | 8 |
5 files changed, 23 insertions, 1 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index bc4d9bf8a556..ffd1047cd93b 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -637,6 +637,7 @@ else | |||
637 | LIB_H += util/ui/libslang.h | 637 | LIB_H += util/ui/libslang.h |
638 | LIB_H += util/ui/progress.h | 638 | LIB_H += util/ui/progress.h |
639 | LIB_H += util/ui/util.h | 639 | LIB_H += util/ui/util.h |
640 | LIB_H += util/ui/ui.h | ||
640 | endif | 641 | endif |
641 | endif | 642 | endif |
642 | 643 | ||
diff --git a/tools/perf/util/ui/browser.c b/tools/perf/util/ui/browser.c index 8bc010edca25..60d6c815e1db 100644 --- a/tools/perf/util/ui/browser.c +++ b/tools/perf/util/ui/browser.c | |||
@@ -1,4 +1,5 @@ | |||
1 | #include "libslang.h" | 1 | #include "libslang.h" |
2 | #include "ui.h" | ||
2 | #include <linux/compiler.h> | 3 | #include <linux/compiler.h> |
3 | #include <linux/list.h> | 4 | #include <linux/list.h> |
4 | #include <linux/rbtree.h> | 5 | #include <linux/rbtree.h> |
@@ -178,6 +179,7 @@ int ui_browser__show(struct ui_browser *self, const char *title, | |||
178 | if (self->sb == NULL) | 179 | if (self->sb == NULL) |
179 | return -1; | 180 | return -1; |
180 | 181 | ||
182 | pthread_mutex_lock(&ui__lock); | ||
181 | SLsmg_gotorc(0, 0); | 183 | SLsmg_gotorc(0, 0); |
182 | ui_browser__set_color(self, NEWT_COLORSET_ROOT); | 184 | ui_browser__set_color(self, NEWT_COLORSET_ROOT); |
183 | slsmg_write_nstring(title, self->width); | 185 | slsmg_write_nstring(title, self->width); |
@@ -188,25 +190,30 @@ int ui_browser__show(struct ui_browser *self, const char *title, | |||
188 | va_start(ap, helpline); | 190 | va_start(ap, helpline); |
189 | ui_helpline__vpush(helpline, ap); | 191 | ui_helpline__vpush(helpline, ap); |
190 | va_end(ap); | 192 | va_end(ap); |
193 | pthread_mutex_unlock(&ui__lock); | ||
191 | return 0; | 194 | return 0; |
192 | } | 195 | } |
193 | 196 | ||
194 | void ui_browser__hide(struct ui_browser *self) | 197 | void ui_browser__hide(struct ui_browser *self) |
195 | { | 198 | { |
199 | pthread_mutex_lock(&ui__lock); | ||
196 | newtFormDestroy(self->form); | 200 | newtFormDestroy(self->form); |
197 | self->form = NULL; | 201 | self->form = NULL; |
198 | ui_helpline__pop(); | 202 | ui_helpline__pop(); |
203 | pthread_mutex_unlock(&ui__lock); | ||
199 | } | 204 | } |
200 | 205 | ||
201 | int ui_browser__refresh(struct ui_browser *self) | 206 | int ui_browser__refresh(struct ui_browser *self) |
202 | { | 207 | { |
203 | int row; | 208 | int row; |
204 | 209 | ||
210 | pthread_mutex_lock(&ui__lock); | ||
205 | newtScrollbarSet(self->sb, self->index, self->nr_entries - 1); | 211 | newtScrollbarSet(self->sb, self->index, self->nr_entries - 1); |
206 | row = self->refresh(self); | 212 | row = self->refresh(self); |
207 | ui_browser__set_color(self, HE_COLORSET_NORMAL); | 213 | ui_browser__set_color(self, HE_COLORSET_NORMAL); |
208 | SLsmg_fill_region(self->y + row, self->x, | 214 | SLsmg_fill_region(self->y + row, self->x, |
209 | self->height - row, self->width, ' '); | 215 | self->height - row, self->width, ' '); |
216 | pthread_mutex_unlock(&ui__lock); | ||
210 | 217 | ||
211 | return 0; | 218 | return 0; |
212 | } | 219 | } |
diff --git a/tools/perf/util/ui/helpline.c b/tools/perf/util/ui/helpline.c index 8d79daa4458a..f36d2ff509ed 100644 --- a/tools/perf/util/ui/helpline.c +++ b/tools/perf/util/ui/helpline.c | |||
@@ -5,6 +5,7 @@ | |||
5 | 5 | ||
6 | #include "../debug.h" | 6 | #include "../debug.h" |
7 | #include "helpline.h" | 7 | #include "helpline.h" |
8 | #include "ui.h" | ||
8 | 9 | ||
9 | void ui_helpline__pop(void) | 10 | void ui_helpline__pop(void) |
10 | { | 11 | { |
@@ -55,7 +56,8 @@ int ui_helpline__show_help(const char *format, va_list ap) | |||
55 | int ret; | 56 | int ret; |
56 | static int backlog; | 57 | static int backlog; |
57 | 58 | ||
58 | ret = vsnprintf(ui_helpline__last_msg + backlog, | 59 | pthread_mutex_lock(&ui__lock); |
60 | ret = vsnprintf(ui_helpline__last_msg + backlog, | ||
59 | sizeof(ui_helpline__last_msg) - backlog, format, ap); | 61 | sizeof(ui_helpline__last_msg) - backlog, format, ap); |
60 | backlog += ret; | 62 | backlog += ret; |
61 | 63 | ||
@@ -64,6 +66,7 @@ int ui_helpline__show_help(const char *format, va_list ap) | |||
64 | newtRefresh(); | 66 | newtRefresh(); |
65 | backlog = 0; | 67 | backlog = 0; |
66 | } | 68 | } |
69 | pthread_mutex_unlock(&ui__lock); | ||
67 | 70 | ||
68 | return ret; | 71 | return ret; |
69 | } | 72 | } |
diff --git a/tools/perf/util/ui/setup.c b/tools/perf/util/ui/setup.c index fbf1a145492f..ee46d671db59 100644 --- a/tools/perf/util/ui/setup.c +++ b/tools/perf/util/ui/setup.c | |||
@@ -6,6 +6,9 @@ | |||
6 | #include "../debug.h" | 6 | #include "../debug.h" |
7 | #include "browser.h" | 7 | #include "browser.h" |
8 | #include "helpline.h" | 8 | #include "helpline.h" |
9 | #include "ui.h" | ||
10 | |||
11 | pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER; | ||
9 | 12 | ||
10 | static void newt_suspend(void *d __used) | 13 | static void newt_suspend(void *d __used) |
11 | { | 14 | { |
diff --git a/tools/perf/util/ui/ui.h b/tools/perf/util/ui/ui.h new file mode 100644 index 000000000000..d264e059c829 --- /dev/null +++ b/tools/perf/util/ui/ui.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef _PERF_UI_H_ | ||
2 | #define _PERF_UI_H_ 1 | ||
3 | |||
4 | #include <pthread.h> | ||
5 | |||
6 | extern pthread_mutex_t ui__lock; | ||
7 | |||
8 | #endif /* _PERF_UI_H_ */ | ||