/* control multiple files */ int main(int argc, char *argv[]) { int ch; prgname = argv[0]; while ((ch = getopt(argc, argv, "OT:VW:X:Z:f:gklm:psvwx:")) != -1) switch (ch) { #if !defined(MULTIPASS) || defined(PASS1) case 'X': while (*optarg) switch (*optarg++) { case 'd': ++ddebug; break; /* declarations */ case 'i': ++idebug; break; /* initializations */ case 'b': ++bdebug; break; case 't': ++tdebug; break; case 'e': ++edebug; break; /* pass1 exit */ case 'x': ++xdebug; break; /* MD code */ case 's': ++sdebug; break; case 'n': ++nflag; break; case 'o': ++oflag; break; case 'p': ++pdebug; break; /* prototype */ default: fprintf(stderr, "unknown X flag '%c'\n", optarg[-1]); exit(1); } #endif break; #if !defined(MULTIPASS) || defined(PASST) case 'T': while (*optarg) switch (*optarg++) { case 'i': ++iTflag; break; case 'o': ++oTflag; break; case 'n': ++nflag; break; default: fprintf(stderr, "unknown T flag '%c'\n", optarg[-1]); exit(1); } #endif break; #if !defined(MULTIPASS) || defined(PASS2) case 'Z': while (*optarg) switch (*optarg++) { case 'f': /* instruction matching */ ++f2debug; break; case 'e': /* print tree upon pass2 enter */ ++e2debug; break; case 'o': ++odebug; break; case 'r': /* register alloc/graph coloring */ ++rdebug; break; case 'b': /* basic block and SSA building */ ++b2debug; break; case 'c': /* code printout */ ++c2debug; break; case 't': ++t2debug; break; case 's': /* shape matching */ ++s2debug; break; case 'u': /* Sethi-Ullman debugging */ ++udebug; break; case 'x': ++x2debug; break; case 'n': ++nflag; break; default: fprintf(stderr, "unknown Z flag '%c'\n", optarg[-1]); exit(1); } #endif break; case 'f': /* Language */ fflags(optarg); break; case 'g': /* Debugging */ gflag = 1; break; case 'k': /* PIC code */ ++kflag; break; case 'l': /* Linenos */ ++lflag; break; case 'm': /* Target-specific */ mflags(optarg); break; case 'p': /* Profiling */ pflag = 1; break; case 's': /* Statistics */ ++sflag; break; case 'W': /* Enable different warnings */ Wflags(optarg); break; case 'x': /* Different optimizations */ if (strcmp(optarg, "ssa") == 0) xssaflag++; else if (strcmp(optarg, "tailcall") == 0) xtailcallflag++; else if (strcmp(optarg, "temps") == 0) xtemps++; else if (strcmp(optarg, "deljumps") == 0) xdeljumps++; else usage(); break; case 'v': printf("ccom: %s\n", VERSSTR); break; case '?': default: usage(); } argc -= optind; argv += optind; if (argc > 0 && strcmp(argv[0], "-") != 0) { if (freopen(argv[0], "r", stdin) == NULL) { fprintf(stderr, "open input file '%s':", argv[0]); perror(NULL); exit(1); } } if (argc > 1 && strcmp(argv[1], "-") != 0) { if (freopen(argv[1], "w", stdout) == NULL) { fprintf(stderr, "open output file '%s':", argv[1]); perror(NULL); exit(1); } } mkdope(); signal(SIGSEGV, segvcatch); fregs = FREGS; /* number of free registers */ lineno = 1; #ifdef GCC_COMPAT gcc_init(); #endif /* dimension table initialization */ btdims[VOID].suesize = 0; btdims[BOOL].suesize = SZBOOL; btdims[CHAR].suesize = SZCHAR; btdims[INT].suesize = SZINT; btdims[FLOAT].suesize = SZFLOAT; btdims[DOUBLE].suesize = SZDOUBLE; btdims[LDOUBLE].suesize = SZLDOUBLE; btdims[LONG].suesize = SZLONG; btdims[LONGLONG].suesize = SZLONGLONG; btdims[SHORT].suesize = SZSHORT; btdims[UCHAR].suesize = SZCHAR; btdims[USHORT].suesize = SZSHORT; btdims[UNSIGNED].suesize = SZINT; btdims[ULONG].suesize = SZLONG; btdims[ULONGLONG].suesize = SZLONGLONG; btdims[FCOMPLEX].suesize = SZFLOAT * 2; btdims[COMPLEX].suesize = SZDOUBLE * 2; btdims[LCOMPLEX].suesize = SZLDOUBLE * 2; /* starts past any of the above */ reached = 1; bjobcode(); #ifdef STABS if (gflag) { stabs_file(argc ? argv[0] : ""); stabs_init(); } #endif if (sspflag) sspinit(); (void) yyparse(); yyaccpt(); if (!nerrors) lcommprint(); ejobcode( nerrors ? 1 : 0 ); if (sflag) prtstats(); return(nerrors?1:0); }
/* control multiple files */ int main(int argc, char *argv[]) { int ch; #ifdef TIMING struct timeval t1, t2; (void)gettimeofday(&t1, NULL); #endif prgname = argv[0]; while ((ch = getopt(argc, argv, "OT:VW:X:Z:f:gkm:psvwx:")) != -1) { switch (ch) { #if !defined(MULTIPASS) || defined(PASS1) case 'X': /* pass1 debugging */ while (*optarg) switch (*optarg++) { case 'b': ++bdebug; break; /* buildtree */ case 'd': ++ddebug; break; /* declarations */ case 'e': ++edebug; break; /* pass1 exit */ case 'i': ++idebug; break; /* initializations */ case 'n': ++ndebug; break; /* node allocation */ case 'o': ++odebug; break; /* optim */ case 'p': ++pdebug; break; /* prototype */ case 's': ++sdebug; break; /* inline */ case 't': ++tdebug; break; /* type match */ case 'x': ++xdebug; break; /* MD code */ default: fprintf(stderr, "unknown -X flag '%c'\n", optarg[-1]); exit(1); } break; #endif #if !defined(MULTIPASS) || defined(PASS2) case 'Z': /* pass2 debugging */ while (*optarg) switch (*optarg++) { case 'b': /* basic block and SSA building */ ++b2debug; break; case 'c': /* code printout */ ++c2debug; break; case 'e': /* print tree upon pass2 enter */ ++e2debug; break; case 'f': /* instruction matching */ ++f2debug; break; case 'g': /* print flow graphs */ ++g2debug; break; case 'n': /* node allocation */ ++ndebug; break; case 'o': /* instruction generator */ ++o2debug; break; case 'r': /* register alloc/graph coloring */ ++r2debug; break; case 's': /* shape matching */ ++s2debug; break; case 't': /* type matching */ ++t2debug; break; case 'u': /* Sethi-Ullman debugging */ ++u2debug; break; case 'x': /* target specific */ ++x2debug; break; default: fprintf(stderr, "unknown -Z flag '%c'\n", optarg[-1]); exit(1); } break; #endif case 'f': /* Language */ fflags(optarg); break; case 'g': /* Debugging */ ++gflag; break; case 'k': /* PIC code */ ++kflag; break; case 'm': /* Target-specific */ mflags(optarg); break; case 'p': /* Profiling */ ++pflag; break; case 's': /* Statistics */ ++sflag; break; case 'W': /* Enable different warnings */ Wflags(optarg); break; case 'x': /* Different settings */ xopt(optarg); break; case 'v': printf("ccom: %s\n", VERSSTR); break; case '?': default: usage(); } } argc -= optind; argv += optind; if (argc > 0 && strcmp(argv[0], "-") != 0) { if (freopen(argv[0], "r", stdin) == NULL) { fprintf(stderr, "open input file '%s':", argv[0]); perror(NULL); exit(1); } } if (argc > 1 && strcmp(argv[1], "-") != 0) { if (freopen(argv[1], "w", stdout) == NULL) { fprintf(stderr, "open output file '%s':", argv[1]); perror(NULL); exit(1); } } mkdope(); signal(SIGSEGV, segvcatch); #ifdef SIGBUS signal(SIGBUS, segvcatch); #endif fregs = FREGS; /* number of free registers */ lineno = 1; #ifdef GCC_COMPAT gcc_init(); #endif /* starts past any of the above */ reached = 1; bjobcode(); #ifndef TARGET_VALIST { NODE *p = block(NAME, NIL, NIL, PTR|CHAR, NULL, 0); struct symtab *sp = lookup(addname("__builtin_va_list"), 0); p->n_sp = sp; defid(p, TYPEDEF); nfree(p); } #endif complinit(); #ifdef STABS if (gflag) { stabs_file(argc ? argv[0] : ""); stabs_init(); } #endif if (sspflag) sspinit(); (void) yyparse(); yyaccpt(); if (!nerrors) lcommprint(); #ifdef STABS if (gflag) stabs_efile(argc ? argv[0] : ""); #endif ejobcode( nerrors ? 1 : 0 ); #ifdef TIMING (void)gettimeofday(&t2, NULL); t2.tv_sec -= t1.tv_sec; t2.tv_usec -= t1.tv_usec; if (t2.tv_usec < 0) { t2.tv_usec += 1000000; t2.tv_sec -= 1; } fprintf(stderr, "ccom total time: %ld s %ld us\n", t2.tv_sec, t2.tv_usec); #endif if (sflag) prtstats(); return(nerrors?1:0); }
i4 main( i4 argc, char **argv ) { STATUS generic_status = OK; CL_ERR_DESC system_status; EX_CONTEXT context; STATUS status; GCC_ERLIST erlist; STATUS (*call_list[7])(); i4 i, call_count; i4 cmd_args = 0; char usage[] = { "Usage: iigcb -from <protocol>" }; char usage1[] = { " -to <protocol> <hostname> < listen_address>" }; #ifdef LNX PCsetpgrp(); #endif MEfill( sizeof( system_status ), 0, (PTR)&system_status ); MEadvise( ME_INGRES_ALLOC ); EXdeclare( GCX_exit_handler, &context ); SIeqinit(); /* ** Parse command line. */ for( i = 1; i < argc; i++ ) if ( ! STcompare( argv[i], "-from" ) ) { if ( ++i >= argc ) { SIfprintf( stderr, "\n%s%s\n\n", usage, usage1 ); SIflush( stderr ); SIstd_write(SI_STD_OUT, "\nFAIL\n"); EXdelete(); PCexit( FAIL ); } STcopy( argv[i], gcb_from_addr.n_sel ); CVupper( gcb_from_addr.n_sel ); ++cmd_args; } else if ( ! STcompare( argv[ i ], "-to" ) ) { if ( (i + 3) >= argc ) { SIfprintf( stderr, "\n%s%s\n\n", usage, usage1 ); SIflush( stderr ); SIstd_write(SI_STD_OUT, "\nFAIL\n"); EXdelete(); PCexit( FAIL ); } STcopy( argv[ ++i ], gcb_to_addr.n_sel ); STcopy( argv[ ++i ], gcb_to_addr.node_id ); STcopy( argv[ ++i ], gcb_to_addr.port_id ); CVupper( gcb_to_addr.n_sel ); ++cmd_args; } if ( cmd_args ) if ( cmd_args == 2 ) gcb_pm_reso.cmd_line = TRUE; else { SIfprintf( stderr, "\n%s%s\n\n", usage, usage1 ); SIflush( stderr ); SIstd_write(SI_STD_OUT, "\nFAIL\n"); EXdelete(); PCexit( FAIL ); } /* ** Perform general initialization. The bridge may be run ** for async lines as a part of Ingres/Net. Otherwise, ** Bridge authorization is required. */ if ( gcb_pm_reso.cmd_line && ! STcasecmp( gcb_from_addr.n_sel, ERx("async") ) ) status = gcc_init( FALSE, CI_INGRES_NET, argc, argv, &generic_status, &system_status ); else { #ifdef CI_INGRES_BRIDGE status = gcc_init( FALSE, CI_INGRES_BRIDGE, argc, argv, &generic_status, &system_status ); #else generic_status = E_GC2A0F_NO_AUTH_BRIDGE; status = FAIL; #endif } if ( status != OK ) { gcc_er_log( &generic_status, &system_status, NULL, NULL ); generic_status = E_GC2A01_INIT_FAIL; gcc_er_log( &generic_status, NULL, NULL, NULL ); SIstd_write(SI_STD_OUT, "\nFAIL\n"); EXdelete(); PCexit( FAIL ); } /* ** Perform standalong Bridge Server initialization. */ IIGCc_global->gcc_flags |= GCC_STANDALONE; gcb_init_mib(); /* ** Initialize the protocol layers. */ call_list[0] = GCcinit; call_list[1] = gcb_alinit; call_list[2] = gcc_pbinit; call_count = 3; if ( gcc_call( &call_count, call_list, &generic_status, &system_status ) != OK ) { gcc_er_log( &generic_status, &system_status, NULL, NULL ); generic_status = E_GC2A01_INIT_FAIL; gcc_er_log( &generic_status, NULL, NULL, NULL ); SIstd_write(SI_STD_OUT, "\nFAIL\n"); } else { { /* ** Obtain and fix up the configuration name, then log it. */ char server_flavor[256], server_type[32]; char *tmpbuf = PMgetDefault(3); if (!STbcompare( tmpbuf, 0, "*", 0, TRUE )) STcopy("(DEFAULT)", server_flavor); else STcopy(tmpbuf, server_flavor); STcopy(PMgetDefault(2), server_type); CVupper(server_type); erlist.gcc_parm_cnt = 2; erlist.gcc_erparm[0].value = server_flavor; erlist.gcc_erparm[0].size = STlength(server_flavor); erlist.gcc_erparm[1].value = server_type; erlist.gcc_erparm[1].size = STlength(server_type); generic_status = E_GC2A10_LOAD_CONFIG; gcc_er_log( &generic_status, (CL_ERR_DESC *)NULL, (GCC_MDE *)NULL, &erlist); } erlist.gcc_parm_cnt = 1; erlist.gcc_erparm[0].size = STlength( IIGCc_rev_lvl ); erlist.gcc_erparm[0].value = IIGCb_rev_lvl; generic_status = E_GC2A03_STARTUP; gcc_er_log( &generic_status, NULL, NULL, &erlist ); /* ** Invoke GCexec to enter the main phase of Protocol bridge ** execution. GCexec does not return until bridge shutdown ** is initiated by invoking GCshut. */ GCexec(); generic_status = E_GC2A04_SHUTDOWN; gcc_er_log( &generic_status, &system_status, NULL, NULL ); } /* ** GCexec has returned. Bridge shutdown is in process. ** Initialize the call list to specify termination rotutines. ** Call in reverse order of initialization but don't call ** termination routines whose initialization routines were ** not called (call_count has the number of successful ** initialization calls). */ call_list[0] = gcb_alterm; call_list[1] = gcc_pbterm; call_list[2] = GCcterm; if ( gcc_call( &call_count, &call_list[ 3 - call_count ], &generic_status, &system_status ) ) gcc_er_log( &generic_status, &system_status, NULL, NULL ); /* ** Do general server termination. */ if ( gcc_term( &generic_status, &system_status ) != OK ) gcc_er_log( &generic_status, &system_status, NULL, NULL ); EXdelete(); PCexit( OK ); } /* end main */