tools/perf/ui/tui/setup.c
Source file repositories/reference/linux-study-clean/tools/perf/ui/tui/setup.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/ui/tui/setup.c- Extension
.c- Size
- 3751 bytes
- Lines
- 202
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
errno.hsignal.hstdbool.hstdlib.htermios.hunistd.hlinux/kernel.hexecinfo.h../../util/color.h../../util/debug.h../browser.h../helpline.h../ui.h../util.h../libslang.h../keysyms.htui.h
Detected Declarations
function ui__refresh_dimensionsfunction ui__sigwinchfunction ui__setup_sigwinchfunction ui__getchfunction ui__signal_backtracefunction ui__signalfunction ui__sigcontfunction ui__initfunction ui__exit
Annotated Snippet
#include <errno.h>
#include <signal.h>
#include <stdbool.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
#include <linux/kernel.h>
#ifdef HAVE_BACKTRACE_SUPPORT
#include <execinfo.h>
#endif
#include "../../util/color.h"
#include "../../util/debug.h"
#include "../browser.h"
#include "../helpline.h"
#include "../ui.h"
#include "../util.h"
#include "../libslang.h"
#include "../keysyms.h"
#include "tui.h"
static volatile int ui__need_resize;
extern struct perf_error_ops perf_tui_eops;
extern bool tui_helpline__set;
extern void hist_browser__init_hpp(void);
void ui__refresh_dimensions(bool force)
{
if (force || ui__need_resize) {
ui__need_resize = 0;
mutex_lock(&ui__lock);
SLtt_get_screen_size();
SLsmg_reinit_smg();
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;
Annotation
- Immediate include surface: `errno.h`, `signal.h`, `stdbool.h`, `stdlib.h`, `termios.h`, `unistd.h`, `linux/kernel.h`, `execinfo.h`.
- Detected declarations: `function ui__refresh_dimensions`, `function ui__sigwinch`, `function ui__setup_sigwinch`, `function ui__getch`, `function ui__signal_backtrace`, `function ui__signal`, `function ui__sigcont`, `function ui__init`, `function ui__exit`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.