static int real_main2 (int argc, TCHAR **argv) { #ifdef USE_SDL int result = (SDL_Init (SDL_INIT_TIMER | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) == 0); if (result) atexit (SDL_Quit); #endif set_config_changed (); if (restart_config[0]) { default_prefs (&currprefs, 0); fixup_prefs (&currprefs); } if (! graphics_setup ()) { write_log (_T("Graphics Setup Failed\n")); exit (1); } if (restart_config[0]) parse_cmdline_and_init_file (argc, argv); else currprefs = changed_prefs; // uae_inithrtimer (); if (!machdep_init ()) { write_log (_T("Machine Init Failed.\n")); restart_program = 0; return -1; } if (console_emulation) { consolehook_config (&currprefs); fixup_prefs (&currprefs); } if (! setup_sound ()) { write_log (_T("Sound driver unavailable: Sound output disabled\n")); currprefs.produce_sound = 0; } inputdevice_init (); changed_prefs = currprefs; no_gui = ! currprefs.start_gui; if (restart_program == 2) no_gui = 1; else if (restart_program == 3) no_gui = 0; restart_program = 0; if (! no_gui && currprefs.start_gui) { int err = gui_init (); currprefs = changed_prefs; set_config_changed (); if (err == -1) { write_log (_T("Failed to initialize the GUI\n")); return -1; } else if (err == -2) { return 1; } } memset (&gui_data, 0, sizeof gui_data); gui_data.cd = -1; gui_data.hd = -1; gui_data.md = -1; #ifdef NATMEM_OFFSET init_shm (); #endif #ifdef PICASSO96 picasso_reset (); #endif fixup_prefs (&currprefs); #ifdef RETROPLATFORM rp_fixup_options (&currprefs); #endif changed_prefs = currprefs; target_run (); /* force sound settings change */ currprefs.produce_sound = 0; savestate_init (); keybuf_init (); /* Must come after init_joystick */ memory_hardreset (2); memory_reset (); #ifdef AUTOCONFIG native2amiga_install (); #endif custom_init (); /* Must come after memory_init */ #ifdef SERIAL_PORT serial_init (); #endif DISK_init (); reset_frame_rate_hack (); init_m68k (); /* must come after reset_frame_rate_hack (); */ gui_update (); if (graphics_init ()) { #ifdef DEBUGGER setup_brkhandler (); if (currprefs.start_debugger && debuggable ()) activate_debugger (); #endif if (!init_audio ()) { if (sound_available && currprefs.produce_sound > 1) { write_log (_T("Sound driver unavailable: Sound output disabled\n")); } currprefs.produce_sound = 0; } start_program (); } return 0; }
static int real_main2 (int argc, TCHAR **argv) { #ifdef USE_SDL SDL_Init (SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE); #endif set_config_changed (); if (restart_config[0]) { default_prefs (&currprefs, true, 0); fixup_prefs (&currprefs, true); } if (! graphics_setup ()) { exit (1); } #ifdef NATMEM_OFFSET //preinit_shm (); #endif if (restart_config[0]) parse_cmdline_and_init_file (argc, argv); else currprefs = changed_prefs; if (!machdep_init ()) { restart_program = 0; return -1; } if (console_emulation) { consolehook_config (&currprefs); fixup_prefs (&currprefs, true); } if (! setup_sound ()) { write_log (_T("Sound driver unavailable: Sound output disabled\n")); currprefs.produce_sound = 0; } inputdevice_init (); changed_prefs = currprefs; no_gui = ! currprefs.start_gui; if (restart_program == 2) no_gui = 1; else if (restart_program == 3) no_gui = 0; restart_program = 0; if (! no_gui) { int err = gui_init (); currprefs = changed_prefs; set_config_changed (); if (err == -1) { write_log (_T("Failed to initialize the GUI\n")); return -1; } else if (err == -2) { return 1; } } memset (&gui_data, 0, sizeof gui_data); gui_data.cd = -1; gui_data.hd = -1; gui_data.md = (currprefs.cs_cd32nvram || currprefs.cs_cdtvram) ? 0 : -1; logging_init (); /* Yes, we call this twice - the first case handles when the user has loaded a config using the cmd-line. This case handles loads through the GUI. */ #ifdef NATMEM_OFFSET init_shm (); #endif #ifdef WITH_LUA uae_lua_init (); #endif #ifdef PICASSO96 picasso_reset (); #endif #if 0 #ifdef JIT if (!(currprefs.cpu_model >= 68020 && currprefs.address_space_24 == 0 && currprefs.cachesize)) canbang = 0; #endif #endif fixup_prefs (&currprefs, true); #ifdef RETROPLATFORM rp_fixup_options (&currprefs); #endif changed_prefs = currprefs; target_run (); /* force sound settings change */ currprefs.produce_sound = 0; savestate_init (); keybuf_init (); /* Must come after init_joystick */ memory_hardreset (2); memory_reset (); #ifdef AUTOCONFIG native2amiga_install (); #endif custom_init (); /* Must come after memory_init */ #ifdef SERIAL_PORT serial_init (); #endif DISK_init (); #ifdef WITH_PPC uae_ppc_reset(true); #endif reset_frame_rate_hack (); init_m68k (); /* must come after reset_frame_rate_hack (); */ gui_update (); if (graphics_init (true)) { setup_brkhandler (); if (currprefs.start_debugger && debuggable ()) activate_debugger (); if (!init_audio ()) { if (sound_available && currprefs.produce_sound > 1) { write_log (_T("Sound driver unavailable: Sound output disabled\n")); } currprefs.produce_sound = 0; } start_program (); } return 0; }
static int real_main2 (int argc, TCHAR **argv) { #ifdef USE_SDL SDL_Init (SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE); #endif config_changed = 1; if (restart_config[0]) { default_prefs (&currprefs, 0); fixup_prefs (&currprefs); } if (! graphics_setup ()) { exit (1); } #ifdef NATMEM_OFFSET preinit_shm (); #endif if (restart_config[0]) parse_cmdline_and_init_file (argc, argv); else currprefs = changed_prefs; if (!machdep_init ()) { restart_program = 0; return -1; } if (console_emulation) { consolehook_config (&currprefs); fixup_prefs (&currprefs); } if (! setup_sound ()) { write_log (L"Sound driver unavailable: Sound output disabled\n"); currprefs.produce_sound = 0; } inputdevice_init (); changed_prefs = currprefs; no_gui = ! currprefs.start_gui; if (restart_program == 2) no_gui = 1; else if (restart_program == 3) no_gui = 0; restart_program = 0; if (! no_gui) { int err = gui_init (); currprefs = changed_prefs; config_changed = 1; if (err == -1) { write_log (L"Failed to initialize the GUI\n"); return -1; } else if (err == -2) { return 1; } } logging_init (); /* Yes, we call this twice - the first case handles when the user has loaded a config using the cmd-line. This case handles loads through the GUI. */ #ifdef NATMEM_OFFSET init_shm (); #endif #ifdef JIT if (!(currprefs.cpu_model >= 68020 && currprefs.address_space_24 == 0 && currprefs.cachesize)) canbang = 0; #endif fixup_prefs (&currprefs); changed_prefs = currprefs; target_run (); /* force sound settings change */ currprefs.produce_sound = 0; #ifdef AUTOCONFIG rtarea_setup (); #endif #ifdef FILESYS rtarea_init (); uaeres_install (); hardfile_install (); #endif savestate_init (); #ifdef SCSIEMU scsi_reset (); scsidev_install (); #endif #ifdef SANA2 netdev_install (); #endif #ifdef UAESERIAL uaeserialdev_install (); #endif keybuf_init (); /* Must come after init_joystick */ #ifdef AUTOCONFIG expansion_init (); #endif #ifdef FILESYS filesys_install (); #endif memory_init (); memory_reset (); #ifdef AUTOCONFIG #if defined (BSDSOCKET) bsdlib_install (); #endif emulib_install (); uaeexe_install (); native2amiga_install (); #endif custom_init (); /* Must come after memory_init */ #ifdef SERIAL_PORT serial_init (); #endif DISK_init (); reset_frame_rate_hack (); init_m68k (); /* must come after reset_frame_rate_hack (); */ gui_update (); if (graphics_init ()) { setup_brkhandler (); if (currprefs.start_debugger && debuggable ()) activate_debugger (); if (!init_audio ()) { if (sound_available && currprefs.produce_sound > 1) { write_log (L"Sound driver unavailable: Sound output disabled\n"); } currprefs.produce_sound = 0; } start_program (); } return 0; }
int main(int argc, char* arg[]){ char* compiler; /* the compiler - from enviroment flag "DMD" */ char* cmd_arg_case; /* additional arguments - from the testcase file */ char* buffer; /* general purpose buffer */ size_t bufferLen; int index; int modus; /* test modus: RUN NORUN COMPILE NOCOMPILE */ char* case_file; int case_result; int torture_result[sizeof(torture)/sizeof(char*)]; char* torture_block_global; char* torture_block_case; char* torture_require; char* error_file; /* expected sourcefile containing the error */ char* error_line; /* expected error line */ char* gdb; /* the debugger - from environment flag "GDB" */ char* gdb_script; /* gdb command sequence */ char* gdb_pattern_raw; /* POSIX regexp expected in GDB's output */ #ifdef REG_EXTENDED regex_t* gdb_pattern; #endif compiler = NULL; cmd_arg_case = NULL; buffer = NULL; bufferLen = 0; modus = -1; case_file = NULL; torture_block_global = NULL; torture_block_case = NULL; torture_require = NULL; error_file = NULL; error_line = NULL; gdb = NULL; gdb_script = NULL; gdb_pattern_raw = NULL; #ifdef REG_EXTENDED gdb_pattern = NULL; #endif /* check arguments */ if(argc != 3){ err: fprintf(stderr, "DStress test executer (revision 1083)\n" "Copyright by Thomas Kuehne <*****@*****.**> 2005, 2006\n" "\n"); if(argc!=0){ fprintf(stderr, "%s <run|norun|compile|nocompile> <source>\n", arg[0]); }else{ fprintf(stderr, "dstress <run|norun|compile|nocompile>" " <source>\n"); } fprintf(stderr, "\n" "== eniroment settings (usually $NAME or %%NAME%%) ==\n" "* DMD - compiler (including standard arguments)\n" "* GDB - debugger (including standard arguments)\n"); fprintf(stderr, "\n" "== case setting (line in the case source) ==\n" "* __DSTRESS_DFLAGS__ - additional compiler arguments\n" "only evaluated if it is a \"nocompile\" or \"norun\" test:\n" "* __DSTRESS_ELINE__ - expected source line to throw an error message\n" "* __DSTRESS_EFILE__ - expected source file to throw an error message\n" " (defaults to the case file)\n"); fprintf(stderr, "only evaluated if it is a \"run\" or \"norun\" test:\n" "* __GDB_SCRIPT__ - command sequence to feed to the debugger\n" " (use \\n to encode a line break)\n" "* __GDB_PATTERN__ - expected regular expression in the debugger's\n" " output\n"); fprintf(stderr, "\n" "== note ==\n" "* the current directory is required to contain the sub-directory \"obj\"\n" " (used for temporary files)\n" ); exit(EXIT_FAILURE); } modus = 0; if(0==strncmp(arg[1], TORTURE_PREFIX, strlen(TORTURE_PREFIX))){ modus |= MODE_TORTURE; arg[1] += strlen(TORTURE_PREFIX); } if(0==strcmp(arg[1], "run")){ modus |= MODE_RUN; }else if(0==strcmp(arg[1], "norun")){ modus |= MODE_NORUN; }else if(0==strcmp(arg[1], "compile")){ modus |= MODE_COMPILE; }else if(0==strcmp(arg[1], "nocompile")){ modus |= MODE_NOCOMPILE; }else{ goto err; } /* gen flags */ case_file = cleanPathSeperator(arg[2]); compiler = getCompiler(); gdb = getGDB(); torture_block_global = getTortureBlock(); buffer = loadFile(case_file, &bufferLen); bufferLen = 0; cmd_arg_case = cleanPathSeperator(getCaseFlag(buffer, "__DSTRESS_DFLAGS__")); error_line = getCaseFlag(buffer, "__DSTRESS_ELINE__"); error_file = cleanPathSeperator(getCaseFlag(buffer, "__DSTRESS_EFILE__")); gdb_script = getCaseFlag(buffer, "__GDB_SCRIPT__"); gdb_pattern_raw = getCaseFlag(buffer, "__GDB_PATTERN__"); torture_block_case = getCaseFlag(buffer, "__DSTRESS_TORTURE_BLOCK__"); torture_require = getCaseFlag(buffer, "__DSTRESS_TORTURE_REQUIRE__"); free(buffer); /* tmp_dir */ if(!cmd_arg_case || !cmd_arg_case[0]){ tmp_dir = TMP_DIR; }else{ pid_t pid; pid = getpid(); bufferLen = strlen(TMP_DIR) + 4 + sizeof(pid_t) * 4; buffer = (char*) malloc(bufferLen); snprintf(buffer, bufferLen, "%s/_%X", TMP_DIR, pid); tmp_dir = cleanPathSeperator(buffer); if(mkdir(tmp_dir, 0770)){ fprintf(stderr, "failed to create tmp dir: %s (%d, %s)\n", tmp_dir, errno, strerror(errno)); return EXIT_FAILURE; } } /* set implicit source file */ if(strcmp(error_line, "")!=0 && strcmp(error_file, "")==0){ error_file=case_file; } /* gdb pattern */ #ifdef REG_EXTENDED if(gdb_pattern_raw!=NULL && gdb_pattern_raw[0]!='\x00'){ gdb_pattern = (regex_t*) malloc(sizeof(regex_t)); if(regcomp(gdb_pattern, gdb_pattern_raw, REG_EXTENDED | REG_NOSUB)){ fprintf(stderr, "failed to compile regular expression:" "\n\t%s\n", gdb_pattern_raw); exit(EXIT_FAILURE); }else if(gdb_script==NULL){ fprintf(stderr, "GDB pattern without GDB script\n"); exit(EXIT_FAILURE); } }else{ gdb_pattern = NULL; } /* gdb script */ if(gdb_script!=NULL && gdb_script[0]!='\x00'){ if(gdb_pattern==NULL){ fprintf(stderr, "GDB script without GDB pattern\n"); exit(EXIT_FAILURE); } buffer=gdb_script; for(; *buffer; buffer++){ if(buffer[0]=='\\'){ if(buffer[1]=='n'){ buffer[0]=' '; buffer[1]='\n'; } buffer++; } } bufferLen = strlen(gdb_script)+11; buffer = (char*) malloc(bufferLen); snprintf(buffer, bufferLen, "%s\n\nquit\ny\n\n", gdb_script); gdb_script=buffer; }else if(gdb_script){ free(gdb_script); gdb_script = NULL; } #else if(gdb_script && strlen(gdb_script)){ if(gdb_pattern_raw && strlen(gdb_pattern_raw)){ fprintf(stderr, "WARNING: GDB/regex support inactive\n"); }else{ fprintf(stderr, "GDB script without GDB pattern\n"); exit(EXIT_FAILURE); } }else if(gdb_pattern_raw && strlen(gdb_pattern_raw)){ fprintf(stderr, "GDB pattern without GDB script\n"); exit(EXIT_FAILURE); } #endif /* REG_EXTENDED else */ #ifdef DEBUG fprintf(stderr, "case : \"%s\"\n", case_file); fprintf(stderr, "compiler: \"%s\"\n", compiler); fprintf(stderr, "DFLAGS C: \"%s\"\n", cmd_arg_case); fprintf(stderr, "ELINE : \"%s\"\n", error_line); fprintf(stderr, "EFILE : \"%s\"\n", error_file); #ifdef REG_EXTENDED fprintf(stderr, "GDB Scri: \"%s\"\n", gdb_script); fprintf(stderr, "GDB Patt: \"%s\"\n", gdb_pattern_raw); #endif fprintf(stderr, "block G : \"%s\"\n", torture_block_global); fprintf(stderr, "block C : \"%s\"\n", torture_block_case); fprintf(stderr, "modus : %x\n", modus); #endif /* let's get serious */ #ifdef USE_WINDOWS originalStdout = GetStdHandle(STD_OUTPUT_HANDLE); originalStderr = GetStdHandle(STD_ERROR_HANDLE); #endif if(modus & MODE_TORTURE){ if((modus & (MODE_COMPILE | MODE_NOCOMPILE)) && (modus & (MODE_RUN | MODE_NORUN))) { fprintf(stderr, "BUG: unhandled torture modus %x\n", modus); exit(EXIT_FAILURE); }else if(!(modus & (MODE_COMPILE | MODE_NOCOMPILE | MODE_RUN | MODE_NORUN))){ fprintf(stderr, "BUG: unhandled torture modus %x\n", modus); exit(EXIT_FAILURE); } bufferLen = strlen(torture[(sizeof(torture) / sizeof(char*))-1]) + 128 + strlen(cmd_arg_case) + 3; if(torture_block_case!=NULL && strlen(torture_block_case)<1){ torture_block_case=NULL; } buffer = (char*) malloc(bufferLen); for(index=0; index < sizeof(torture)/sizeof(char*); index++){ if((torture_block_global && strstr(torture[index], torture_block_global)) || (torture_block_case && strstr(torture[index], torture_block_case)) || (torture_require && !strstr(torture[index], torture_require))) { torture_result[index]=RES_UNTESTED; continue; } buffer[0]=0; snprintf(buffer, bufferLen, "%s %s", torture[index], cmd_arg_case); if(modus & (MODE_COMPILE | MODE_NOCOMPILE)){ torture_result[index] = target_compile(modus, compiler, buffer, case_file, error_file, error_line); }else if(modus & (MODE_RUN | MODE_NORUN)){ torture_result[index] = target_run(modus, compiler, buffer, case_file, error_file, error_line #ifdef REG_EXTENDED , gdb, gdb_script, gdb_pattern #endif ); } printf("Torture-Sub-%i/" ZU "-", index+1, sizeof(torture)/sizeof(char*)); printResult(torture_result[index], modus, case_file, stdout); printf("--------\n"); } }else{ if(torture_require && torture_require[0]){ if(!cmd_arg_case || !cmd_arg_case[0]){ cmd_arg_case = torture_require; }else{ bufferLen = strlen(cmd_arg_case); bufferLen += strlen(torture_require); bufferLen += 2; buffer = (char*) malloc(bufferLen); snprintf(buffer, bufferLen, "%s %s", cmd_arg_case, torture_require); cmd_arg_case = buffer; } } if(modus & (MODE_RUN | MODE_NORUN)){ case_result = target_run(modus, compiler, cmd_arg_case, case_file, error_file, error_line #ifdef REG_EXTENDED , gdb, gdb_script, gdb_pattern #endif ); }else if(modus & (MODE_COMPILE | MODE_NOCOMPILE)){ case_result = target_compile(modus, compiler, cmd_arg_case, case_file, error_file, error_line); }else{ fprintf(stderr, "BUG: unhandled non-torture modus %x\n", modus); exit(EXIT_FAILURE); } printf("Torture-Sub-1/" ZU "-", sizeof(torture)/sizeof(char*)); printResult(case_result, modus, case_file, stdout); } if(strcmp(TMP_DIR, tmp_dir)){ bufferLen = strlen(tmp_dir); bufferLen += strlen(RM_DIR); bufferLen += 2; buffer = (char*) malloc(bufferLen); snprintf(buffer, bufferLen, "%s %s", RM_DIR, tmp_dir); system(buffer); } exit(EXIT_SUCCESS); }
static int real_main2 (int argc, TCHAR **argv) { #if (defined (_WIN32) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER) extern int EvalException (LPEXCEPTION_POINTERS blah, int n_except); __try #endif { #ifdef USE_SDL int result = (SDL_Init (SDL_INIT_TIMER | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) == 0); if (result) atexit (SDL_Quit); #endif config_changed = 1; if (restart_config[0]) { default_prefs (&currprefs, 0); fixup_prefs (&currprefs); } if (! graphics_setup ()) { write_log ("Graphics Setup Failed\n"); exit (1); } #ifdef NATMEM_OFFSET preinit_shm (); #endif if (restart_config[0]) parse_cmdline_and_init_file (argc, argv); else currprefs = changed_prefs; uae_inithrtimer (); if (!machdep_init ()) { write_log ("Machine Init Failed.\n"); restart_program = 0; return -1; } if (console_emulation) { consolehook_config (&currprefs); fixup_prefs (&currprefs); } if (! setup_sound ()) { write_log ("Sound driver unavailable: Sound output disabled\n"); currprefs.produce_sound = 0; } inputdevice_init (); changed_prefs = currprefs; no_gui = ! currprefs.start_gui; if (restart_program == 2) no_gui = 1; else if (restart_program == 3) no_gui = 0; restart_program = 0; if (! no_gui) { int err = gui_init (); currprefs = changed_prefs; config_changed = 1; if (err == -1) { write_log ("Failed to initialize the GUI\n"); return -1; } else if (err == -2) { return 1; } } #ifdef NATMEM_OFFSET init_shm (); #endif #ifdef JIT if (!(currprefs.cpu_model >= 68020 && currprefs.address_space_24 == 0 && currprefs.cachesize)) canbang = 0; #endif fixup_prefs (&currprefs); changed_prefs = currprefs; target_run (); /* force sound settings change */ currprefs.produce_sound = 0; #ifdef AUTOCONFIG /* Install resident module to get 8MB chipmem, if requested */ rtarea_setup (); #endif #ifdef FILESYS rtarea_init (); uaeres_install (); hardfile_install (); #endif savestate_init (); #ifdef SCSIEMU scsi_reset (); scsidev_install (); #endif #ifdef SANA2 netdev_install (); #endif #ifdef UAESERIAL uaeserialdev_install (); #endif keybuf_init (); /* Must come after init_joystick */ #ifdef AUTOCONFIG expansion_init (); #endif #ifdef FILESYS filesys_install (); #endif target_startup_sequence (&currprefs); memory_init (); memory_reset (); #ifdef AUTOCONFIG #if defined (BSDSOCKET) bsdlib_install (); #endif emulib_install (); uaeexe_install (); native2amiga_install (); #endif custom_init (); /* Must come after memory_init */ #ifdef SERIAL_PORT serial_init (); #endif DISK_init (); reset_frame_rate_hack (); init_m68k (); /* must come after reset_frame_rate_hack (); */ gui_update (); if (graphics_init ()) { #ifdef DEBUGGER setup_brkhandler (); if (currprefs.start_debugger && debuggable ()) activate_debugger (); #endif if (!init_audio ()) { if (sound_available && currprefs.produce_sound > 1) { write_log ("Sound driver unavailable: Sound output disabled\n"); } currprefs.produce_sound = 0; } start_program (); } } #if (defined (_WIN32) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER) #ifdef JIT __except( EvalException( GetExceptionInformation(), GetExceptionCode() ) ) #else __except (DummyException (GetExceptionInformation (), GetExceptionCode ())) #endif { // EvalException does the good stuff... } #endif return 0; }