mirror of
https://github.com/torvalds/linux.git
synced 2024-12-18 17:12:55 +00:00
1d037ca164
perf defines both __used and __unused variables to use for marking
unused variables. The variable __used is defined to
__attribute__((__unused__)), which contradicts the kernel definition to
__attribute__((__used__)) for new gcc versions. On Android, __used is
also defined in system headers and this leads to warnings like: warning:
'__used__' attribute ignored
__unused is not defined in the kernel and is not a standard definition.
If __unused is included everywhere instead of __used, this leads to
conflicts with glibc headers, since glibc has a variables with this name
in its headers.
The best approach is to use __maybe_unused, the definition used in the
kernel for __attribute__((unused)). In this way there is only one
definition in perf sources (instead of 2 definitions that point to the
same thing: __used and __unused) and it works on both Linux and Android.
This patch simply replaces all instances of __used and __unused with
__maybe_unused.
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Acked-by: Pekka Enberg <penberg@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1347315303-29906-7-git-send-email-irina.tirdea@intel.com
[ committer note: fixed up conflict with a116e05
in builtin-sched.c ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
149 lines
2.5 KiB
C
149 lines
2.5 KiB
C
#include <newt.h>
|
|
#include <signal.h>
|
|
#include <stdbool.h>
|
|
|
|
#include "../../util/cache.h"
|
|
#include "../../util/debug.h"
|
|
#include "../browser.h"
|
|
#include "../helpline.h"
|
|
#include "../ui.h"
|
|
#include "../util.h"
|
|
#include "../libslang.h"
|
|
#include "../keysyms.h"
|
|
|
|
static volatile int ui__need_resize;
|
|
|
|
extern struct perf_error_ops perf_tui_eops;
|
|
|
|
extern void hist_browser__init_hpp(void);
|
|
|
|
void ui__refresh_dimensions(bool force)
|
|
{
|
|
if (force || ui__need_resize) {
|
|
ui__need_resize = 0;
|
|
pthread_mutex_lock(&ui__lock);
|
|
SLtt_get_screen_size();
|
|
SLsmg_reinit_smg();
|
|
pthread_mutex_unlock(&ui__lock);
|
|
}
|
|
}
|
|
|
|
static void ui__sigwinch(int sig __maybe_unused)
|
|
{
|
|
ui__need_resize = 1;
|
|
}
|
|
|
|
static void ui__setup_sigwinch(void)
|
|
{
|
|
static bool done;
|
|
|
|
if (done)
|
|
return;
|
|
|
|
done = true;
|
|
pthread__unblock_sigwinch();
|
|
signal(SIGWINCH, ui__sigwinch);
|
|
}
|
|
|
|
int ui__getch(int delay_secs)
|
|
{
|
|
struct timeval timeout, *ptimeout = delay_secs ? &timeout : NULL;
|
|
fd_set read_set;
|
|
int err, key;
|
|
|
|
ui__setup_sigwinch();
|
|
|
|
FD_ZERO(&read_set);
|
|
FD_SET(0, &read_set);
|
|
|
|
if (delay_secs) {
|
|
timeout.tv_sec = delay_secs;
|
|
timeout.tv_usec = 0;
|
|
}
|
|
|
|
err = select(1, &read_set, NULL, NULL, ptimeout);
|
|
|
|
if (err == 0)
|
|
return K_TIMER;
|
|
|
|
if (err == -1) {
|
|
if (errno == EINTR)
|
|
return K_RESIZE;
|
|
return K_ERROR;
|
|
}
|
|
|
|
key = SLang_getkey();
|
|
if (key != K_ESC)
|
|
return key;
|
|
|
|
FD_ZERO(&read_set);
|
|
FD_SET(0, &read_set);
|
|
timeout.tv_sec = 0;
|
|
timeout.tv_usec = 20;
|
|
err = select(1, &read_set, NULL, NULL, &timeout);
|
|
if (err == 0)
|
|
return K_ESC;
|
|
|
|
SLang_ungetkey(key);
|
|
return SLkp_getkey();
|
|
}
|
|
|
|
static void newt_suspend(void *d __maybe_unused)
|
|
{
|
|
newtSuspend();
|
|
raise(SIGTSTP);
|
|
newtResume();
|
|
}
|
|
|
|
static void ui__signal(int sig)
|
|
{
|
|
ui__exit(false);
|
|
psignal(sig, "perf");
|
|
exit(0);
|
|
}
|
|
|
|
int ui__init(void)
|
|
{
|
|
int err;
|
|
|
|
newtInit();
|
|
err = SLkp_init();
|
|
if (err < 0) {
|
|
pr_err("TUI initialization failed.\n");
|
|
goto out;
|
|
}
|
|
|
|
SLkp_define_keysym((char *)"^(kB)", SL_KEY_UNTAB);
|
|
|
|
newtSetSuspendCallback(newt_suspend, NULL);
|
|
ui_helpline__init();
|
|
ui_browser__init();
|
|
|
|
signal(SIGSEGV, ui__signal);
|
|
signal(SIGFPE, ui__signal);
|
|
signal(SIGINT, ui__signal);
|
|
signal(SIGQUIT, ui__signal);
|
|
signal(SIGTERM, ui__signal);
|
|
|
|
perf_error__register(&perf_tui_eops);
|
|
|
|
hist_browser__init_hpp();
|
|
out:
|
|
return err;
|
|
}
|
|
|
|
void ui__exit(bool wait_for_ok)
|
|
{
|
|
if (wait_for_ok)
|
|
ui__question_window("Fatal Error",
|
|
ui_helpline__last_msg,
|
|
"Press any key...", 0);
|
|
|
|
SLtt_set_cursor_visibility(1);
|
|
SLsmg_refresh();
|
|
SLsmg_reset_smg();
|
|
SLang_reset_tty();
|
|
|
|
perf_error__unregister(&perf_tui_eops);
|
|
}
|