Пример #1
0
Файл: main.c Проект: 17twenty/go
int main(void) {
	int32_t res;

	int r1 = install_handler();
	if (r1!=0) {
		return r1;
	}

	if (!DidInitRun()) {
		fprintf(stderr, "ERROR: buildmode=c-archive init should run\n");
		return 2;
	}

	if (DidMainRun()) {
		fprintf(stderr, "ERROR: buildmode=c-archive should not run main\n");
		return 2;
	}

	int r2 = check_handler();
	if (r2!=0) {
		return r2;
	}

	res = FromPkg();
	if (res != 1024) {
		fprintf(stderr, "ERROR: FromPkg()=%d, want 1024\n", res);
		return 2;
	}

	CheckArgs();

	fprintf(stderr, "PASS\n");
	return 0;
}
Пример #2
0
int main(void) {
	struct sigaction sa;
	struct sigaction osa;
	int32_t res;

	// Install our own signal handler.
	memset(&sa, 0, sizeof sa);
	sa.sa_sigaction = handler;
	sigemptyset(&sa.sa_mask);
	sa.sa_flags = SA_ONSTACK | SA_SIGINFO;
	memset(&osa, 0, sizeof osa);
	sigemptyset(&osa.sa_mask);
	if (sigaction(SIGSEGV, &sa, &osa) < 0) {
		perror("sigaction");
		return 2;
	}
	if (osa.sa_handler == SIG_DFL || (osa.sa_flags&SA_ONSTACK) == 0) {
		fprintf(stderr, "Go runtime did not install signal handler\n");
		return 2;
	}
	oldHandler = osa.sa_sigaction;

	if (!DidInitRun()) {
		fprintf(stderr, "ERROR: buildmode=c-archive init should run\n");
		return 2;
	}

	if (DidMainRun()) {
		fprintf(stderr, "ERROR: buildmode=c-archive should not run main\n");
		return 2;
	}

	// Make sure our signal handler is still the one in use.
	if (sigaction(SIGSEGV, NULL, &sa) < 0) {
		perror("sigaction check");
		return 2;
	}
	if (sa.sa_sigaction != handler) {
		fprintf(stderr, "ERROR: wrong signal handler: %p != %p\n", sa.sa_sigaction, handler);
		return 2;
	}

	res = FromPkg();
	if (res != 1024) {
		fprintf(stderr, "ERROR: FromPkg()=%d, want 1024\n", res);
		return 2;
	}

	CheckArgs();

	fprintf(stderr, "PASS\n");
	return 0;
}
Пример #3
0
int main(void) {
	int32_t res;

	if (DidMainRun()) {
		fprintf(stderr, "ERROR: buildmode=c-archive should not run main\n");
		return 2;
	}

	if (!DidInitRun()) {
		fprintf(stderr, "ERROR: buildmode=c-archive init should run\n");
		return 2;
	}

	res = FromPkg();
	if (res != 1024) {
		fprintf(stderr, "ERROR: FromPkg()=%d, want 1024\n", res);
		return 2;
	}

	return 0;
}