int postProcess() { if (directory) walktree(directory, command); else printHelp(); return 0; }
local void walksub(nodeptr *nptr, nodeptr *np, cellptr cptr, cellptr bptr, nodeptr p, real psize, vector pmid) { nodeptr q; int k; vector qmid; if (Type(p) == CELL) { // fanout over descendents for (q = More(p); q != Next(p); q = Next(q)) { // loop over all subcells for (k = 0; k < NDIM; k++) // set subcell's midpoint qmid[k] = pmid[k] + (Pos(q)[k] < pmid[k] ? - psize : psize) / 4; walktree(nptr, np, cptr, bptr, q, psize / 2, qmid); // recurse on subcell } } else { // extend "virtual" tree for (k = 0; k < NDIM; k++) // set virtual midpoint qmid[k] = pmid[k] + (Pos(p)[k] < pmid[k] ? - psize : psize) / 4; walktree(nptr, np, cptr, bptr, p, psize / 2, qmid); // and search next level } }
static void do_arg(const char *name) { #ifdef S_IFLNK if (!L_opt) { Stat_t sb; if (lstat(name, &sb) >= 0 && isLINK(sb.st_mode)) { Ignore(name, " (is a link)"); return; } } #endif (void) walktree((char *) 0, name, scan_tree, "r", 0); }
static int WALK_FUNC(scan_tree) { char tmp[BUFSIZ]; char *s = pathcat(tmp, path, name); Stat_t sb; if (RCS_DEBUG) PRINTF("++ %s%sscan (%s, %s, %s%d)\n", R_opt ? "R " : "", L_opt ? "L " : "", path, name, (sp == 0) ? "no-stat, " : "", level); if (!quiet || n_opt) track_wd(path); if (sp == 0) { if (R_opt && (level > 0)) { Ignore(name, " (no such file)"); } } else if (isDIR(sp->st_mode)) { abspath(s); /* get rid of "." and ".." names */ if (ignore_dir(s)) readable = -1; else if (sameleaf(s, rcs_dir(NULL, NULL))) { if (R_opt) { (void) walktree(strcpy(user_wd, path), name, scan_archive, "r", level); } readable = -1; } else { #ifdef S_IFLNK if (!L_opt && (lstat(s, &sb) < 0 || isLINK(sb.st_mode))) { Ignore(name, " (is a link)"); readable = -1; } #endif } } else if (!isFILE(sp->st_mode)) { Ignore(name, RCS_DEBUG ? " (not a file)" : ""); readable = -1; } return (readable); }
int walktree(const wchar_t * directory,const wchar_t * command) { std::wstring dir = directory; dir += L"\\*"; std::wstring cmd = command ? command : L""; WIN32_FIND_DATAW findData; HANDLE hFile = FindFirstFile(dir.c_str(), &findData); if (hFile != INVALID_HANDLE_VALUE) { std::wstring current = getCurrent(); SetCurrentDirectoryW(directory); do { std::wstring fname = findData.cFileName; if (fname == L".." || fname == L".") continue; if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { std::wstring walk = fname; walktree(walk.c_str(), command); } else { // TODO implement replacement strategy %N filename without extension %E extension %F complete file name %P path if (cmd.empty()) { wprintf(L"%s\n", fname.c_str()); } else { std::wstring com = cmd + L" " + fname; wchar_t*buffer = new wchar_t[com.length() + 1]; wsprintf(buffer, L"%s", com.c_str()); _wsystem(buffer); } } } while (FindNextFileW(hFile, &findData)); FindClose(hFile); SetCurrentDirectoryW(current.c_str()); } return 0; }
void gravcalc(void) { double cpustart; vector rmid; if (active == NULL) { // if this is the 1st call actmax = FACTIVE * 216 * (tdepth + 1); // estimate list length #if !defined(QUICKSCAN) if (theta > 0.1) actmax = actmax * rpow(theta,-2.5); // allow for opening angle else actmax = 5.0 * ncell; // guess total node count #endif active = (nodeptr *) allocate(actmax * sizeof(nodeptr)); interact = (cellptr) allocate(actmax * sizeof(cell)); } cpustart = cputime(); // record time, less alloc acttot = nfcalc = nbbcalc = nbccalc = 0; // zero cumulative counters active[0] = (nodeptr) root; // initialize active list CLRV(rmid); // set center of root cell walktree(active, active + 1, interact, interact + actmax, (nodeptr) root, rsize, rmid); // scan tree, update forces cpuforce = cputime() - cpustart; // store CPU time w/o alloc }
void obj_code (uint4 src_lines, void *checksum_ctx) { int status; rhdtyp rhead; mline *mlx, *mly; var_tabent *vptr; int4 lnr_pad_len; intrpt_state_t prev_intrpt_state; DCL_THREADGBL_ACCESS; SETUP_THREADGBL_ACCESS; assert(!run_time); obj_init(); /* Define the routine name global symbol. */ define_symbol(GTM_MODULE_DEF_PSECT, (mstr *)&int_module_name, 0); memset(&rhead, 0, SIZEOF(rhead)); alloc_reg(); jmp_opto(); curr_addr = SIZEOF(rhdtyp); cg_phase = CGP_APPROX_ADDR; cg_phase_last = CGP_NOSTATE; code_gen(); code_size = curr_addr; cg_phase = CGP_ADDR_OPT; shrink_jmps(); comp_lits(&rhead); if ((cmd_qlf.qlf & CQ_MACHINE_CODE)) { cg_phase = CGP_ASSEMBLY; code_gen(); } if (!(cmd_qlf.qlf & CQ_OBJECT)) return; rhead.ptext_ptr = SIZEOF(rhead); set_rtnhdr_checksum(&rhead, (gtm_rtn_src_chksum_ctx *)checksum_ctx); rhead.vartab_ptr = code_size; rhead.vartab_len = mvmax; code_size += mvmax * SIZEOF(var_tabent); rhead.labtab_ptr = code_size; rhead.labtab_len = mlmax; code_size += mlmax * SIZEOF(lab_tabent); rhead.lnrtab_ptr = code_size; rhead.lnrtab_len = src_lines; rhead.compiler_qlf = cmd_qlf.qlf; if (cmd_qlf.qlf & CQ_EMBED_SOURCE) { rhead.routine_source_offset = TREF(routine_source_offset); rhead.routine_source_length = (uint4)(stringpool.free - stringpool.base) - TREF(routine_source_offset); } rhead.temp_mvals = sa_temps[TVAL_REF]; rhead.temp_size = sa_temps_offset[TCAD_REF]; code_size += src_lines * SIZEOF(int4); lnr_pad_len = PADLEN(code_size, SECTION_ALIGN_BOUNDARY); code_size += lnr_pad_len; DEFER_INTERRUPTS(INTRPT_IN_OBJECT_FILE_COMPILE, prev_intrpt_state); create_object_file(&rhead); ENABLE_INTERRUPTS(INTRPT_IN_OBJECT_FILE_COMPILE, prev_intrpt_state); cg_phase = CGP_MACHINE; code_gen(); /* Variable table: */ vptr = (var_tabent *)mcalloc(mvmax * SIZEOF(var_tabent)); if (mvartab) walktree(mvartab, cg_var, (char *)&vptr); else assert(0 == mvmax); emit_immed((char *)vptr, mvmax * SIZEOF(var_tabent)); /* Label table: */ if (mlabtab) walktree((mvar *)mlabtab, cg_lab, (char *)rhead.lnrtab_ptr); else assert(0 == mlmax); /* External entry definitions: */ emit_immed((char *)&(mline_root.externalentry->rtaddr), SIZEOF(mline_root.externalentry->rtaddr)); /* line 0 */ for (mlx = mline_root.child; mlx; mlx = mly) { if (mlx->table) emit_immed((char *)&(mlx->externalentry->rtaddr), SIZEOF(mlx->externalentry->rtaddr)); if (0 == (mly = mlx->child)) /* note assignment */ if (0 == (mly = mlx->sibling)) /* note assignment */ for (mly = mlx; ; ) { if (0 == (mly = mly->parent)) /* note assignment */ break; if (mly->sibling) { mly = mly->sibling; break; } } } if (0 != lnr_pad_len) /* emit padding so literal text pool starts on proper boundary */ emit_immed(PADCHARS, lnr_pad_len); # if !defined(__MVS__) && !defined(__s390__) /* assert not valid for instructions on OS390 */ assert(code_size == psect_use_tab[GTM_CODE]); # endif emit_literals(); DEFER_INTERRUPTS(INTRPT_IN_OBJECT_FILE_COMPILE, prev_intrpt_state); finish_object_file(); ENABLE_INTERRUPTS(INTRPT_IN_OBJECT_FILE_COMPILE, prev_intrpt_state); CLOSE_OBJECT_FILE(object_file_des, status); if (-1 == status) rts_error_csa(CSA_ARG(NULL) VARLSTCNT(8) ERR_SYSCALL, 5, RTS_ERROR_LITERAL("close()"), CALLFROM, errno); /* Ready to make object visible. Rename from tmp name to real routine name */ RENAME_TMP_OBJECT_FILE(object_file_name); }
void obj_code (uint4 src_lines, uint4 checksum) { rhdtyp rhead; mline *mlx, *mly; var_tabent *vptr; int4 lnr_pad_len; assert(!run_time); obj_init(); /* Define the routine name global symbol. */ define_symbol(GTM_MODULE_DEF_PSECT, (mstr *)&int_module_name, 0); memset(&rhead, 0, SIZEOF(rhead)); alloc_reg(); jmp_opto(); curr_addr = SIZEOF(rhdtyp); cg_phase = CGP_APPROX_ADDR; cg_phase_last = CGP_NOSTATE; code_gen(); code_size = curr_addr; cg_phase = CGP_ADDR_OPT; shrink_jmps(); comp_lits(&rhead); if ((cmd_qlf.qlf & CQ_MACHINE_CODE)) { cg_phase = CGP_ASSEMBLY; code_gen(); } if (!(cmd_qlf.qlf & CQ_OBJECT)) return; rhead.ptext_ptr = SIZEOF(rhead); rhead.checksum = checksum; rhead.vartab_ptr = code_size; rhead.vartab_len = mvmax; code_size += mvmax * SIZEOF(var_tabent); rhead.labtab_ptr = code_size; rhead.labtab_len = mlmax; code_size += mlmax * SIZEOF(lab_tabent); rhead.lnrtab_ptr = code_size; rhead.lnrtab_len = src_lines; rhead.compiler_qlf = cmd_qlf.qlf; rhead.temp_mvals = sa_temps[TVAL_REF]; rhead.temp_size = sa_temps_offset[TCAD_REF]; code_size += src_lines * SIZEOF(int4); lnr_pad_len = PADLEN(code_size, SECTION_ALIGN_BOUNDARY); code_size += lnr_pad_len; create_object_file(&rhead); cg_phase = CGP_MACHINE; code_gen(); /* Variable table: */ vptr = (var_tabent *)mcalloc(mvmax * SIZEOF(var_tabent)); if (mvartab) walktree(mvartab, cg_var, (char *)&vptr); else assert(0 == mvmax); emit_immed((char *)vptr, mvmax * SIZEOF(var_tabent)); /* Label table: */ if (mlabtab) walktree((mvar *)mlabtab, cg_lab, (char *)rhead.lnrtab_ptr); else assert(0 == mlmax); /* External entry definitions: */ emit_immed((char *)&(mline_root.externalentry->rtaddr), SIZEOF(mline_root.externalentry->rtaddr)); /* line 0 */ for (mlx = mline_root.child; mlx; mlx = mly) { if (mlx->table) emit_immed((char *)&(mlx->externalentry->rtaddr), SIZEOF(mlx->externalentry->rtaddr)); if (0 == (mly = mlx->child)) /* note assignment */ if (0 == (mly = mlx->sibling)) /* note assignment */ for (mly = mlx; ; ) { if (0 == (mly = mly->parent)) /* note assignment */ break; if (mly->sibling) { mly = mly->sibling; break; } } } if (0 != lnr_pad_len) /* emit padding so literal text pool starts on proper boundary */ emit_immed(PADCHARS, lnr_pad_len); #if !defined(__MVS__) && !defined(__s390__) /* assert not valid for instructions on OS390 */ assert(code_size == psect_use_tab[GTM_CODE]); #endif emit_literals(); close_object_file(); }