f7a858bffc
Rename the fallthrough attribute to better align with the kernel version. Copy the definition from include/linux/compiler_attributes.h including the #else clause. Adding the #else clause allows the tools compiler.h header to drop the check for a definition entirely and keeps both definitions together. Change any __fallthrough statements to fallthrough anywhere it was used within perf. This allows other tools to use the same key word as the kernel. Committer notes: Did some missing conversions to: builtin-list.c Also included gtk.h before the 'fallthrough' definition in: tools/perf/ui/gtk/hists.c tools/perf/ui/gtk/helpline.c tools/perf/ui/gtk/browser.c As it is the arg name for a macro in glib.h: /var/home/acme/git/perf-tools-next/tools/include/linux/compiler-gcc.h:16:55: error: missing binary operator before token "(" 16 | # define fallthrough __attribute__((__fallthrough__)) | ^ /usr/include/glib-2.0/glib/gmacros.h:637:28: note: in expansion of macro ‘fallthrough’ 637 | #if g_macro__has_attribute(fallthrough) Reviewed-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Liam Howlett <Liam.Howlett@oracle.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Miguel Ojeda <ojeda@kernel.org> Cc: Nathan Chancellor <nathan@kernel.org> Cc: Nick Desaulniers <ndesaulniers@google.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Tom Rix <trix@redhat.com> Cc: linux-sparse@vger.kernel.org <linux-sparse@vger.kernel.org> Cc: llvm@lists.linux.dev <llvm@lists.linux.dev> Link: https://lore.kernel.org/r/20221125154947.2163498-1-Liam.Howlett@oracle.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
59 lines
1.2 KiB
C
59 lines
1.2 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include "gtk.h"
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <linux/kernel.h>
|
|
|
|
#include "../ui.h"
|
|
#include "../helpline.h"
|
|
|
|
static void gtk_helpline_pop(void)
|
|
{
|
|
if (!perf_gtk__is_active_context(pgctx))
|
|
return;
|
|
|
|
gtk_statusbar_pop(GTK_STATUSBAR(pgctx->statbar),
|
|
pgctx->statbar_ctx_id);
|
|
}
|
|
|
|
static void gtk_helpline_push(const char *msg)
|
|
{
|
|
if (!perf_gtk__is_active_context(pgctx))
|
|
return;
|
|
|
|
gtk_statusbar_push(GTK_STATUSBAR(pgctx->statbar),
|
|
pgctx->statbar_ctx_id, msg);
|
|
}
|
|
|
|
static int gtk_helpline_show(const char *fmt, va_list ap)
|
|
{
|
|
int ret;
|
|
char *ptr;
|
|
static int backlog;
|
|
|
|
ret = vscnprintf(ui_helpline__current + backlog,
|
|
sizeof(ui_helpline__current) - backlog, fmt, ap);
|
|
backlog += ret;
|
|
|
|
/* only first line can be displayed */
|
|
ptr = strchr(ui_helpline__current, '\n');
|
|
if (ptr && (ptr - ui_helpline__current) <= backlog) {
|
|
*ptr = '\0';
|
|
ui_helpline__puts(ui_helpline__current);
|
|
backlog = 0;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
static struct ui_helpline gtk_helpline_fns = {
|
|
.pop = gtk_helpline_pop,
|
|
.push = gtk_helpline_push,
|
|
.show = gtk_helpline_show,
|
|
};
|
|
|
|
void perf_gtk__init_helpline(void)
|
|
{
|
|
helpline_fns = >k_helpline_fns;
|
|
}
|