~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/ui/setup.c

Version: ~ [ linux-5.16-rc3 ] ~ [ linux-5.15.5 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.82 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.162 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.218 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.256 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.291 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.293 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #include <pthread.h>
  2 #include <dlfcn.h>
  3 
  4 #include "../util/cache.h"
  5 #include "../util/debug.h"
  6 #include "../util/hist.h"
  7 
  8 pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
  9 void *perf_gtk_handle;
 10 
 11 #ifdef HAVE_GTK2_SUPPORT
 12 static int setup_gtk_browser(void)
 13 {
 14         int (*perf_ui_init)(void);
 15 
 16         if (perf_gtk_handle)
 17                 return 0;
 18 
 19         perf_gtk_handle = dlopen(PERF_GTK_DSO, RTLD_LAZY);
 20         if (perf_gtk_handle == NULL) {
 21                 char buf[PATH_MAX];
 22                 scnprintf(buf, sizeof(buf), "%s/%s", LIBDIR, PERF_GTK_DSO);
 23                 perf_gtk_handle = dlopen(buf, RTLD_LAZY);
 24         }
 25         if (perf_gtk_handle == NULL)
 26                 return -1;
 27 
 28         perf_ui_init = dlsym(perf_gtk_handle, "perf_gtk__init");
 29         if (perf_ui_init == NULL)
 30                 goto out_close;
 31 
 32         if (perf_ui_init() == 0)
 33                 return 0;
 34 
 35 out_close:
 36         dlclose(perf_gtk_handle);
 37         return -1;
 38 }
 39 
 40 static void exit_gtk_browser(bool wait_for_ok)
 41 {
 42         void (*perf_ui_exit)(bool);
 43 
 44         if (perf_gtk_handle == NULL)
 45                 return;
 46 
 47         perf_ui_exit = dlsym(perf_gtk_handle, "perf_gtk__exit");
 48         if (perf_ui_exit == NULL)
 49                 goto out_close;
 50 
 51         perf_ui_exit(wait_for_ok);
 52 
 53 out_close:
 54         dlclose(perf_gtk_handle);
 55 
 56         perf_gtk_handle = NULL;
 57 }
 58 #else
 59 static inline int setup_gtk_browser(void) { return -1; }
 60 static inline void exit_gtk_browser(bool wait_for_ok __maybe_unused) {}
 61 #endif
 62 
 63 void setup_browser(bool fallback_to_pager)
 64 {
 65         if (use_browser < 2 && (!isatty(1) || dump_trace))
 66                 use_browser = 0;
 67 
 68         /* default to TUI */
 69         if (use_browser < 0)
 70                 use_browser = 1;
 71 
 72         switch (use_browser) {
 73         case 2:
 74                 if (setup_gtk_browser() == 0)
 75                         break;
 76                 printf("GTK browser requested but could not find %s\n",
 77                        PERF_GTK_DSO);
 78                 sleep(1);
 79                 /* fall through */
 80         case 1:
 81                 use_browser = 1;
 82                 if (ui__init() == 0)
 83                         break;
 84                 /* fall through */
 85         default:
 86                 use_browser = 0;
 87                 if (fallback_to_pager)
 88                         setup_pager();
 89                 break;
 90         }
 91 }
 92 
 93 void exit_browser(bool wait_for_ok)
 94 {
 95         switch (use_browser) {
 96         case 2:
 97                 exit_gtk_browser(wait_for_ok);
 98                 break;
 99 
100         case 1:
101                 ui__exit(wait_for_ok);
102                 break;
103 
104         default:
105                 break;
106         }
107 }
108 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp