Exemple #1
0
int cc1main(struct STR_CC1MAIN *str_cc1main)
{
//	static char execflag = 0;
	int argc;
	UCHAR **argv;
	UCHAR **argv1, **p;
	GO_stdout.p0 = GO_stdout.p = str_cc1main->dest0;
	GO_stdout.p1 = str_cc1main->dest1;
	GO_stdout.dummy = ~0;
	GO_stderr.p0 = GO_stderr.p = str_cc1main->err0;
	GO_stderr.p1 = str_cc1main->err1;
	GO_stderr.dummy = ~0;

	/* 多重実行阻止 (staticを再初期化すればできるが) */
//	if (execflag)
//		return 7;
//	execflag = 1;

	if (setjmp(setjmp_env)) {
		str_cc1main->dest0 = GO_stdout.p;
		str_cc1main->err0 = GO_stderr.p;
		return GOL_abortcode;
	}

	if (str_cc1main->work1 - str_cc1main->work0 < SYSWORK_SIZE * 2)
		return GO_TERM_WORKOVER;
	GOL_memmaninit(&GOL_sysman, SYSWORK_SIZE, str_cc1main->work0);
	GOL_memmaninit(&GOL_memman, str_cc1main->work1 - str_cc1main->work0 - SYSWORK_SIZE,
		str_cc1main->work0 + SYSWORK_SIZE);
	argv = ConvCmdLine1(&argc, str_cc1main->cmdlin);
	p = argv1 = GOL_sysmalloc((argc + 1) * sizeof (char *));
	for (;;) {
		if ((*p = *argv) == NULL)
			break;
		if ((*argv)[0] == '-' && (*argv)[1] == 'o') {
			str_cc1main->outname = &((*argv)[2]);
			if ((*argv)[2] == '\0') {
				if (argv[1] != NULL)
					str_cc1main->outname = (argv++)[1];
			}
			p--;  /* delete -o */
		}
		p++;
		argv++;
	}
	str_cc1main->errcode = main1(p - argv1, argv1);
	GOL_sysabort(GO_TERM_NORMAL);
}
Exemple #2
0
int main(int argc, UCHAR **argv)
/* かならず、-oオプションを付ける */
/* ここで、-oオプションは剥ぎ取られる */
/* しかし入力ファイル名は書く(標準入力ではsizeが測定できないため) */
{
	struct bss_alloc *bss0;
	UCHAR **argv1, **p;
	bss0 = (struct bss_alloc *) malloc(sizeof (struct bss_alloc));
	GO_stdout.p0 = GO_stdout.p = bss0->_stdout;
	GO_stdout.p1 = GO_stdout.p0 + SIZ_STDOUT;
	GO_stdout.dummy = ~0;
	GO_stderr.p0 = GO_stderr.p = bss0->_stderr;
	GO_stderr.p1 = GO_stderr.p0 + (SIZ_STDERR - 128); /* わざと少し小さくしておく */
	GO_stderr.dummy = ~0;
	GOL_memmaninit(&GOL_sysman, SIZ_SYSWRK, bss0->syswrk);
	GOL_memmaninit(&GOL_memman, SIZ_WORK, GOL_work0 = bss0->work);
	GOL_callmain(argc, argv);
	return 0; /* ダミー */
}
void mainCRTStartup(void)
/* Sure, I put the -o options */
/* Here, -o option is stripped */
/* But (because the size can not be measured in the standard input) The name of the input file write */
{
	struct bss_alloc bss_image;
	struct bss_alloc *bss0 = (void *) ((((int) &bss_image) + 0x0f) & ~0x0f); /* 对齐 */

	/* 下面是给标准输出分配空间 */
	GO_stdout.p0 = GO_stdout.p = bss0->_stdout;
	GO_stdout.p1 = GO_stdout.p0 + SIZ_STDOUT;
	GO_stdout.dummy = ~0;
	GO_stderr.p0 = GO_stderr.p = bss0->_stderr;
	GO_stderr.p1 = GO_stderr.p0 + (SIZ_STDERR - 128); /* I keep a little smaller on purpose */
	GO_stderr.dummy = ~0;

	/* 这里使用的是自己的一套内存分配函数,具体可以参照go_lib相关代码。 */
	GOL_memmaninit(&GOL_sysman, SIZ_SYSWRK, bss0->syswrk);
	GOL_memmaninit(&GOL_memman, SIZ_WORK, GOL_work0 = bss0->work);
	
	/* 调用下一步的主函数 */
	GOL_callmain0();
}
Exemple #4
0
int obj2bim_main(struct STR_OBJ2BIM *params)
{
//	static char execflag = 0;
	int argc;
	UCHAR **argv, *tmp0;
	UCHAR **argv1, **p;
	GO_stdout.p0 = GO_stdout.p = params->map0;
	GO_stdout.p1 = params->map1; /* stdoutはmap */
	GO_stdout.dummy = ~0;
	GO_stderr.p0 = GO_stderr.p = params->err0;
	GO_stderr.p1 = params->err1;
	GO_stderr.dummy = ~0;

	/* 多重実行阻止 (staticを再初期化すればできるが) */
//	if (execflag)
//		return 7;
//	execflag = 1;

	if (setjmp(setjmp_env)) {
		params->err0 = GO_stderr.p;
		return GOL_abortcode;
	}

	if (params->work1 - params->work0 < SIZ_SYSWRK + 16 * 1024)
		return GO_TERM_WORKOVER;
	GOL_memmaninit(&GOL_sysman, SIZ_SYSWRK, params->work0);
	GOL_memmaninit(&GOL_memman, params->work1 - params->work0 - SIZ_SYSWRK, params->work0 + SIZ_SYSWRK);
	argv = ConvCmdLine1(&argc, params->cmdlin);

	params->errcode = main0(argc, argv, params);
	params->map0 = GO_stdout.p;

skip:
	/* バッファを出力 */
	GOL_sysabort(0);
}
Exemple #5
0
int main(int argc, UCHAR **argv)
{
	struct bss_alloc *bss0 = (struct bss_alloc *) malloc(sizeof (struct bss_alloc));
	GO_stdout.p0 = GO_stdout.p = bss0->_stdout;
	GO_stdout.p1 = GO_stdout.p0 + SIZ_STDOUT;
	GO_stdout.dummy = ~0;
	GO_stderr.p0 = GO_stderr.p = bss0->_stderr;
	GO_stderr.p1 = GO_stderr.p0 + (SIZ_STDERR - 128); /* わざと少し小さくしておく */
	GO_stderr.dummy = ~0;
//	GOL_memmaninit(&GOL_sysman, SIZ_SYSWRK, bss0->syswrk);
	GOL_memmaninit(&GOL_memman, SIZ_WORK, GOL_work0 = bss0->work);

	GOL_retcode = main1(argc, argv, bss0->work1);
	/* バッファを出力 */
	GOL_sysabort(0);
	return 0; /* ダミー */
}