예제 #1
0
파일: fanedit.c 프로젝트: likev/CodeOrpgPub
int main(int argc, char *argv[])
{
    Arg             al[20];
    int             ac;
    int             canvaswidth, canvasheight;

    /* read command line options */
    if (Read_options (argc, argv) != 0)
	exit (-1);

    /* create the toplevel shell */
    toplevel = XtAppInitialize(&context, "", NULL, 0,
			       &argc, argv, NULL, NULL, 0);

    CS_error((void (*) ()) printf);

    printf("We serve line %d\n", Cur_link_ind);

    SIM_init (In_lb, Out_lb);

    /* default window size. */
    ac = 0;
    canvaswidth = 400;
    canvasheight = 700;
    XtSetArg(al[ac], XmNheight, canvaswidth);
    ac++;
    XtSetArg(al[ac], XmNwidth, canvasheight);
    ac++;
    XtSetValues(toplevel, al, ac);

    /* create a form widget. */
    ac = 0;
    form = XmCreateForm(toplevel, "form", al, ac);
    XtManageChild(form);

    /* create a menu bar and attach it to the form. */
    ac = 0;
    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM);
    ac++;
    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM);
    ac++;
    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM);
    ac++;
    menu_bar = XmCreateMenuBar(form, "menu_bar", al, ac);
    XtManageChild(menu_bar);

    /* create a textshow widget and attach it to the form. */
    ac = 0;
    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET);
    ac++;
    XtSetArg(al[ac], XmNtopWidget, menu_bar);
    ac++;
    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM);
    ac++;
    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_POSITION);
    ac++;
    XtSetArg(al[ac], XmNleftPosition, 0);
    ac++;
    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_POSITION);
    ac++;
    XtSetArg(al[ac], XmNbottomPosition, 93);
    ac++;
    XtSetArg(al[ac], XmNeditMode, XmMULTI_LINE_EDIT);
    ac++;
    textshow = XmCreateScrolledText(form, "text", al, ac);
    XtManageChild(textshow);
    XmTextSetEditable(textshow, False);

    Create_menus(menu_bar); 

    XtAppAddTimeOut(context,
		    950,
		    (XtTimerCallbackProc) timer_callback,
		    (XtPointer) NULL);

    XtRealizeWidget(toplevel);
    XtAppMainLoop(context);

    return (0);
}
예제 #2
0
int main(int argc, char **argv)
{
	u_int in_p, mode_p, op_p, in_c, mode_c, op_c;
	SIM_permu_t permu;
	double Emax, Etmp;
	u_int d_tab[150];
	u_int64_t cnt;
	int model;

	if (argc < 2) {
		printf("usage: test_permu <model>\n");
		//fprintf(stderr, "usage: test_permu <model>\n");
		exit(1);
	}

	model = atoi(argv[1]);
	if (!(model && model < PERMU_MAX_MODEL)) {
		fprintf(stderr, "invalid model %d\n", model);
		exit(1);
	}

	SIM_init();
	SIM_permu_init(&permu, model, 8);
	Emax = SIM_permu_max_energy(&permu);
	printf("%g\n", Emax);
	SIM_permu_init(&permu, model, 16);
	Emax = SIM_permu_max_energy(&permu);
	printf("%g\n", Emax);
	SIM_permu_init(&permu, model, 32);
	Emax = SIM_permu_max_energy(&permu);
	printf("%g\n", Emax);
	SIM_permu_init(&permu, model, 64);
	Emax = SIM_permu_max_energy(&permu);
	printf("%g\n", Emax);
	exit(0);

	memset(d_tab, 0, 150 * sizeof(u_int));

	switch (model) {
		case OMFLIP_PERMU:
			for (in_p = 0; in_p < 256; in_p ++)
				for (op_p = 0; op_p < 256; op_p ++)
					for (mode_p = 0; mode_p < 4; mode_p ++) {
						SIM_permu_record(&permu, in_p, mode_p, op_p, 0);

						for (in_c = 0; in_c < 256; in_c ++)
							for (op_c = 0; op_c < 256; op_c ++) {
								SIM_permu_record_test(&permu, in_c, 0, op_c);
								Etmp = SIM_permu_report(&permu);
								d_tab[(u_int)ceil(Etmp / Emax * 100)] ++;

								SIM_permu_record_test(&permu, in_c, 1, op_c);
								Etmp = SIM_permu_report(&permu);
								d_tab[(u_int)ceil(Etmp / Emax * 100)] ++;

								SIM_permu_record_test(&permu, in_c, 2, op_c);
								Etmp = SIM_permu_report(&permu);
								d_tab[(u_int)ceil(Etmp / Emax * 100)] ++;

								SIM_permu_record_test(&permu, in_c, 3, op_c);
								Etmp = SIM_permu_report(&permu);
								d_tab[(u_int)ceil(Etmp / Emax * 100)] ++;
							}
					}
			break;

		case GRP_PERMU:
			for (in_p = 0; in_p < 256; in_p ++)
				for (op_p = 0; op_p < 256; op_p ++) {
					SIM_permu_record(&permu, in_p, 0, op_p, 0);

					for (in_c = 0; in_c < 256; in_c ++)
						for (op_c = 0; op_c < 256; op_c ++) {
							SIM_permu_record_test(&permu, in_c, 0, op_c);
							Etmp = SIM_permu_report(&permu);
							d_tab[(u_int)ceil(Etmp / Emax * 100)] ++;
						}
				}
			break;
	}

	/* print stat */
	for (cnt = 0, in_p = 0; in_p < 150; in_p ++) {
		printf("%d\n", d_tab[in_p]);
		cnt += d_tab[in_p];
	}
	printf("total: %lu\n", cnt);

	exit(0);
}
예제 #3
0
파일: skyeye.c 프로젝트: manasdas17/skyeye
int
main (int argc, char **argv)
{
	int ret;

	sky_pref_t* pref = get_skyeye_pref();
	assert(pref != NULL);	
	/* initialization of options from command line */
	ret = init_option(argc, argv, pref);
	/* set the current preference for skyeye */
	//update_skyeye_pref(pref);
	/* return non-zero represent not run skyeye */
	if(ret != 0)
		exit(0);
	else
		SIM_init();
	/* Do anything you want to do , or just deadloop here. */
	while(1)
	;
#if 0
	if(ret < 0)
		goto exit_skyeye;

	/* set some environment for running */
	init_env();

	/* initialization of all the data structure of simulation */
	if((ret = init ()) < 0)
		goto exit_skyeye;
#endif

#if 0
	/* load elf file when running elf image */
	if (exec_file) {
		if (tea_load_exec (exec_file, 0)) {
			fprintf (stderr, "load \"%s\" error\n", exec_file);
			goto exit_skyeye;
		}
#if !defined(__MINGW32__)
		/* get its symbol to debug */
		init_symbol_table(exec_file);
#endif
	}
#endif
	/* set the start address for pc */
#if 0
	if (skyeye_config.start_address != 0){
		unsigned long addr = (skyeye_config.start_address & load_mask)|load_base;
		arch_instance->set_pc (addr);
		printf ("start addr is set to 0x%08x by exec file.\n",
                        (unsigned int) addr);

	}
#endif
	/* never return */
	//SIM_start();
	//fflush(stdout);
    
#if 0
	/* running simulaion */ 
	if (remote_debugmode == 0)
		sim_resume (0);
	else{	
		printf ("remote_debugmode= %d, filename = %s, server TCP port is 12345\n",
			remote_debugmode, skyeye_config_filename);
		sim_debug ();
	}
#endif
exit_skyeye:
	return ret;
}