void MLImeCfg_CL::buttonOk_clicked() { if ( checkroot() ) savebt_clicked(); //exit(0); emit cancel_clked(); }
static void powertop_init(void) { static char initialized = 0; int ret; struct statfs st_fs; struct rlimit rlmt; if (initialized) return; checkroot(); rlmt.rlim_cur = rlmt.rlim_max = get_nr_open(); setrlimit (RLIMIT_NOFILE, &rlmt); ret = system("/sbin/modprobe cpufreq_stats > /dev/null 2>&1"); ret = system("/sbin/modprobe msr > /dev/null 2>&1"); statfs("/sys/kernel/debug", &st_fs); if (st_fs.f_type != (long) DEBUGFS_MAGIC) { if (access("/bin/mount", X_OK) == 0) { ret = system("/bin/mount -t debugfs debugfs /sys/kernel/debug > /dev/null 2>&1"); } else { ret = system("mount -t debugfs debugfs /sys/kernel/debug > /dev/null 2>&1"); } if (ret != 0) { printf(_("Failed to mount debugfs!\n")); printf(_("exiting...\n")); exit(EXIT_FAILURE); } } srand(time(NULL)); if (access("/var/cache/", W_OK) == 0) mkdir("/var/cache/powertop", 0600); else mkdir("/data/local/powertop", 0600); load_results("saved_results.powertop"); load_parameters("saved_parameters.powertop"); enumerate_cpus(); create_all_devices(); detect_power_meters(); register_parameter("base power", 100, 0.5); register_parameter("cpu-wakeups", 39.5); register_parameter("cpu-consumption", 1.56); register_parameter("gpu-operations", 0.5576); register_parameter("disk-operations-hard", 0.2); register_parameter("disk-operations", 0.0); register_parameter("xwakes", 0.1); load_parameters("saved_parameters.powertop"); initialized = 1; }
matrix* Resmat(matrix* roots) { lie_Index i,j,k,r=Lierank(grp),s=Ssrank(grp), n=roots->nrows; vector* root_norms=Simproot_norms(grp); entry* norms=root_norms->compon; /* needed to compute $\<\lambda,\alpha[i]>$ */ matrix* root_images=Matmult(roots,Cartan()),* result=mkmatrix(r,r); entry** alpha=roots->elm,** img=root_images->elm,** res=result->elm; for (i=0; i<r; i++) for (j=0; j<r; j++) res[i][j]= i==j; /* initialise |res| to identity */ for (j=0; j<n; j++) /* traverse the given roots */ { entry* v=img[j], norm=(checkroot(alpha[j]),Norm(alpha[j])); for (k=s-1; v[k]==0; k--) {} if (k<j) error("Given set of roots is not independent; apply closure first.\n"); if (v[k]<0) { for (i=j; i<n; i++) img[i][k]= -img[i][k]; for (i=k-j; i<s; i++) res[i][k]= -res[i][k]; } while(--k>=j) /* clear |v[k+1]| by unimodular column operations with column~|j| */ { entry u[3][2]; lie_Index l=0; u[0][1]=u[1][0]=1; u[0][0]=u[1][1]=0; u[2][1]=v[k]; u[2][0]=v[k+1]; if (v[k]<0) u[2][1]= -v[k], u[0][1]= -1; /* make |u[2][1]| non-negative */ do /* subtract column |l| some times into column |1-l| */ { entry q=u[2][1-l]/u[2][l]; for (i=0; i<3; i++) u[i][1-l]-=q*u[i][l]; } while (u[2][l=1-l]!=0); if (l==0) for (i=0; i<2; i++) swap(&u[i][0],&u[i][1]); { for (i=j; i<n; i++) /* combine columns |k| and |k+1| */ { entry img_i_k=img[i][k]; img[i][k] =img_i_k*u[0][0]+img[i][k+1]*u[1][0]; img[i][k+1]=img_i_k*u[0][1]+img[i][k+1]*u[1][1]; } for (i=k-j; i<s; i++) { entry res_i_k=res[i][k]; res[i][k]=res_i_k*u[0][0]+res[i][k+1]*u[1][0]; res[i][k+1]=res_i_k*u[0][1]+res[i][k+1]*u[1][1]; } } } for (i=0; i<s; i++) { lie_Index inpr= norms[i]*alpha[j][i]; /* this is $(\omega_i,\alpha[j])$ */ if (inpr%norm!=0) error("Supposed root has non-integer Cartan product.\n"); res[i][j]=inpr/norm; /* this is $\<\omega_i,\alpha[j]>$ */ } } freemem(root_norms); freemem(root_images); return result; }
MLImeCfg_CL::MLImeCfg_CL( QWidget* parent ) : QWidget( parent ), imefilestatus( false ) { setupUI(); buttonOk->hide(); buttonCancel->hide(); connect( listBox, SIGNAL( itemClicked( QListWidgetItem* ) ), this, SLOT( listBox_clicked( QListWidgetItem* ) ) ); connect( buttonOk, SIGNAL( clicked() ), this, SLOT( buttonOk_clicked() ) ); connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( buttonCancel_clicked() ) ); connect( savebt, SIGNAL( clicked() ), this, SLOT( savebt_clicked() ) ); connect( createbt, SIGNAL( clicked() ), this, SLOT( createbt_clicked() ) ); connect( opencmd, SIGNAL( clicked() ), this, SLOT( opencmd_clicked() ) ); connect( delbn, SIGNAL( clicked() ), this, SLOT( delbn_clicked() ) ); connect( addbn, SIGNAL( clicked() ), this, SLOT( addbn_clicked() ) ); connect( clearbn, SIGNAL( clicked() ), this, SLOT( clearbn_clicked() ) ); connect( defaultbn, SIGNAL( clicked() ), this, SLOT( defaultbn_clicked() ) ); QDir ime( IMEDIR ); //检查用户权限,若非 root 则禁用添加删除输入法及保存启动脚本的按钮 if ( checkroot() ) { if ( !ime.exists() ) { //如果目录不存在则创建它。 QString tmpcmd; tmpcmd = "mkdir -p " + QString( IMEDIR ); system( qPrintable( tmpcmd ) ); } } else { addbn->setEnabled( false ); delbn->setEnabled( false ); savebt->setEnabled( false ); } ime.setFilter( QDir::Files ); imecount = ime.count(); listitem = imecount; for ( int i=0; i<imecount; ++i ) listBox->addItem( ime[i] ); //显示默认输入法 showdefaultime(); readxinput(); auto_choose(); }
int main(int argc, char **argv) { int option_index; int c; char filename[4096]; char workload[4096] = {0,}; int iterations = 1, auto_tune = 0; set_new_handler(out_of_memory); setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); while (1) { /* parse commandline options */ c = getopt_long (argc, argv, "ch:C:i:t:uVw:q", long_options, &option_index); /* Detect the end of the options. */ if (c == -1) break; switch (c) { case 'V': print_version(); exit(0); break; case 'e': /* Extech power analyzer support */ checkroot(); extech_power_meter(optarg ? optarg : "/dev/ttyUSB0"); break; case 'u': print_usage(); exit(0); break; case 'a': auto_tune = 1; leave_powertop = 1; break; case 'c': powertop_init(); calibrate(); break; case 'h': /* html report */ reporttype = REPORT_HTML; sprintf(filename, "%s", optarg ? optarg : "powertop.html" ); break; case 't': time_out = (optarg ? atoi(optarg) : 20); break; case 'i': iterations = (optarg ? atoi(optarg) : 1); break; case 'w': /* measure workload */ sprintf(workload, "%s", optarg ? optarg :'\0' ); break; case 'q': if(freopen("/dev/null", "a", stderr)) fprintf(stderr, _("Quite mode failed!\n")); break; case 'C': /* csv report*/ reporttype = REPORT_CSV; sprintf(filename, "%s", optarg ? optarg : "powertop.csv"); break; case '?': /* Unknown option */ /* getopt_long already printed an error message. */ exit(0); break; } } powertop_init(); if (reporttype != REPORT_OFF) make_report(time_out, workload, iterations, filename); if (debug_learning) printf("Learning debugging enabled\n"); learn_parameters(250, 0); save_parameters("saved_parameters.powertop"); if (debug_learning) { learn_parameters(1000, 1); dump_parameter_bundle(); end_pci_access(); exit(0); } init_display(); initialize_tuning(); /* first one is short to not let the user wait too long */ one_measurement(1, NULL); if (!auto_tune) { tuning_update_display(); show_tab(0); } else { auto_toggle_tuning(); } while (!leave_powertop) { show_cur_tab(); one_measurement(time_out, NULL); learn_parameters(15, 0); } endwin(); printf("%s\n", _("Leaving PowerTOP")); end_process_data(); clear_process_data(); end_cpu_data(); clear_cpu_data(); save_all_results("saved_results.powertop"); save_parameters("saved_parameters.powertop"); learn_parameters(500, 0); save_parameters("saved_parameters.powertop"); end_pci_access(); clear_tuning(); reset_display(); clean_shutdown(); return 0; }