eval_err_t testutil_node_print_pretty( memory_state_t *ms, node_t *args, node_t *env_handle, node_t **result) { return extract_args(ms, 1, do_node_print_pretty, args, result, NULL); }
int main(int argc, char *argv[]) { char *cmd; interactive = argc==1; cmd = nullptr; out_phys = fopen("/tmp/ep2.mem", "wb+"); out_virt = fopen("/tmp/ep2.vir", "wb+"); if (!interactive) parse(argv[1]); using_history(); while (true) { cmd = readline(PROMPT); add_history(cmd); extract_args(cmd); switch(evaluate_str(args_table[0])) { case evaluate_str("carrega"): parse(args_table[1]); break; case evaluate_str("espaco"): set_mem_mgr(atoi(args_table[1])); break; case evaluate_str("substitui"): set_page_mgr(atoi(args_table[1])); break; case evaluate_str("executa"): run_mem_mgr(atoi(args_table[1])); break; case evaluate_str("sai"): goto cleanup; break; default: fputs("Erro.\n", stderr); break; } delete cmd; for (int i=0;args_table[i]!=NULL;++i) { delete[] args_table[i]; args_table[i] = NULL; } } cleanup: fclose(out_phys); fclose(out_virt); return 0; }
void mADocumentView::add() { string argString = (QString("filename:") + ui->arguments->text()).toStdString(); string _filename; vector<string> argv; if(!extract_args(argString, _filename, argv)) argv.clear(); string filepath; if(file != NULL) filepath = file->fileName().toStdString(); else filepath = QDir::currentPath().toStdString(); string output; t_CKUINT shred_id; string code = ui->textEdit->text().toStdString(); t_OTF_RESULT otf_result = m_ma->run_code(code, m_title, argv, filepath, m_docid, shred_id, output); if(otf_result == OTF_SUCCESS) { m_lastResult = ""; ui->textEdit->clearIndicatorRange(0, 0, ui->textEdit->lines(), ui->textEdit->lineLength(ui->textEdit->lines()-1)-1, m_indicator); } else if( otf_result == OTF_VM_TIMEOUT ) { // miniAudicleController * mac = [NSDocumentController sharedDocumentController]; // [mac setLockdown:YES]; } else if( otf_result == OTF_COMPILE_ERROR ) { int error_line; if( m_ma->get_last_result( m_docid, NULL, NULL, &error_line ) ) { // ui->textEdit->fillIndicatorRange(error_line, 0, error_line+1, 0, // //ui->textEdit->lineLength(error_line)-1, // m_indicator); } // if([self.windowController currentViewController] == self) // [[text_view textView] animateError]; m_lastResult = output; } else { // if([self.windowController currentViewController] == self) // [[text_view textView] animateError]; m_lastResult = output; } }
void launch_interface ( FileSystem* fs ) { commandline_t buffer; printf ( "\n0> " ); fflush ( stdout ); while ( fgets (buffer, sizeof buffer, stdin) ) { int ret = 1; argv_t argv; int argc; extract_args (buffer, &argc, argv); if (argc == 0) { fprintf (stderr, "No command given\n"); } else { if (!strcmp (argv[0], "quit")) { printf ("\n"); return; } bool found = false; for (size i = 0; i < sizeof table / sizeof *table; i++) { if (!strcmp (argv[0], table[i].command)) { if (argc - 1 >= table[i].nb_params && (table[i].nb_opt_params < 0 || argc - 1 <= table[i].nb_opt_params)) ret = table[i].function (fs, argc, argv); else fprintf (stderr, "Wrong number of parameters for command %s\n", table[i].command); found = true; break; } } if (!found) fprintf (stderr, "Unknown command\n"); } printf ("%d> ", ret); fflush (stdout); } }
static void extract_args(ciapos_sexp frame, ciapos_sexp arglist, ciapos_sexp args) { if (arglist.tag == CIAPOS_TAGNIL || args.tag == CIAPOS_TAGNIL) { assert(args.tag == arglist.tag); return; } if (arglist.tag == CIAPOS_TAGSYM) ciapos_environment_put(frame, arglist.symbol, args); assert(args.tag == CIAPOS_TAGTUP); assert(arglist.tag == CIAPOS_TAGTUP); ciapos_sexp argname = ciapos_tuple_get(arglist, 0); ciapos_sexp argval = ciapos_tuple_get(args, 0); assert(argname.tag == CIAPOS_TAGSYM); ciapos_environment_put(frame, argname.symbol, argval); extract_args(frame, ciapos_tuple_get(arglist, 1), ciapos_tuple_get(args, 1)); }
static ciapos_sexp usercode_eval(ciapos_vm *vm, ciapos_sexp fbody, ciapos_sexp env, ciapos_sexp args) { ciapos_sexp arglist = ciapos_tuple_get(fbody, 0); ciapos_sexp frame = ciapos_mkenvironment(&vm->top_of_heap, 16); extract_args(frame, arglist, args); ciapos_sexp newenv = ciapos_mktuple(&vm->top_of_heap, 2); ciapos_tuple_put(newenv, 0, frame); ciapos_tuple_put(newenv, 1, env); env = newenv; ciapos_sexp result; fbody = ciapos_tuple_get(fbody, 1); assert(fbody.tag == CIAPOS_TAGTUP); do { result = ciapos_vm_eval_withstack(vm, env, ciapos_tuple_get(fbody, 0)); fbody = ciapos_tuple_get(fbody, 1); } while (fbody.tag == CIAPOS_TAGTUP); assert(fbody.tag == CIAPOS_TAGNIL); return result; }
/********************** ************************/ int main(int argc,char *argv[]) { int n_pages = 0; //int n_frames = 0; ram_info_t ram_info;// ram_info.n_frames = 0;// ram_info.algorithm = NULL;// int n_cache = 0; int n_tlb = 0; char *access_file = NULL; FILE *access_fd = NULL; addr_t virtual_addr = 0; addr_t physical_addr; pid_t pid = 0; char mode; /* * Parse arguments */ if( 0 != parse_args(argc, argv, &access_file, &n_pages, &ram_info.n_frames, &n_cache, &n_tlb, &ram_info.algorithm) ) {// return -1; } /* * Setup data structures */ srand(time(NULL)); current_ref = (char *)malloc(sizeof(char) * MAX_LINE); clear_stats(); stats.cache_size = n_cache; stats.tlb_size = n_tlb; stats.num_pages = n_pages; stats.num_frames = ram_info.n_frames;// printf("Allocating resources...\n"); allocate_cache(n_cache); allocate_tlb(n_tlb); allocate_page_table(n_pages); allocate_page_directory(n_pages); //allocate_ram(n_frames); allocate_ram(ram_info); /* * Open the file that we are going to read */ if( NULL == (access_fd = fopen(access_file, "r") ) ) { fprintf(stderr, "Error: Unable to open the access file <%s>\n", access_file); return -1; } /* * Read page requests from the file */ gettimeofday(&stats.start, NULL); while(0 == feof(access_fd) ) { /* Read one line */ current_ref[0] = '\0'; if( NULL == fgets(current_ref, MAX_LINE, access_fd) ) { break; } /* Strip off the newline */ if( '\n' == current_ref[strlen(current_ref)-1] ) { current_ref[strlen(current_ref)-1] = '\0'; } extract_args(current_ref, &pid, &mode, &virtual_addr); /* * Memory management operations to access the page */ if(VERBOSE){ printf("-----------------------------------------------------------\n"); printf("%s: Process %*d \t Access [Page %4d, Offset %#05x] (%#010x)\n", current_ref, MAX_PID_LEN, pid, GET_PAGE(virtual_addr), GET_OFFSET(virtual_addr), virtual_addr); } access_page(pid, mode, virtual_addr, &physical_addr); if(VERBOSE){ printf("%s: Process %*d \t Access [Page %4d, Offset %#05x] (%#010x) --> (%#010x) [Frame %4d, Offset %#05x]\n", current_ref, MAX_PID_LEN, pid, GET_PAGE(virtual_addr), GET_OFFSET(virtual_addr), virtual_addr, physical_addr, GET_FRAME(physical_addr), GET_OFFSET(physical_addr)); } } gettimeofday(&stats.end, NULL); display_stats(); /* * Cleanup */ fclose(access_fd); if( NULL != current_ref ) { free(current_ref); current_ref = NULL; } free_ram(); free_page_dir(); free_tlb(); free_cache(); return 0; }
eval_err_t foreign_func_p(memory_state_t *ms, node_t *args, node_t *env, node_t **out) { return extract_args(ms, 1, func_matchfn, args, out, NULL); }
eval_err_t foreign_b_shl(memory_state_t *ms, node_t *args, node_t *env, node_t **out) { return extract_args(ms, 2, do_mathop, args, out, mathop_bit_shl); }
eval_err_t foreign_addc_p(memory_state_t *ms, node_t *args, node_t *env, node_t **out) { return extract_args(ms, 2, do_mathop, args, out, mathop_addc_p); }
eval_err_t foreign_smeq_p(memory_state_t *ms, node_t *args, node_t *env, node_t **out) { return extract_args(ms, 2, do_symeq_p, args, out, NULL); }
eval_err_t foreign_splsym(memory_state_t *ms, node_t *args, node_t *env, node_t **out) { return extract_args(ms, 1, do_splitsym, args, out, NULL); }
eval_err_t foreign_cdr(memory_state_t *ms, node_t *args, node_t *env, node_t **out) { return extract_args(ms, 1, do_cdr, args, out, NULL); }
int sys_popen(const char *command) { int parent_end, child_end; int pipe_fds[2]; popen_list *entry = NULL; char **argl = NULL; if (pipe(pipe_fds) < 0) return -1; parent_end = pipe_fds[0]; child_end = pipe_fds[1]; if (!*command) { errno = EINVAL; goto err_exit; } if((entry = (popen_list *)malloc(sizeof(popen_list))) == NULL) goto err_exit; ZERO_STRUCTP(entry); /* * Extract the command and args into a NULL terminated array. */ if(!(argl = extract_args(command))) goto err_exit; entry->child_pid = sys_fork(); if (entry->child_pid == -1) { goto err_exit; } if (entry->child_pid == 0) { /* * Child ! */ int child_std_end = STDOUT_FILENO; popen_list *p; close(parent_end); if (child_end != child_std_end) { dup2 (child_end, child_std_end); close (child_end); } /* * POSIX.2: "popen() shall ensure that any streams from previous * popen() calls that remain open in the parent process are closed * in the new child process." */ for (p = popen_chain; p; p = p->next) close(p->fd); execv(argl[0], argl); _exit (127); } /* * Parent. */ close (child_end); SAFE_FREE(argl); /* Link into popen_chain. */ entry->next = popen_chain; popen_chain = entry; entry->fd = parent_end; return entry->fd; err_exit: SAFE_FREE(entry); SAFE_FREE(argl); close(pipe_fds[0]); close(pipe_fds[1]); return -1; }
extern "C" int chuck_main( int argc, const char ** argv ) #endif { Chuck_Compiler * compiler = NULL; Chuck_VM * vm = NULL; Chuck_VM_Code * code = NULL; Chuck_VM_Shred * shred = NULL; t_CKBOOL enable_audio = TRUE; t_CKBOOL vm_halt = TRUE; t_CKUINT srate = SAMPLING_RATE_DEFAULT; t_CKUINT buffer_size = BUFFER_SIZE_DEFAULT; t_CKUINT num_buffers = NUM_BUFFERS_DEFAULT; t_CKUINT dac = 0; t_CKUINT adc = 0; t_CKUINT dac_chans = 2; t_CKUINT adc_chans = 2; t_CKBOOL dump = FALSE; t_CKBOOL probe = FALSE; t_CKBOOL set_priority = FALSE; t_CKBOOL auto_depend = FALSE; t_CKBOOL block = FALSE; t_CKBOOL enable_shell = FALSE; t_CKBOOL no_vm = FALSE; t_CKBOOL load_hid = FALSE; t_CKBOOL enable_server = TRUE; t_CKBOOL do_watchdog = TRUE; t_CKINT adaptive_size = 0; t_CKINT log_level = CK_LOG_CORE; t_CKINT deprecate_level = 1; // warn string filename = ""; vector<string> args; #if defined(__DISABLE_WATCHDOG__) do_watchdog = FALSE; #elif defined(__MACOSX_CORE__) do_watchdog = TRUE; #elif defined(__PLATFORM_WIN32__) && !defined(__WINDOWS_PTHREAD__) do_watchdog = TRUE; #else do_watchdog = FALSE; #endif t_CKUINT files = 0; t_CKUINT count = 1; t_CKINT i; // set log level EM_setlog( log_level ); // parse command line args for( i = 1; i < argc; i++ ) { if( argv[i][0] == '-' || argv[i][0] == '+' || argv[i][0] == '=' || argv[i][0] == '^' || argv[i][0] == '@' ) { if( !strcmp(argv[i], "--dump") || !strcmp(argv[i], "+d") || !strcmp(argv[i], "--nodump") || !strcmp(argv[i], "-d") ) continue; else if( get_count( argv[i], &count ) ) continue; else if( !strcmp(argv[i], "--audio") || !strcmp(argv[i], "-a") ) enable_audio = TRUE; else if( !strcmp(argv[i], "--silent") || !strcmp(argv[i], "-s") ) enable_audio = FALSE; else if( !strcmp(argv[i], "--halt") || !strcmp(argv[i], "-t") ) vm_halt = TRUE; else if( !strcmp(argv[i], "--loop") || !strcmp(argv[i], "-l") ) { vm_halt = FALSE; enable_server = TRUE; } else if( !strcmp(argv[i], "--server") ) enable_server = TRUE; else if( !strcmp(argv[i], "--standalone") ) enable_server = FALSE; else if( !strcmp(argv[i], "--callback") ) block = FALSE; else if( !strcmp(argv[i], "--blocking") ) block = TRUE; else if( !strcmp(argv[i], "--hid") ) load_hid = TRUE; else if( !strcmp(argv[i], "--shell") || !strcmp( argv[i], "-e" ) ) { enable_shell = TRUE; vm_halt = FALSE; } else if( !strcmp(argv[i], "--empty") ) no_vm = TRUE; else if( !strncmp(argv[i], "--srate", 7) ) srate = atoi( argv[i]+7 ) > 0 ? atoi( argv[i]+7 ) : srate; else if( !strncmp(argv[i], "-r", 2) ) srate = atoi( argv[i]+2 ) > 0 ? atoi( argv[i]+2 ) : srate; else if( !strncmp(argv[i], "--bufsize", 9) ) buffer_size = atoi( argv[i]+9 ) > 0 ? atoi( argv[i]+9 ) : buffer_size; else if( !strncmp(argv[i], "-b", 2) ) buffer_size = atoi( argv[i]+2 ) > 0 ? atoi( argv[i]+2 ) : buffer_size; else if( !strncmp(argv[i], "--bufnum", 8) ) num_buffers = atoi( argv[i]+8 ) > 0 ? atoi( argv[i]+8 ) : num_buffers; else if( !strncmp(argv[i], "-n", 2) ) num_buffers = atoi( argv[i]+2 ) > 0 ? atoi( argv[i]+2 ) : num_buffers; else if( !strncmp(argv[i], "--dac", 5) ) dac = atoi( argv[i]+5 ) > 0 ? atoi( argv[i]+5 ) : 0; else if( !strncmp(argv[i], "--adc", 5) ) adc = atoi( argv[i]+5 ) > 0 ? atoi( argv[i]+5 ) : 0; else if( !strncmp(argv[i], "--channels", 10) ) dac_chans = adc_chans = atoi( argv[i]+10 ) > 0 ? atoi( argv[i]+10 ) : 2; else if( !strncmp(argv[i], "-c", 2) ) dac_chans = adc_chans = atoi( argv[i]+2 ) > 0 ? atoi( argv[i]+2 ) : 2; else if( !strncmp(argv[i], "--out", 5) ) dac_chans = atoi( argv[i]+5 ) > 0 ? atoi( argv[i]+5 ) : 2; else if( !strncmp(argv[i], "-o", 2) ) dac_chans = atoi( argv[i]+2 ) > 0 ? atoi( argv[i]+2 ) : 2; else if( !strncmp(argv[i], "--in", 4) ) adc_chans = atoi( argv[i]+4 ) > 0 ? atoi( argv[i]+4 ) : 2; else if( !strncmp(argv[i], "-i", 2) ) adc_chans = atoi( argv[i]+2 ) > 0 ? atoi( argv[i]+2 ) : 2; else if( !strncmp(argv[i], "--level", 7) ) { g_priority = atoi( argv[i]+7 ); set_priority = TRUE; } else if( !strncmp(argv[i], "--watchdog", 10) ) { g_watchdog_timeout = atof( argv[i]+10 ); if( g_watchdog_timeout <= 0 ) g_watchdog_timeout = 0.5; do_watchdog = TRUE; } else if( !strncmp(argv[i], "--nowatchdog", 12) ) do_watchdog = FALSE; else if( !strncmp(argv[i], "--remote", 8) ) strcpy( g_host, argv[i]+8 ); else if( !strncmp(argv[i], "@", 1) ) strcpy( g_host, argv[i]+1 ); else if( !strncmp(argv[i], "--port", 6) ) g_port = atoi( argv[i]+6 ); else if( !strncmp(argv[i], "-p", 2) ) g_port = atoi( argv[i]+2 ); else if( !strncmp(argv[i], "--auto", 6) ) auto_depend = TRUE; else if( !strncmp(argv[i], "-u", 2) ) auto_depend = TRUE; else if( !strncmp(argv[i], "--log", 5) ) log_level = argv[i][5] ? atoi( argv[i]+5 ) : CK_LOG_INFO; else if( !strncmp(argv[i], "--verbose", 9) ) log_level = argv[i][9] ? atoi( argv[i]+9 ) : CK_LOG_INFO; else if( !strncmp(argv[i], "-v", 2) ) log_level = argv[i][2] ? atoi( argv[i]+2 ) : CK_LOG_INFO; else if( !strncmp(argv[i], "--adaptive", 10) ) adaptive_size = argv[i][10] ? atoi( argv[i]+10 ) : -1; else if( !strncmp(argv[i], "--deprecate", 11) ) { // get the rest string arg = argv[i]+11; if( arg == ":stop" ) deprecate_level = 0; else if( arg == ":warn" ) deprecate_level = 1; else if( arg == ":ignore" ) deprecate_level = 2; else { // error fprintf( stderr, "[chuck]: invalid arguments for '--deprecate'...\n" ); fprintf( stderr, "[chuck]: ... (looking for :stop, :warn, or :ignore)\n" ); exit( 1 ); } } else if( !strcmp( argv[i], "--probe" ) ) probe = TRUE; else if( !strcmp( argv[i], "--poop" ) ) uh(); else if( !strcmp( argv[i], "--caution-to-the-wind" ) ) g_enable_system_cmd = TRUE; else if( !strcmp(argv[i], "--help") || !strcmp(argv[i], "-h") || !strcmp(argv[i], "--about") ) { usage(); exit( 2 ); } else if( !strcmp( argv[i], "--version" ) ) { version(); exit( 2 ); } else { // boost log level g_otf_log = CK_LOG_CORE; // flag int is_otf = FALSE; // log level EM_setlog( log_level ); // do it if( otf_send_cmd( argc, argv, i, g_host, g_port, &is_otf ) ) exit( 0 ); // is otf if( is_otf ) exit( 1 ); // done fprintf( stderr, "[chuck]: invalid flag '%s'\n", argv[i] ); usage(); exit( 1 ); } } else files++; } // log level EM_setlog( log_level ); // probe if( probe ) { Digitalio::probe(); #ifndef __DISABLE_MIDI__ EM_error2b( 0, "" ); probeMidiIn(); EM_error2b( 0, "" ); probeMidiOut(); EM_error2b( 0, "" ); #endif // __DISABLE_MIDI__ // HidInManager::probeHidIn(); // exit exit( 0 ); } // check buffer size buffer_size = ensurepow2( buffer_size ); // check mode and blocking if( !enable_audio && !block ) block = TRUE; // audio, boost if( !set_priority && !block ) g_priority = g_priority_low; if( !set_priority && !enable_audio ) g_priority = 0x7fffffff; // set priority Chuck_VM::our_priority = g_priority; // set watchdog g_do_watchdog = do_watchdog; // set adaptive size if( adaptive_size < 0 ) adaptive_size = buffer_size; if ( !files && vm_halt && !enable_shell ) { fprintf( stderr, "[chuck]: no input files... (try --help)\n" ); exit( 1 ); } // shell initialization without vm if( enable_shell && no_vm ) { // instantiate g_shell = new Chuck_Shell; // initialize if( !init_shell( g_shell, new Chuck_Console, NULL ) ) exit( 1 ); // no vm is needed, just start running the shell now g_shell->run(); // clean up SAFE_DELETE( g_shell ); // done exit( 0 ); } // make sure vm if( no_vm ) { fprintf( stderr, "[chuck]: '--empty' can only be used with shell...\n" ); exit( 1 ); } // allocate the vm - needs the type system vm = g_vm = new Chuck_VM; if( !vm->initialize( enable_audio, vm_halt, srate, buffer_size, num_buffers, dac, adc, dac_chans, adc_chans, block, adaptive_size ) ) { fprintf( stderr, "[chuck]: %s\n", vm->last_error() ); exit( 1 ); } // allocate the compiler compiler = g_compiler = new Chuck_Compiler; // initialize the compiler if( !compiler->initialize( vm ) ) { fprintf( stderr, "[chuck]: error initializing compiler...\n" ); exit( 1 ); } // enable dump compiler->emitter->dump = dump; // set auto depend compiler->set_auto_depend( auto_depend ); // vm synthesis subsystem - needs the type system if( !vm->initialize_synthesis( ) ) { fprintf( stderr, "[chuck]: %s\n", vm->last_error() ); exit( 1 ); } #ifndef __ALTER_HID__ // pre-load hid if( load_hid ) HidInManager::init(); #endif // __ALTER_HID__ // catch SIGINT signal( SIGINT, signal_int ); #ifndef __PLATFORM_WIN32__ // catch SIGPIPE signal( SIGPIPE, signal_pipe ); #endif // shell initialization if( enable_shell ) { // instantiate g_shell = new Chuck_Shell; // initialize if( !init_shell( g_shell, new Chuck_Console, vm ) ) exit( 1 ); } // set deprecate compiler->env->deprecate_level = deprecate_level; // reset count count = 1; // log EM_log( CK_LOG_SEVERE, "starting compilation..." ); // push indent EM_pushlog(); // loop through and process each file for( i = 1; i < argc; i++ ) { // make sure if( argv[i][0] == '-' || argv[i][0] == '+' ) { if( !strcmp(argv[i], "--dump") || !strcmp(argv[i], "+d" ) ) compiler->emitter->dump = TRUE; else if( !strcmp(argv[i], "--nodump") || !strcmp(argv[i], "-d" ) ) compiler->emitter->dump = FALSE; else get_count( argv[i], &count ); continue; } // parse out command line arguments if( !extract_args( argv[i], filename, args ) ) { // error fprintf( stderr, "[chuck]: malformed filename with argument list...\n" ); fprintf( stderr, " --> '%s'", argv[i] ); return 1; } // log EM_log( CK_LOG_FINE, "compiling '%s'...", filename.c_str() ); // push indent EM_pushlog(); // parse, type-check, and emit if( !compiler->go( filename, NULL ) ) return 1; // get the code code = compiler->output(); // name it code->name += string(argv[i]); // log EM_log( CK_LOG_FINE, "sporking %d %s...", count, count == 1 ? "instance" : "instances" ); // spork it while( count-- ) { // spork shred = vm->spork( code, NULL ); // add args shred->args = args; } // pop indent EM_poplog(); // reset count count = 1; } // pop indent EM_poplog(); // reset the parser reset_parse(); // boost priority if( Chuck_VM::our_priority != 0x7fffffff ) { // try if( !Chuck_VM::set_priority( Chuck_VM::our_priority, vm ) ) { // error fprintf( stderr, "[chuck]: %s\n", vm->last_error() ); exit( 1 ); } } // server if( enable_server ) { #ifndef __DISABLE_OTF_SERVER__ // log EM_log( CK_LOG_SYSTEM, "starting listener on port: %d...", g_port ); // start tcp server g_sock = ck_tcp_create( 1 ); if( !g_sock || !ck_bind( g_sock, g_port ) || !ck_listen( g_sock, 10 ) ) { fprintf( stderr, "[chuck]: cannot bind to tcp port %i...\n", g_port ); ck_close( g_sock ); g_sock = NULL; } else { #if !defined(__PLATFORM_WIN32__) || defined(__WINDOWS_PTHREAD__) pthread_create( &g_tid_otf, NULL, otf_cb, NULL ); #else g_tid_otf = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)otf_cb, NULL, 0, 0 ); #endif } #endif // __DISABLE_OTF_SERVER__ } else { // log EM_log( CK_LOG_SYSTEM, "OTF server/listener: OFF" ); } // start shell on separate thread if( enable_shell ) { #if !defined(__PLATFORM_WIN32__) || defined(__WINDOWS_PTHREAD__) pthread_create( &g_tid_shell, NULL, shell_cb, g_shell ); #else g_tid_shell = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)shell_cb, g_shell, 0, 0 ); #endif } // run the vm vm->run(); // detach all_detach(); // free vm vm = NULL; SAFE_DELETE( g_vm ); // free the compiler compiler = NULL; SAFE_DELETE( g_compiler ); // wait for the shell, if it is running // does the VM reset its priority to normal before exiting? if( enable_shell ) while( g_shell != NULL ) usleep(10000); return 0; }