static void srec_init () { static boolean inited = false; if (inited == false) { inited = true; hex_init (); } }
static void ihex_init () { static boolean inited; if (! inited) { inited = true; hex_init (); } }
static void ihex_init () { static bfd_boolean inited; if (! inited) { inited = TRUE; hex_init (); } }
static void srec_init () { static bfd_boolean inited = FALSE; if (! inited) { inited = TRUE; hex_init (); } }
/* Initialization of the front end environment, before command line options are parsed. Signal handlers, internationalization etc. ARGV0 is main's argv[0]. */ static void general_init (const char *argv0) { const char *p; p = argv0 + strlen (argv0); while (p != argv0 && !IS_DIR_SEPARATOR (p[-1])) --p; progname = p; xmalloc_set_program_name (progname); hex_init (); gcc_init_libintl (); line_table = XNEW (struct line_maps); linemap_init (line_table); line_table->reallocator = xrealloc; }
void general_init(const char *argv0) { const char *p; p = argv0 + strlen(argv0); while(p != argv0 && !IS_DIR_SEPARATOR(p[-1])) --p; progname = p; xmalloc_set_program_name(progname); hex_init(); /* Unlock the stdio streams. */ unlock_std_streams(); gcc_init_libintl(); /* Initialize the diagnostics reporting machinery, so option parsing can give warnings and errors. */ diagnostic_initialize(global_dc); /* Set a default printer. Language specific initializations will override it later. */ pp_format_decoder(global_dc->printer) = &default_tree_printer; /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */ #ifdef SIGSEGV signal(SIGSEGV, crash_signal); #endif #ifdef SIGILL signal(SIGILL, crash_signal); #endif #ifdef SIGBUS signal(SIGBUS, crash_signal); #endif #ifdef SIGABRT signal(SIGABRT, crash_signal); #endif #if defined SIGIOT &&(!defined SIGABRT || SIGABRT != SIGIOT) signal(SIGIOT, crash_signal); #endif #ifdef SIGFPE signal(SIGFPE, crash_signal); #endif /* Other host-specific signal setup. */ (*host_hooks.extra_signals)(); /* Initialize the garbage-collector, string pools and tree type hash table. */ init_ggc(); init_stringpool(); linemap_init(&line_table); init_ttree(); /* Initialize register usage now so switches may override. */ init_reg_sets(); /* Register the language-independent parameters. */ add_params(lang_independent_params, LAST_PARAM); /* This must be done after add_params but before argument processing. */ init_ggc_heuristics(); init_optimization_passes(); }
int assemble(void) { char *pc; struct symbol_table *cmd_defines; /* store the command line defines to restore on second pass */ cmd_defines = state.stDefines; state.c_memory = state.i_memory = i_memory_create(); if(state.basefilename[0] == '\0') { strcpy(state.basefilename, state.srcfilename); pc = strrchr(state.basefilename, '.'); if (pc) *pc = 0; } /* Builtins are always case insensitive */ state.stBuiltin = push_symbol_table(NULL, 1); state.stDirective = state.stBuiltin; state.stMacros = push_symbol_table(NULL, state.case_insensitive); state.stTop = state.stGlobal = push_symbol_table(NULL, state.case_insensitive); state.stTopDefines = state.stDefines = push_symbol_table(cmd_defines, state.case_insensitive); opcode_init(0); /* the tables are built, select the processor if -p was used */ if (cmd_processor) { select_processor(processor_name); state.cmd_line.processor = 1; } state.pass = 1; open_src(state.srcfilename, 0); yyparse(); state.pass++; state.org = 0; state.cblock = 0; /* clean out defines for second pass */ state.stTopDefines = state.stDefines = push_symbol_table(cmd_defines, state.case_insensitive); if (state.cmd_line.radix != 1) state.radix = 16; state.obj.symbol_num = 0; state.obj.section_num = 0; state.obj.org_num = 0; state.found_config = 0; state.found_devid = 0; state.found_idlocs = 0; coff_init(); cod_init(); lst_init(); open_src(state.srcfilename, 0); yyparse(); assert(state.pass == 2); pop_symbol_table(state.stBuiltin); hex_init(); if(state.memory_dump) print_i_memory(state.i_memory, state.device.class == PROC_CLASS_PIC16E ? 1 : 0); /* Maybe produce a symbol table */ if (state.lst.symboltable) { lst_throw(); /* Start symbol table on a fresh page */ lst_symbol_table(state.stGlobal); lst_defines_table(state.stDefines); } /* Maybe produce a memory map */ if ((state.mode == absolute) && (state.lst.memorymap)) { lst_memory_map(state.i_memory); } /* Finish off the object, listing, and symbol files*/ coff_close_file(); lst_close(); if (state.processor_info) cod_close_file(); free_files(); if ((state.num.errors > 0) || (gp_num_errors > 0)) return EXIT_FAILURE; else return EXIT_SUCCESS; }
t_pos *read_file(char *file) { int size, x, y, ry, p, inctile; char line[MAX_LINE_SIZE]; t_pos *ret = (t_pos *) malloc(sizeof(t_pos)); t_hex *hex = &ret->hex; t_tiles *tiles = &ret->tiles; t_done *done = &ret->done; FILE *input; tiles_init(tiles); input = fopen(file, "rb"); if (input == NULL) { free(ret); return NULL; } fgets(line, MAX_LINE_SIZE, input); sscanf(line, "%d", &size); hex_init(hex, size); done_init(done, hex->count); for (y = 0; y < size; ++y) { if (fgets(line, MAX_LINE_SIZE, input) == NULL) { printf("ERROR READING LINE %d!\n", y); free(ret); return NULL; } p = size - 1 - y; for (x = 0; x < size + y; ++x) { char *tile = line + p; p += 2; inctile = 0; if (tile[1] == '.') { inctile = 7; } else { inctile = tile[1] - '0'; } if (tile[0] == '+') { printf("Adding locked tile: %d at pos %d, %d, id=%d\n", inctile, x, y, get_by_pos(hex, make_point(x, y))->id); add_done(done, get_by_pos(hex, make_point(x, y))->id, inctile); } else { (*tiles)[inctile] += 1; } } } for (y = 1; y < size; ++y) { ry = size - 1 + y; if (fgets(line, MAX_LINE_SIZE, input) == NULL) { printf("ERROR READING LINE %d!\n", ry); free(ret); return NULL; } p = y; for (x = y; x < 2 * size - 1; ++x) { char *tile = line + p; p += 2; inctile = 0; if (tile[1] == '.') { inctile = 7; } else { inctile = tile[1] - '0'; } if (tile[0] == '+') { printf("Adding locked tile: %d at pos %d, %d, id=%d\n", inctile, x, ry, get_by_pos(hex, make_point(x, ry))->id); add_done(done, get_by_pos(hex, make_point(x, ry))->id, inctile); } else { (*tiles)[inctile] += 1; } } } fclose(input); pos_init(ret); link_nodes(hex); return ret; }