4 #include "../util/cache.h"
5 #include "../util/debug.h"
6 #include "../util/hist.h"
8 pthread_mutex_t ui__lock
= PTHREAD_MUTEX_INITIALIZER
;
11 #ifdef HAVE_GTK2_SUPPORT
12 static int setup_gtk_browser(void)
14 int (*perf_ui_init
)(void);
19 perf_gtk_handle
= dlopen(PERF_GTK_DSO
, RTLD_LAZY
);
20 if (perf_gtk_handle
== NULL
) {
22 scnprintf(buf
, sizeof(buf
), "%s/%s", LIBDIR
, PERF_GTK_DSO
);
23 perf_gtk_handle
= dlopen(buf
, RTLD_LAZY
);
25 if (perf_gtk_handle
== NULL
)
28 perf_ui_init
= dlsym(perf_gtk_handle
, "perf_gtk__init");
29 if (perf_ui_init
== NULL
)
32 if (perf_ui_init() == 0)
36 dlclose(perf_gtk_handle
);
40 static void exit_gtk_browser(bool wait_for_ok
)
42 void (*perf_ui_exit
)(bool);
44 if (perf_gtk_handle
== NULL
)
47 perf_ui_exit
= dlsym(perf_gtk_handle
, "perf_gtk__exit");
48 if (perf_ui_exit
== NULL
)
51 perf_ui_exit(wait_for_ok
);
54 dlclose(perf_gtk_handle
);
56 perf_gtk_handle
= NULL
;
59 static inline int setup_gtk_browser(void) { return -1; }
60 static inline void exit_gtk_browser(bool wait_for_ok __maybe_unused
) {}
63 void setup_browser(bool fallback_to_pager
)
65 if (use_browser
< 2 && (!isatty(1) || dump_trace
))
72 switch (use_browser
) {
74 if (setup_gtk_browser() == 0)
76 printf("GTK browser requested but could not find %s\n",
87 if (fallback_to_pager
)
93 void exit_browser(bool wait_for_ok
)
95 switch (use_browser
) {
97 exit_gtk_browser(wait_for_ok
);
101 ui__exit(wait_for_ok
);