tools/perf/ui/setup.c

Source file repositories/reference/linux-study-clean/tools/perf/ui/setup.c

File Facts

System
Linux kernel
Corpus path
tools/perf/ui/setup.c
Extension
.c
Size
2610 bytes
Lines
142
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.

Dependency Surface

Detected Declarations

Annotated Snippet

static inline int setup_gtk_browser(void) { return -1; }
static inline void exit_gtk_browser(bool wait_for_ok __maybe_unused) {}
#endif

int stdio__config_color(const struct option *opt __maybe_unused,
			const char *mode, int unset __maybe_unused)
{
	perf_use_color_default = perf_config_colorbool("color.ui", mode, -1);
	return 0;
}

void setup_browser(bool fallback_to_pager)
{
	mutex_init(&ui__lock);
	if (use_browser < 2 && (!isatty(1) || dump_trace))
		use_browser = 0;

	/* default to TUI */
	if (use_browser < 0)
		use_browser = 1;

	switch (use_browser) {
	case 2:
		if (setup_gtk_browser() == 0)
			break;
		printf("GTK browser requested but could not find %s\n",
		       PERF_GTK_DSO);
		sleep(1);
		use_browser = 1;
		/* fall through */
	case 1:
		if (ui__init() == 0)
			break;
		/* fall through */
	default:
		use_browser = 0;
		if (fallback_to_pager)
			setup_pager();
		break;
	}
}

void exit_browser(bool wait_for_ok)
{
	switch (use_browser) {
	case 2:
		exit_gtk_browser(wait_for_ok);
		break;

	case 1:
		ui__exit(wait_for_ok);
		break;

	default:
		break;
	}
	mutex_destroy(&ui__lock);
}

void pthread__block_sigwinch(void)
{
	sigset_t set;

	sigemptyset(&set);
	sigaddset(&set, SIGWINCH);
	pthread_sigmask(SIG_BLOCK, &set, NULL);
}

void pthread__unblock_sigwinch(void)
{
	sigset_t set;

	sigemptyset(&set);
	sigaddset(&set, SIGWINCH);
	pthread_sigmask(SIG_UNBLOCK, &set, NULL);
}

Annotation

Implementation Notes