int RUN(int argc,char **argv,FILE *out) { #ifdef OUT opt_t def = { 0, NUMBER_OF_RUN, SIZE_OF_TEST, AVAIL, NEXE, mode_random, }; opt_t d = def ; char *prog = argv[0] ; char **p = parse_opt(argc,argv,&def,&d) ; int n_exe = d.n_exe ; if (d.avail != AVAIL) n_exe = d.avail / N ; if (n_exe < 1) n_exe = 1 ; global.verbose = d.verbose; global.nexe = n_exe; global.noccs = NOCCS ; global.nruns = d.max_run; global.size = d.size_of_test; global.do_scan = d.mode == mode_scan ; if (global.verbose) { fprintf(stderr,"%s: n=%i, r=%i, s=%i, %s\n",prog,global.nexe,global.nruns,global.size,global.do_scan ? "+sp" : "+rp"); } parse_param(prog,global.parse,PARSESZ,p) ; #ifdef PRELUDE prelude(out) ; #endif tsc_t start = timeofday(); #else global.verbose = 0 ; global.nexe = NEXE ; global.noccs = NOCCS ; global.nruns = NUMBER_OF_RUN ; global.size = SIZE_OF_TEST ; global.do_scan = 0; #endif for (int id=0; id < AVAIL ; id++) { arg[id].id = id; arg[id].g = &global; } for (int id=0; id < AVAIL ; id++) launch(&th[id],zyva,&arg[id]); for (int id=0; id < AVAIL ; id++) join(&th[id]); int nexe = global.nexe ; hash_init(&global.hash) ; for (int k=0 ; k < nexe ; k++) { hash_adds(&global.hash,&global.ctx[k].t) ; } #ifdef OUT tsc_t total = timeofday()-start; count_t p_true = 0, p_false = 0; for (int k = 0 ; k < HASHSZ ; k++) { entry_t *e = &global.hash.t[k]; if (e->ok) { p_true += e->c ; } else { p_false += e->c; } } postlude(out,&global,p_true,p_false,total); #endif return EXIT_SUCCESS; }
/* * @- TMcommit * global commit without any multi-threaded access assumptions, thus * taking all BBP locks. It creates a new database checkpoint. */ gdk_return TMcommit(void) { gdk_return ret = GDK_FAIL; /* commit with the BBP globally locked */ BBPlock(); if (prelude(getBBPsize(), NULL) == GDK_SUCCEED && BBPsync(getBBPsize(), NULL) == GDK_SUCCEED) { epilogue(getBBPsize(), NULL); ret = GDK_SUCCEED; } BBPunlock(); return ret; }
void Render::draw(int mode) { switch(mode) { case 0: prelude(); break; case 1: theme(); break; case 2: finale(); break; } // switch mode } // draw()
void Game::update() { switch(mode) { case PRELUDE: prelude(); break; case THEME: theme(); break; case FINALE: finale(); break; }; // switch state } // update()
void generate_c(FILE *f, struct ir_unit *unit) { CTX *ctx = talloc_struct(NULL, CTX, { f, 0 }); ctx->type_mangle = ht_create(ctx, HT_DATA_dptr, HT_DATA_dstr); ctx->redef = ht_create(ctx, HT_DATA_dstr, HT_DATA_dempty); ctx->tuple_abbrev = ht_create(ctx, HT_DATA_dstr, HT_DATA_dstr); ctx->tmp = talloc_new(ctx); prelude(ctx); struct optimize_settings opt = OPTIMIZE_DEFAULT; opt.opt_inline = true; unit_optimize(unit, &opt); for (int n = 0; n < unit->fn_decls_count; n++) { struct ir_fn_decl *fn = unit->fn_decls[n]; gen_fn(ctx, fn->body, link_name(ctx, fn->name), fn->name.visible); } talloc_free(ctx); }
/* * @- TMsubcommit * * Create a new checkpoint that is equal to the previous, with the * exception that for the passed list of batnames, the current state * will be reflected in the new checkpoint. * * On the bats in this list we assume exclusive access during the * operation. * * This operation is useful for e.g. adding a new XQuery document or * SQL table to the committed state (after bulk-load). Or for dropping * a table or doc, without forcing the total database to be clean, * which may require a lot of I/O. * * We expect the globally locked phase (BBPsync) to take little time * (<100ms) as only the BBP.dir is written out; and for the existing * bats that were modified, only some heap moves are done (moved from * BAKDIR to SUBDIR). The atomic commit for sub-commit is the rename * of SUBDIR to DELDIR. * * As it does not take the BBP-locks (thanks to the assumption that * access is exclusive), the concurrency impact of subcommit is also * much lighter to ongoing concurrent query and update facilities than * a real global TMcommit. */ gdk_return TMsubcommit_list(bat *subcommit, int cnt) { int xx; gdk_return ret = GDK_FAIL; assert(cnt > 0); assert(subcommit[0] == 0); /* BBP artifact: slot 0 in the array will be ignored */ /* sort the list on BAT id */ GDKqsort(subcommit + 1, NULL, NULL, cnt - 1, sizeof(bat), 0, TYPE_bat); assert(cnt == 1 || subcommit[1] > 0); /* all values > 0 */ /* de-duplication of BAT ids in subcommit list * this is needed because of legacy reasons (database * upgrade) */ for (xx = 2; xx < cnt; xx++) { if (subcommit[xx-1] == subcommit[xx]) { int i; cnt--; for (i = xx; i < cnt; i++) subcommit[i] = subcommit[i+1]; } } if (prelude(cnt, subcommit) == GDK_SUCCEED) { /* save the new bats outside the lock */ /* lock just prevents BBPtrims, and other global * (sub-)commits */ for (xx = 0; xx <= BBP_THREADMASK; xx++) MT_lock_set(&GDKtrimLock(xx)); if (BBPsync(cnt, subcommit) == GDK_SUCCEED) { /* write BBP.dir (++) */ epilogue(cnt, subcommit); ret = GDK_SUCCEED; } for (xx = BBP_THREADMASK; xx >= 0; xx--) MT_lock_unset(&GDKtrimLock(xx)); } return ret; }
int cue_code_generator_generate(CueCodeGenerator *cg, CueAstRoot *ast) { int nsdepth = 0; CueList *body = ast->v.module.body; CueList *package = ast->v.module.package; CueList *package_str = cue_list_new(cg->pool); CueListNode *cur = cue_list_head(package); prelude(cg); while (cur != NULL) { CueAstExpr *name = cur->data; enter_namespace(cg, name->v.name.id); cue_list_push(package_str, name->v.name.id); cur = cur->next; nsdepth++; } _fmt(cg, "// enter package %s\n\n", _join(cg->pool, ".", package_str)); cur = body->head; while (cur != NULL) { compile_stmt(cg, (CueAstStmt*)cur->data); cur = cur->next; } while (nsdepth > 0) { leave_namespace(cg); nsdepth--; } _fmt(cg, "// leave package %s\n\n", _join(cg->pool, ".", package_str)); prologue(cg); return 0; }
int main(int argc, char** argv) { prelude(argc, argv); calculate(argc, argv); exit(EXIT_SUCCESS); }
bool display_deps(environment const & env, std::ostream & out, std::ostream & err, char const * fname) { name import("import"); name prelude("prelude"); name period("."); std::ifstream in(fname); if (in.bad() || in.fail()) { err << "failed to open file '" << fname << "'" << std::endl; return false; } scanner s(in, fname); optional<unsigned> k; std::string base = dirname(fname); bool import_prefix = false; bool import_args = false; bool ok = true; bool is_prelude = false; auto display_dep = [&](optional<unsigned> const & k, name const & f) { import_args = true; try { std::string m_name = find_file(base, k, name_to_file(f), {".lean", ".hlean", ".olean", ".lua"}); int last_idx = m_name.find_last_of("."); std::string rawname = m_name.substr(0, last_idx); std::string ext = m_name.substr(last_idx); if (ext == ".lean" || ext == ".hlean") m_name = rawname + ".olean"; display_path(out, m_name); import_prefix = true; out << "\n"; } catch (exception & new_ex) { err << "error: file '" << name_to_file(s.get_name_val()) << "' not found in the LEAN_PATH" << std::endl; ok = false; } }; while (true) { scanner::token_kind t = scanner::token_kind::Identifier; try { t = s.scan(env); } catch (exception &) { continue; } if (t == scanner::token_kind::Eof) { if (!is_prelude) display_dep(optional<unsigned>(), name("init")); return ok; } else if (t == scanner::token_kind::CommandKeyword && s.get_token_info().value() == prelude) { is_prelude = true; } else if (t == scanner::token_kind::CommandKeyword && s.get_token_info().value() == import) { k = optional<unsigned>(); import_prefix = true; } else if (import_prefix && t == scanner::token_kind::Keyword && s.get_token_info().value() == period) { if (!k) k = 0; else k = *k + 1; } else if ((import_prefix || import_args) && t == scanner::token_kind::Identifier) { display_dep(k, s.get_name_val()); k = optional<unsigned>(); } else { import_args = false; import_prefix = false; } } }