Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754124Ab2JDSYi (ORCPT ); Thu, 4 Oct 2012 14:24:38 -0400 Received: from casper.infradead.org ([85.118.1.10]:39666 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751535Ab2JDSI6 (ORCPT ); Thu, 4 Oct 2012 14:08:58 -0400 From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Namhyung Kim , Namhyung Kim , Paul Mackerras , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: [PATCH 06/42] perf tools: Convert to NEWT_SUPPORT Date: Thu, 4 Oct 2012 15:08:06 -0300 Message-Id: <1349374122-27806-7-git-send-email-acme@infradead.org> X-Mailer: git-send-email 1.7.9.2.358.g22243 In-Reply-To: <1349374122-27806-1-git-send-email-acme@infradead.org> References: <1349374122-27806-1-git-send-email-acme@infradead.org> Content-Type: text/plain; charset="UTF-8" X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8754 Lines: 250 From: Namhyung Kim For building perf without libnewt, we can set NO_NEWT=1 as a argument of make. It then defines NO_NEWT_SUPPORT macro for C code to do the proper handling. However it usually used in a negative semantics - e.g. #ifndef - so we saw double negations which can be misleading. Convert it to a positive form to make it more readable. Signed-off-by: Namhyung Kim Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1348824728-14025-7-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Makefile | 8 +++----- tools/perf/ui/gtk/util.c | 2 +- tools/perf/ui/helpline.h | 10 +++++----- tools/perf/util/annotate.h | 8 ++++---- tools/perf/util/cache.h | 12 ++++++------ tools/perf/util/debug.c | 2 +- tools/perf/util/debug.h | 6 +++--- tools/perf/util/hist.h | 18 +++++++++--------- 8 files changed, 32 insertions(+), 34 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 99b2bb3..3d2181c 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -554,16 +554,14 @@ ifndef NO_LIBAUDIT endif endif -ifdef NO_NEWT - BASIC_CFLAGS += -DNO_NEWT_SUPPORT -else +ifndef NO_NEWT FLAGS_NEWT=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -lnewt ifneq ($(call try-cc,$(SOURCE_NEWT),$(FLAGS_NEWT)),y) msg := $(warning newt not found, disables TUI support. Please install newt-devel or libnewt-dev); - BASIC_CFLAGS += -DNO_NEWT_SUPPORT else # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h BASIC_CFLAGS += -I/usr/include/slang + BASIC_CFLAGS += -DNEWT_SUPPORT EXTLIBS += -lnewt -lslang LIB_OBJS += $(OUTPUT)ui/setup.o LIB_OBJS += $(OUTPUT)ui/browser.o @@ -603,7 +601,7 @@ else LIB_OBJS += $(OUTPUT)ui/gtk/util.o LIB_OBJS += $(OUTPUT)ui/gtk/helpline.o # Make sure that it'd be included only once. - ifneq ($(findstring -DNO_NEWT_SUPPORT,$(BASIC_CFLAGS)),) + ifeq ($(findstring -DNEWT_SUPPORT,$(BASIC_CFLAGS)),) LIB_OBJS += $(OUTPUT)ui/setup.o LIB_OBJS += $(OUTPUT)ui/util.o endif diff --git a/tools/perf/ui/gtk/util.c b/tools/perf/ui/gtk/util.c index 8aada5b..ccb046a 100644 --- a/tools/perf/ui/gtk/util.c +++ b/tools/perf/ui/gtk/util.c @@ -116,7 +116,7 @@ struct perf_error_ops perf_gtk_eops = { * FIXME: Functions below should be implemented properly. * For now, just add stubs for NO_NEWT=1 build. */ -#ifdef NO_NEWT_SUPPORT +#ifndef NEWT_SUPPORT void ui_progress__update(u64 curr __maybe_unused, u64 total __maybe_unused, const char *title __maybe_unused) { diff --git a/tools/perf/ui/helpline.h b/tools/perf/ui/helpline.h index 2b667ee..e1f126b 100644 --- a/tools/perf/ui/helpline.h +++ b/tools/perf/ui/helpline.h @@ -23,16 +23,16 @@ void ui_helpline__puts(const char *msg); extern char ui_helpline__current[512]; -#ifdef NO_NEWT_SUPPORT +#ifdef NEWT_SUPPORT +extern char ui_helpline__last_msg[]; +int ui_helpline__show_help(const char *format, va_list ap); +#else static inline int ui_helpline__show_help(const char *format __maybe_unused, va_list ap __maybe_unused) { return 0; } -#else -extern char ui_helpline__last_msg[]; -int ui_helpline__show_help(const char *format, va_list ap); -#endif /* NO_NEWT_SUPPORT */ +#endif /* NEWT_SUPPORT */ #ifdef NO_GTK2_SUPPORT static inline int perf_gtk__show_helpline(const char *format __maybe_unused, diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 9b5b21e..39242dc 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -138,7 +138,10 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx, bool print_lines, bool full_paths, int min_pcnt, int max_lines); -#ifdef NO_NEWT_SUPPORT +#ifdef NEWT_SUPPORT +int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, + void(*timer)(void *arg), void *arg, int delay_secs); +#else static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused, struct map *map __maybe_unused, int evidx __maybe_unused, @@ -148,9 +151,6 @@ static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused, { return 0; } -#else -int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, - void(*timer)(void *arg), void *arg, int delay_secs); #endif extern const char *disassembler_style; diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h index ab17694..70f318d 100644 --- a/tools/perf/util/cache.h +++ b/tools/perf/util/cache.h @@ -33,7 +33,7 @@ extern int pager_use_color; extern int use_browser; -#if defined(NO_NEWT_SUPPORT) && defined(NO_GTK2_SUPPORT) +#if !defined(NEWT_SUPPORT) && defined(NO_GTK2_SUPPORT) static inline void setup_browser(bool fallback_to_pager) { if (fallback_to_pager) @@ -44,15 +44,15 @@ static inline void exit_browser(bool wait_for_ok __maybe_unused) {} void setup_browser(bool fallback_to_pager); void exit_browser(bool wait_for_ok); -#ifdef NO_NEWT_SUPPORT +#ifdef NEWT_SUPPORT +int ui__init(void); +void ui__exit(bool wait_for_ok); +#else static inline int ui__init(void) { return -1; } static inline void ui__exit(bool wait_for_ok __maybe_unused) {} -#else -int ui__init(void); -void ui__exit(bool wait_for_ok); #endif #ifdef NO_GTK2_SUPPORT @@ -65,7 +65,7 @@ static inline void perf_gtk__exit(bool wait_for_ok __maybe_unused) {} int perf_gtk__init(void); void perf_gtk__exit(bool wait_for_ok); #endif -#endif /* NO_NEWT_SUPPORT && NO_GTK2_SUPPORT */ +#endif /* !NEWT_SUPPORT && NO_GTK2_SUPPORT */ char *alias_lookup(const char *alias); int split_cmdline(char *cmdline, const char ***argv); diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c index 66eb382..0f6ad70 100644 --- a/tools/perf/util/debug.c +++ b/tools/perf/util/debug.c @@ -49,7 +49,7 @@ int dump_printf(const char *fmt, ...) return ret; } -#if defined(NO_NEWT_SUPPORT) && defined(NO_GTK2_SUPPORT) +#if !defined(NEWT_SUPPORT) && defined(NO_GTK2_SUPPORT) int ui__warning(const char *format, ...) { va_list args; diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index bb2e7d1..3fe9ade 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h @@ -15,7 +15,7 @@ void trace_event(union perf_event *event); struct ui_progress; struct perf_error_ops; -#if defined(NO_NEWT_SUPPORT) && defined(NO_GTK2_SUPPORT) +#if !defined(NEWT_SUPPORT) && defined(NO_GTK2_SUPPORT) static inline void ui_progress__update(u64 curr __maybe_unused, u64 total __maybe_unused, const char *title __maybe_unused) {} @@ -34,13 +34,13 @@ perf_error__unregister(struct perf_error_ops *eops __maybe_unused) return 0; } -#else /* NO_NEWT_SUPPORT && NO_GTK2_SUPPORT */ +#else /* !NEWT_SUPPORT && NO_GTK2_SUPPORT */ #include "../ui/progress.h" int ui__error(const char *format, ...) __attribute__((format(printf, 1, 2))); #include "../ui/util.h" -#endif /* NO_NEWT_SUPPORT && NO_GTK2_SUPPORT */ +#endif /* !NEWT_SUPPORT && NO_GTK2_SUPPORT */ int ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2))); int ui__error_paranoid(void); diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index f011ad4..843638d 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -154,7 +154,15 @@ int hist_entry__period_snprintf(struct perf_hpp *hpp, struct hist_entry *he, struct perf_evlist; -#ifdef NO_NEWT_SUPPORT +#ifdef NEWT_SUPPORT +#include "../ui/keysyms.h" +int hist_entry__tui_annotate(struct hist_entry *he, int evidx, + void(*timer)(void *arg), void *arg, int delay_secs); + +int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, + void(*timer)(void *arg), void *arg, + int refresh); +#else static inline int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused, const char *help __maybe_unused, @@ -177,14 +185,6 @@ static inline int hist_entry__tui_annotate(struct hist_entry *self } #define K_LEFT -1 #define K_RIGHT -2 -#else -#include "../ui/keysyms.h" -int hist_entry__tui_annotate(struct hist_entry *he, int evidx, - void(*timer)(void *arg), void *arg, int delay_secs); - -int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, - void(*timer)(void *arg), void *arg, - int refresh); #endif #ifdef NO_GTK2_SUPPORT -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/