Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf ui: Move ui_progress routines to separate file in util/ui/

LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+74 -59
+2
tools/perf/Makefile
··· 570 570 LIB_OBJS += $(OUTPUT)util/newt.o 571 571 LIB_OBJS += $(OUTPUT)util/ui/browser.o 572 572 LIB_OBJS += $(OUTPUT)util/ui/helpline.o 573 + LIB_OBJS += $(OUTPUT)util/ui/progress.o 573 574 LIB_H += util/ui/browser.h 574 575 LIB_H += util/ui/helpline.h 576 + LIB_H += util/ui/progress.h 575 577 endif 576 578 endif 577 579
+1 -3
tools/perf/util/debug.h
··· 31 31 static inline void ui_progress__delete(struct ui_progress *self __used) {} 32 32 #else 33 33 int browser__show_help(const char *format, va_list ap); 34 - struct ui_progress *ui_progress__new(const char *title, u64 total); 35 - void ui_progress__update(struct ui_progress *self, u64 curr); 36 - void ui_progress__delete(struct ui_progress *self); 34 + #include "ui/progress.h" 37 35 #endif 38 36 39 37 #endif /* __PERF_DEBUG_H */
-56
tools/perf/util/newt.c
··· 39 39 40 40 newtComponent newt_form__new(void); 41 41 42 - struct ui_progress { 43 - newtComponent form, scale; 44 - }; 45 - 46 - struct ui_progress *ui_progress__new(const char *title, u64 total) 47 - { 48 - struct ui_progress *self = malloc(sizeof(*self)); 49 - 50 - if (self != NULL) { 51 - int cols; 52 - 53 - if (use_browser <= 0) 54 - return self; 55 - newtGetScreenSize(&cols, NULL); 56 - cols -= 4; 57 - newtCenteredWindow(cols, 1, title); 58 - self->form = newtForm(NULL, NULL, 0); 59 - if (self->form == NULL) 60 - goto out_free_self; 61 - self->scale = newtScale(0, 0, cols, total); 62 - if (self->scale == NULL) 63 - goto out_free_form; 64 - newtFormAddComponent(self->form, self->scale); 65 - newtRefresh(); 66 - } 67 - 68 - return self; 69 - 70 - out_free_form: 71 - newtFormDestroy(self->form); 72 - out_free_self: 73 - free(self); 74 - return NULL; 75 - } 76 - 77 - void ui_progress__update(struct ui_progress *self, u64 curr) 78 - { 79 - /* 80 - * FIXME: We should have a per UI backend way of showing progress, 81 - * stdio will just show a percentage as NN%, etc. 82 - */ 83 - if (use_browser <= 0) 84 - return; 85 - newtScaleSet(self->scale, curr); 86 - newtRefresh(); 87 - } 88 - 89 - void ui_progress__delete(struct ui_progress *self) 90 - { 91 - if (use_browser > 0) { 92 - newtFormDestroy(self->form); 93 - newtPopWindow(); 94 - } 95 - free(self); 96 - } 97 - 98 42 static int ui_entry__read(const char *title, char *bf, size_t size, int width) 99 43 { 100 44 struct newtExitStruct es;
+60
tools/perf/util/ui/progress.c
··· 1 + #include <stdlib.h> 2 + #include <newt.h> 3 + #include "../cache.h" 4 + #include "progress.h" 5 + 6 + struct ui_progress { 7 + newtComponent form, scale; 8 + }; 9 + 10 + struct ui_progress *ui_progress__new(const char *title, u64 total) 11 + { 12 + struct ui_progress *self = malloc(sizeof(*self)); 13 + 14 + if (self != NULL) { 15 + int cols; 16 + 17 + if (use_browser <= 0) 18 + return self; 19 + newtGetScreenSize(&cols, NULL); 20 + cols -= 4; 21 + newtCenteredWindow(cols, 1, title); 22 + self->form = newtForm(NULL, NULL, 0); 23 + if (self->form == NULL) 24 + goto out_free_self; 25 + self->scale = newtScale(0, 0, cols, total); 26 + if (self->scale == NULL) 27 + goto out_free_form; 28 + newtFormAddComponent(self->form, self->scale); 29 + newtRefresh(); 30 + } 31 + 32 + return self; 33 + 34 + out_free_form: 35 + newtFormDestroy(self->form); 36 + out_free_self: 37 + free(self); 38 + return NULL; 39 + } 40 + 41 + void ui_progress__update(struct ui_progress *self, u64 curr) 42 + { 43 + /* 44 + * FIXME: We should have a per UI backend way of showing progress, 45 + * stdio will just show a percentage as NN%, etc. 46 + */ 47 + if (use_browser <= 0) 48 + return; 49 + newtScaleSet(self->scale, curr); 50 + newtRefresh(); 51 + } 52 + 53 + void ui_progress__delete(struct ui_progress *self) 54 + { 55 + if (use_browser > 0) { 56 + newtFormDestroy(self->form); 57 + newtPopWindow(); 58 + } 59 + free(self); 60 + }
+11
tools/perf/util/ui/progress.h
··· 1 + #ifndef _PERF_UI_PROGRESS_H_ 2 + #define _PERF_UI_PROGRESS_H_ 1 3 + 4 + struct ui_progress; 5 + 6 + struct ui_progress *ui_progress__new(const char *title, u64 total); 7 + void ui_progress__delete(struct ui_progress *self); 8 + 9 + void ui_progress__update(struct ui_progress *self, u64 curr); 10 + 11 + #endif