void end_forall_semantics (void) { int ir_idx; int list_idx; int sh_idx; TRACE (Func_Entry, "end_forall_semantics", NULL); sh_idx = SH_PARENT_BLK_IDX(curr_stmt_sh_idx); if (SH_ERR_FLG(curr_stmt_sh_idx) || SH_ERR_FLG(sh_idx)) { goto EXIT; } # ifdef _DEBUG if (sh_idx == NULL_IDX) { PRINTMSG(SH_GLB_LINE(curr_stmt_sh_idx), 626, Internal, SH_COL_NUM(curr_stmt_sh_idx), "SH_PARENT_BLK_IDX", "end_forall_semantics"); } # endif ir_idx = SH_IR_IDX(sh_idx); # ifdef _DEBUG if (IR_OPR(ir_idx) != Forall_Opr) { PRINTMSG(SH_GLB_LINE(curr_stmt_sh_idx), 626, Internal, SH_COL_NUM(curr_stmt_sh_idx), "Forall_Opr", "end_forall_semantics"); } # endif list_idx = IR_IDX_R(ir_idx); while (list_idx && IL_FLD(list_idx) == IL_Tbl_Idx) { AT_ATTR_LINK(IL_IDX(IL_IDX(list_idx))) = NULL_IDX; AT_IGNORE_ATTR_LINK(IL_IDX(IL_IDX(list_idx))) = FALSE; list_idx = IL_NEXT_LIST_IDX(list_idx); } EXIT: active_forall_sh_idx = SH_PARENT_BLK_IDX(active_forall_sh_idx); if (active_forall_sh_idx == NULL_IDX) { within_forall_construct = FALSE; } TRACE (Func_Exit, "end_forall_semantics", NULL); return; } /* end_forall_semantics */
static void print_id_line(void) { char version_string[16] = "######"; TRACE (Func_Exit, "print_id_line", NULL); /* The Cray (PVP/MPP) compiler id line is: */ /* */ /* Cray CF90 Version n.n.n (levels) curr-date curr-time */ /* */ /* The id line for other platforms may vary somewhat from this. */ # if (defined(_HOST_OS_IRIX) || defined(_HOST_OS_LINUX)) && !defined(_TARGET_SV2) sprintf(version_string, "%s%s", fe_vers_ID(), fe_vers_number()); # elif defined(_HOST_OS_SOLARIS) sprintf(version_string, "%s%s%s%s%s%s%s%s", fe_vers_ID(), fe_vers_number(), "p", "XX", "g", "XXX", arith_vers_ID(), arith_vers_number()); # else sprintf(version_string, "%s%s%s%s%s%s%s%s", fe_vers_ID(), fe_vers_number(), opt_vers_ID(), opt_vers_number(), be_vers_ID(), be_vers_number(), arith_vers_ID(), arith_vers_number()); # endif # if (defined(_HOST_OS_IRIX) || defined(_HOST_OS_LINUX)) && (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX)) PRINTMSG (0, 1402, Log_Summary, 0, release_level, version_string, comp_date_time); # else PRINTMSG (0, 103, Log_Summary, 0, release_level, version_string, comp_date_time); # endif TRACE (Func_Exit, "print_id_line", NULL); return; } /* print_id_line */
/* * upap_rauthack - Receive Authenticate-Ack. */ static void upap_rauthack(upap_state *u, u_char *inp, int id, int len) { u_char msglen; char *msg; LWIP_UNUSED_ARG(id); UPAPDEBUG((LOG_INFO, "pap_rauthack: Rcvd id %d s=%d\n", id, u->us_clientstate)); if (u->us_clientstate != UPAPCS_AUTHREQ) { /* XXX */ return; } /* * Parse message. */ if (len < sizeof (u_char)) { UPAPDEBUG((LOG_INFO, "pap_rauthack: rcvd short packet.\n")); return; } GETCHAR(msglen, inp); len -= sizeof (u_char); if (len < msglen) { UPAPDEBUG((LOG_INFO, "pap_rauthack: rcvd short packet.\n")); return; } msg = (char *) inp; PRINTMSG(msg, msglen); UNTIMEOUT(upap_timeout, u); /* Cancel timeout */ u->us_clientstate = UPAPCS_OPEN; auth_withpeer_success(u->us_unit, PPP_PAP); }
/* * ChapReceiveSuccess - Receive Success */ static void ChapReceiveSuccess( chap_state *cstate, u_char *inp, u_char id, int len) { if (cstate->clientstate == CHAPCS_OPEN) /* presumably an answer to a duplicate response */ return; if (cstate->clientstate != CHAPCS_RESPONSE) { /* don't know what this is */ CHAPDEBUG(("ChapReceiveSuccess: in state %d\n", cstate->clientstate)); return; } UNTIMEOUT(ChapResponseTimeout, cstate); /* * Print message. */ if (len > 0) PRINTMSG(inp, len); cstate->clientstate = CHAPCS_OPEN; auth_withpeer_success(cstate->unit, PPP_CHAP); }
/* * upap_rauthnak - Receive Authenticate-Nak. */ static void upap_rauthnak(ppp_pcb *pcb, u_char *inp, int id, int len) { u_char msglen; char *msg; LWIP_UNUSED_ARG(id); if (pcb->upap.us_clientstate != UPAPCS_AUTHREQ) /* XXX */ return; /* * Parse message. */ if (len < 1) { UPAPDEBUG(("pap_rauthnak: ignoring missing msg-length.")); } else { GETCHAR(msglen, inp); if (msglen > 0) { len -= sizeof (u_char); if (len < msglen) { UPAPDEBUG(("pap_rauthnak: rcvd short packet.")); return; } msg = (char *) inp; PRINTMSG(msg, msglen); } } pcb->upap.us_clientstate = UPAPCS_BADAUTH; ppp_error("PAP authentication failed"); auth_withpeer_fail(pcb, PPP_PAP); }
static Evas* create_canvas(int width, int height) { Evas *canvas; Evas_Engine_Info_Buffer *einfo; int method; void *pixels; method = evas_render_method_lookup("buffer"); if (unlikely(method <= 0)) { //fputs("ERROR: evas was not compiled with 'buffer' engine!\n", stderr); return NULL; } canvas = evas_new(); if (unlikely(canvas == NULL)) { //fputs("ERROR: could not instantiate new evas canvas.\n", stderr); return NULL; } evas_output_method_set(canvas, method); evas_output_size_set(canvas, width, height); evas_output_viewport_set(canvas, 0, 0, width, height); einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(canvas); if (unlikely(einfo == NULL)) { //fputs("ERROR: could not get evas engine info!\n", stderr); evas_free(canvas); return NULL; } // ARGB32 is sizeof(int), that is 4 bytes, per pixel pixels = real_malloc(width * height * sizeof(int)); if (unlikely(pixels == NULL)) { //fputs("ERROR: could not allocate canvas pixels!\n", stderr); evas_free(canvas); return NULL; } einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32; einfo->info.dest_buffer = pixels; einfo->info.dest_buffer_row_bytes = width * sizeof(int); einfo->info.use_color_key = 0; einfo->info.alpha_threshold = 0; einfo->info.func.new_update_region = NULL; einfo->info.func.free_update_region = NULL; if (unlikely(evas_engine_info_set(canvas,(Evas_Engine_Info*)einfo) == EINA_FALSE)) { PRINTMSG("ERROR: could not set evas engine info!\n"); evas_free(canvas); return NULL; } return canvas; }
int main(int argc, char **argv) { signal(SIGSEGV, handler); signal(SIGABRT, handler); PRINT_INIT_STD(); int ret = run(argc, argv); PRINTMSG("Result of run(): " << ret); return 0; }
/******************************************************************************\ |* *| |* Description: *| |* Check to make sure that the opr enum has only been changed at the *| |* bottom. This is not a failsafe check, but it is designed to make *| |* sure that nothing gets added or deleted at least. *| |* *| |* Input parameters: *| |* NONE *| |* *| |* Output parameters: *| |* NONE *| |* *| |* Returns: *| |* NOTHING *| |* *| \******************************************************************************/ static void check_enums_for_change(void) { TRACE (Func_Entry, "check_enums_for_change", NULL); if (Null_Opr != 0 || Defined_Un_Opr != 1 || Alloc_Opr != 2 || Eqv_Opr != 25 || Nint_Opr != 50 || Char_Opr != 75 || Rrspacing_Opr != 100 || Minval_Opr != 125 || Stop_Opr != 150 || Dv_Set_A_Contig != 175 || Aloc_Opr != 200 || Init_Reloc_Opr != 225 || Prefertask_Cdir_Opr != 250 || Wait_Cmic_Opr != 275 || Set_Ieee_Exception_Opr != 300 || Local_Pe_Dim_Opr != 325 || Fissionable_Star_Opr != 350 || End_Singleprocess_Par_Opr != 375 || Fetch_And_Nand_Opr != 400 || Endparallel_Open_Mp_Opr != 425 || Omp_In_Parallel_Opr != 454 || Io_Item_Type_Code_Opr != 479 || Copyin_Bound_Opr != 484) { /* modified by jhs, 02.8.31 */ # if 0 printf("Char_Opr %d\n ", Char_Opr); printf("Stop_Opr %d\n ", Stop_Opr); printf("Aloc_Opr %d\n ", Aloc_Opr); printf("Prefertask_Cdir_Opr %d\n ", Prefertask_Cdir_Opr); printf("Local_Pe_Dim_Opr %d\n ", Local_Pe_Dim_Opr); printf("Fetch_And_Nand_Opr %d\n ", Fetch_And_Nand_Opr); printf("Omp_In_Parallel_Opr %d\n ", Omp_In_Parallel_Opr); printf("Copyin_Bound_Opr %d\n ", Copyin_Bound_Opr); # endif PRINTMSG(1, 1643, Internal, 0, "Operator"); } TRACE (Func_Exit, "check_enums_for_change", NULL); return; } /* check_enums_for_change */
/* * upap_rauthnak - Receive Authenticate-Nakk. */ static void upap_rauthnak(upap_state *u, u_char *inp, int id, int len) { u_char msglen; char *msg; LWIP_UNUSED_ARG(id); UPAPDEBUG((LOG_INFO, "pap_rauthnak: Rcvd id %d s=%d\n", id, u->us_clientstate)); if (u->us_clientstate != UPAPCS_AUTHREQ) { /* XXX */ return; } /* * Parse message. */ if (len < sizeof (u_char)) { UPAPDEBUG((LOG_INFO, "pap_rauthnak: rcvd short packet.\n")); } else { GETCHAR(msglen, inp); if(msglen > 0) { len -= sizeof (u_char); if (len < msglen) { UPAPDEBUG((LOG_INFO, "pap_rauthnak: rcvd short packet.\n")); return; } msg = (char *) inp; PRINTMSG(msg, msglen); } } u->us_clientstate = UPAPCS_BADAUTH; UPAPDEBUG((LOG_ERR, "PAP authentication failed\n")); auth_withpeer_fail(u->us_unit, PPP_PAP); }
/* * ChapReceiveFailure - Receive failure. */ static void ChapReceiveFailure( chap_state *cstate, u_char *inp, u_char id, int len) { if (cstate->clientstate != CHAPCS_RESPONSE) { /* don't know what this is */ CHAPDEBUG(("ChapReceiveFailure: in state %d\n", cstate->clientstate)); return; } UNTIMEOUT(ChapResponseTimeout, cstate); /* * Print message. */ if (len > 0) PRINTMSG(inp, len); error("CHAP authentication failed"); auth_withpeer_fail(cstate->unit, PPP_CHAP); }
int main(int argc, char **argv) { signal(SIGSEGV, handler); signal(SIGABRT, handler); ros::init(argc, argv, "grasp_planning_graspit_service", ros::init_options::AnonymousName); bool useRosLogging = true; if (useRosLogging) { PRINT_INIT_ROS(); } else { PRINT_INIT_STD(); } GraspIt::GraspItServices s; s.start(); ros::spin(); PRINTMSG("Quitting services."); }
int main(int argc, char **argv) { signal(SIGSEGV, handler); signal(SIGABRT, handler); PRINT_INIT_STD(); std::string worldFilename; std::string robotFilename; std::string objectFilename; std::string outputDirectory; bool saveSeparate; Eigen::Vector3d objPos; int maxPlanningSteps = 50000; if (!loadParams(argc, argv, worldFilename, robotFilename, objectFilename, outputDirectory, saveSeparate, objPos, maxPlanningSteps)) { PRINTERROR("Could not read arguments"); return 1; } PRINTMSG("Creating planner"); std::string name = "EigenGraspPlanner1"; // TODO make parameter SHARED_PTR<GraspIt::GraspItSceneManager> graspitMgr(new GraspIt::GraspItSceneManagerHeadless()); #ifdef USE_EIGENGRASP_NOQT SHARED_PTR<GraspIt::EigenGraspPlannerNoQt> p(new GraspIt::EigenGraspPlannerNoQt(name, graspitMgr)); #else SHARED_PTR<GraspIt::EigenGraspPlanner> p(new GraspIt::EigenGraspPlanner(name, graspitMgr)); #endif // TODO parameterize: // Names for robot and object if not loaded from a world file. // If loaded from a world file, will be overwritten. std::string useRobotName="Robot1"; std::string useObjectName="Object1"; if (!worldFilename.empty()) { PRINTMSG("Loading world"); graspitMgr->loadWorld(worldFilename); std::vector<std::string> robs = graspitMgr->getRobotNames(); std::vector<std::string> objs = graspitMgr->getObjectNames(true); if (robs.empty()) { PRINTERROR("No robots loaded"); return 1; } if (objs.empty()) { PRINTERROR("No graspable objects loaded"); return 1; } if (robs.size()!=1) { PRINTERROR("Exactly 1 robot should have been loaded"); return 1; } if (objs.size()!=1) { PRINTERROR("Exactly 1 graspable object should have been loaded"); return 1; } useRobotName=robs.front(); useObjectName=objs.front(); PRINTMSG("Using robot "<<useRobotName<<" and object "<<useObjectName); } else { // TODO add an option to set the transforms. // For now, they're put in the origin. For the planning, this should not really matter... GraspIt::EigenTransform robotTransform; GraspIt::EigenTransform objectTransform; robotTransform.setIdentity(); objectTransform.setIdentity(); objectTransform.translate(objPos); // objectTransform.translate(Eigen::Vector3d(100,0,0)); std::string robotName(useRobotName); std::string objectName(useObjectName); if ((graspitMgr->loadRobot(robotFilename, robotName, robotTransform) != 0) || (graspitMgr->loadObject(objectFilename, objectName, true, objectTransform))) { PRINTERROR("Could not load robot or object"); return 1; } } bool createDir = true; bool saveIV = true; bool forceWrite = createDir; // only enforce if creating dir is also allowed // in case one wants to view the initial world before planning, save it: graspitMgr->saveGraspItWorld(outputDirectory + "/startWorld.xml", createDir); graspitMgr->saveInventorWorld(outputDirectory + "/startWorld.iv", createDir); if (saveSeparate) { graspitMgr->saveRobotAsInventor(outputDirectory + "/robotStartpose.iv", useRobotName, createDir, forceWrite); graspitMgr->saveObjectAsInventor(outputDirectory + "/object.iv", useObjectName, createDir, forceWrite); } int repeatPlanning = 1; int keepMaxPlanningResults = 3; bool finishWithAutograsp = false; p->plan(maxPlanningSteps, repeatPlanning, keepMaxPlanningResults, finishWithAutograsp); PRINTMSG("Saving results as world files"); bool saveWorld = true; std::string resultsWorldDirectory = outputDirectory; std::string filenamePrefix = "world"; p->saveResultsAsWorldFiles(resultsWorldDirectory, filenamePrefix, saveWorld, saveIV, createDir, saveSeparate); std::vector<GraspIt::EigenGraspResult> allGrasps; p->getResults(allGrasps); PRINTMSG("Grasp results:"); std::vector<GraspIt::EigenGraspResult>::iterator it; for (it = allGrasps.begin(); it != allGrasps.end(); ++it) { PRINTMSG(*it); } PRINTMSG("Quitting program."); return 1; }
bool loadParams(int argc, char ** argv, std::string& worldFilename, std::string& robotFilename, std::string& objectFilename, std::string& outputDirectory, bool& saveSeparate, Eigen::Vector3d& objPos, int& maxIterations) { saveSeparate = false; worldFilename.clear(); robotFilename.clear(); objectFilename.clear(); outputDirectory.clear(); boost::program_options::variables_map vm; try { vm = loadParams(argc, argv); } catch (std::exception const& e) { PRINTERROR("Exception caught: " << e.what()); return false; } catch (...) { PRINTERROR("Exception caught"); return false; } boost::program_options::options_description desc = getOptions(); // desc=getOptions(); if (vm.count("help")) { PRINTMSG(desc); return false; } if (vm.count("dir") < 1) { PRINTERROR("Must specify an output directory"); PRINTMSG(desc); return false; } if (vm.count("wld") && (vm.count("rob") || vm.count("obj"))) { PRINTERROR("Cannot specify a world and a robot and/or object at the same time."); PRINTMSG(desc); return false; } if (!vm.count("wld") && !vm.count("rob")) { PRINTERROR("Have to specify either a robot or a world."); PRINTMSG(desc); return false; } if (vm.count("rob") != vm.count("obj")) { PRINTERROR("If you specify a robot, you also have to specify an object, and vice versa."); PRINTMSG(desc); return false; } if (vm.count("rob") > 1) { PRINTERROR("You can only specify one robot at this stage."); PRINTMSG(desc); return false; } if (vm.count("obj") > 1) { PRINTERROR("You can only specify one object at this stage."); PRINTMSG(desc); return false; } if (vm.count("obj") != vm.count("rob")) { PRINTERROR("If you specify a robot, you should also specify an object."); PRINTMSG(desc); return false; } if (vm.count("wld")) { worldFilename = vm["wld"].as<std::string>(); PRINTMSG("World file is " << worldFilename); } if (vm.count("rob")) { robotFilename = vm["rob"].as<std::string>(); PRINTMSG("Robot file is " << robotFilename); } if (vm.count("obj")) { objectFilename = vm["obj"].as<std::string>(); PRINTMSG("Object file is " << objectFilename); } if (vm.count("dir")) { outputDirectory = vm["dir"].as<std::string>(); PRINTMSG("Output dir is " << outputDirectory); } if (vm.count("iter")) { maxIterations = vm["iter"].as<int>(); PRINTMSG("Number of iterations: " << maxIterations); if (maxIterations < 35000) { PRINTWARN("Planning is not working well with max iterations < 35000"); } } if (vm.count("obj-pos")) { std::vector<float> vals=vm["obj-pos"].as<std::vector<float> >(); if (vals.size()!=3) { PRINTERROR("Must specify 3 values for --obj-pos: x, y and z (specified "<<vals.size()<<")"); PRINTMSG(desc); } PRINTMSG("Using initial object pose "<<vals[0]<<", "<<vals[1]<<", "<<vals[2]); objPos=Eigen::Vector3d(vals[0],vals[1],vals[2]); } if (vm.count("save-separate")) { saveSeparate=true; } return true; }
int main(int argc, char **argv) { int error, i, quit; int curx, cury, maxx, maxy, line_len, loop, max_flen; struct devstat *gsp, *gsq; void *sp, *sq; double dt; struct timespec tp, tq; struct gmesh gmp; struct gprovider *pp; struct gconsumer *cp; struct gident *gid; regex_t f_re, tmp_f_re; short cf, cb; char *p; char f_s[100], pf_s[100], tmp_f_s[100]; const char *line; long double ld[13]; uint64_t u64; EditLine *el; History *hist; HistEvent hist_ev; hist = NULL; el = NULL; maxx = -1; curx = -1; loop = 1; /* Turn on batch mode if output is not tty. */ if (!isatty(fileno(stdout))) flag_b = 1; f_s[0] = '\0'; while ((i = getopt(argc, argv, "abdcf:I:op")) != -1) { switch (i) { case 'a': flag_a = 1; break; case 'b': flag_b = 1; break; case 'c': flag_c = 1; break; case 'd': flag_d = 1; break; case 'f': if (strlen(optarg) > sizeof(f_s) - 1) errx(EX_USAGE, "Filter string too long"); if (regcomp(&f_re, optarg, REG_EXTENDED) != 0) errx(EX_USAGE, "Invalid filter - see re_format(7)"); strncpy(f_s, optarg, sizeof(f_s)); break; case 'o': flag_o = 1; break; case 'I': p = NULL; i = strtoul(optarg, &p, 0); if (p == optarg || errno == EINVAL || errno == ERANGE) { errx(1, "Invalid argument to -I"); } else if (!strcmp(p, "s")) i *= 1000000; else if (!strcmp(p, "ms")) i *= 1000; else if (!strcmp(p, "us")) i *= 1; flag_I = i; break; case 'p': flag_p = 1; break; case '?': default: usage(); } } argc -= optind; argv += optind; if (argc != 0) usage(); i = geom_gettree(&gmp); if (i != 0) err(1, "geom_gettree = %d", i); error = geom_stats_open(); if (error) err(1, "geom_stats_open()"); sq = NULL; sq = geom_stats_snapshot_get(); if (sq == NULL) err(1, "geom_stats_snapshot()"); if (!flag_b) { /* Setup curses */ initscr(); start_color(); use_default_colors(); pair_content(0, &cf, &cb); init_pair(1, COLOR_GREEN, cb); init_pair(2, COLOR_MAGENTA, cb); init_pair(3, COLOR_RED, cb); cbreak(); noecho(); nonl(); nodelay(stdscr, 1); intrflush(stdscr, FALSE); keypad(stdscr, TRUE); /* Setup libedit */ hist = history_init(); if (hist == NULL) err(EX_SOFTWARE, "history_init()"); history(hist, &hist_ev, H_SETSIZE, 100); el = el_init("gstat", stdin, stdout, stderr); if (el == NULL) err(EX_SOFTWARE, "el_init"); el_set(el, EL_EDITOR, "emacs"); el_set(el, EL_SIGNAL, 1); el_set(el, EL_HIST, history, hist); el_set(el, EL_PROMPT, el_prompt); if (f_s[0] != '\0') history(hist, &hist_ev, H_ENTER, f_s); } geom_stats_snapshot_timestamp(sq, &tq); for (quit = 0; !quit;) { sp = geom_stats_snapshot_get(); if (sp == NULL) err(1, "geom_stats_snapshot()"); geom_stats_snapshot_timestamp(sp, &tp); dt = tp.tv_sec - tq.tv_sec; dt += (tp.tv_nsec - tq.tv_nsec) * 1e-9; tq = tp; geom_stats_snapshot_reset(sp); geom_stats_snapshot_reset(sq); move(0,0); PRINTMSG("dT: %5.3fs w: %.3fs", dt, (float)flag_I / 1000000); if (f_s[0] != '\0') { PRINTMSG(" filter: "); if (!flag_b) { getyx(stdscr, cury, curx); getmaxyx(stdscr, maxy, maxx); } strncpy(pf_s, f_s, sizeof(pf_s)); max_flen = maxx - curx - 1; if ((int)strlen(f_s) > max_flen && max_flen >= 0) { if (max_flen > 3) pf_s[max_flen - 3] = '.'; if (max_flen > 2) pf_s[max_flen - 2] = '.'; if (max_flen > 1) pf_s[max_flen - 1] = '.'; pf_s[max_flen] = '\0'; } PRINTMSG("%s", pf_s); } PRINTMSG("\n"); PRINTMSG(" L(q) ops/s "); PRINTMSG(" r/s kBps ms/r "); PRINTMSG(" w/s kBps ms/w "); if (flag_d) PRINTMSG(" d/s kBps ms/d "); if (flag_o) PRINTMSG(" o/s ms/o "); PRINTMSG("%%busy Name\n"); for (;;) { gsp = geom_stats_snapshot_next(sp); gsq = geom_stats_snapshot_next(sq); if (gsp == NULL || gsq == NULL) break; if (gsp->id == NULL) continue; gid = geom_lookupid(&gmp, gsp->id); if (gid == NULL) { geom_deletetree(&gmp); i = geom_gettree(&gmp); if (i != 0) err(1, "geom_gettree = %d", i); gid = geom_lookupid(&gmp, gsp->id); } if (gid == NULL) continue; if (gid->lg_what == ISCONSUMER && !flag_c) continue; if (flag_p && gid->lg_what == ISPROVIDER && ((struct gprovider *)(gid->lg_ptr))->lg_geom->lg_rank != 1) continue; /* Do not print past end of window */ if (!flag_b) { getyx(stdscr, cury, curx); if (curx > 0) continue; } if ((gid->lg_what == ISPROVIDER || gid->lg_what == ISCONSUMER) && f_s[0] != '\0') { pp = gid->lg_ptr; if ((regexec(&f_re, pp->lg_name, 0, NULL, 0) != 0)) continue; } if (gsp->sequence0 != gsp->sequence1) { PRINTMSG("*\n"); continue; } devstat_compute_statistics(gsp, gsq, dt, DSM_QUEUE_LENGTH, &u64, DSM_TRANSFERS_PER_SECOND, &ld[0], DSM_TRANSFERS_PER_SECOND_READ, &ld[1], DSM_MB_PER_SECOND_READ, &ld[2], DSM_MS_PER_TRANSACTION_READ, &ld[3], DSM_TRANSFERS_PER_SECOND_WRITE, &ld[4], DSM_MB_PER_SECOND_WRITE, &ld[5], DSM_MS_PER_TRANSACTION_WRITE, &ld[6], DSM_BUSY_PCT, &ld[7], DSM_TRANSFERS_PER_SECOND_FREE, &ld[8], DSM_MB_PER_SECOND_FREE, &ld[9], DSM_MS_PER_TRANSACTION_FREE, &ld[10], DSM_TRANSFERS_PER_SECOND_OTHER, &ld[11], DSM_MS_PER_TRANSACTION_OTHER, &ld[12], DSM_NONE); if (flag_a && ld[7] < 0.1) { *gsq = *gsp; continue; } PRINTMSG(" %4ju", (uintmax_t)u64); PRINTMSG(" %6.0f", (double)ld[0]); PRINTMSG(" %6.0f", (double)ld[1]); PRINTMSG(" %6.0f", (double)ld[2] * 1024); if (ld[3] > 1e3) PRINTMSG(" %6.0f", (double)ld[3]); else PRINTMSG(" %6.1f", (double)ld[3]); PRINTMSG(" %6.0f", (double)ld[4]); PRINTMSG(" %6.0f", (double)ld[5] * 1024); if (ld[6] > 1e3) PRINTMSG(" %6.0f", (double)ld[6]); else PRINTMSG(" %6.1f", (double)ld[6]); if (flag_d) { PRINTMSG(" %6.0f", (double)ld[8]); PRINTMSG(" %6.0f", (double)ld[9] * 1024); if (ld[10] > 1e3) PRINTMSG(" %6.0f", (double)ld[10]); else PRINTMSG(" %6.1f", (double)ld[10]); } if (flag_o) { PRINTMSG(" %6.0f", (double)ld[11]); if (ld[12] > 1e3) PRINTMSG(" %6.0f", (double)ld[12]); else PRINTMSG(" %6.1f", (double)ld[12]); } if (ld[7] > 80) i = 3; else if (ld[7] > 50) i = 2; else i = 1; if (!flag_b) attron(COLOR_PAIR(i)); PRINTMSG(" %6.1lf", (double)ld[7]); if (!flag_b) { attroff(COLOR_PAIR(i)); PRINTMSG("|"); } else PRINTMSG(" "); if (gid == NULL) { PRINTMSG(" ??"); } else if (gid->lg_what == ISPROVIDER) { pp = gid->lg_ptr; PRINTMSG(" %s", pp->lg_name); } else if (gid->lg_what == ISCONSUMER) { cp = gid->lg_ptr; PRINTMSG(" %s/%s/%s", cp->lg_geom->lg_class->lg_name, cp->lg_geom->lg_name, cp->lg_provider->lg_name); } if (!flag_b) clrtoeol(); PRINTMSG("\n"); *gsq = *gsp; } geom_stats_snapshot_free(sp); if (flag_b) { /* We loop extra to make sure we get the information. */ if (!loop) break; loop = 0; usleep(flag_I); continue; } getyx(stdscr, cury, curx); getmaxyx(stdscr, maxy, maxx); clrtobot(); if (maxy - 1 <= cury) move(maxy - 1, 0); refresh(); usleep(flag_I); while((i = getch()) != ERR) { switch (i) { case '>': flag_I *= 2; break; case '<': flag_I /= 2; if (flag_I < 1000) flag_I = 1000; break; case 'c': flag_c = !flag_c; break; case 'f': move(0,0); clrtoeol(); refresh(); line = el_gets(el, &line_len); if (line == NULL) err(1, "el_gets"); if (line_len > 1) history(hist, &hist_ev, H_ENTER, line); strncpy(tmp_f_s, line, sizeof(f_s)); if ((p = strchr(tmp_f_s, '\n')) != NULL) *p = '\0'; /* * We have to clear since we messed up * curses idea of the screen by using * libedit. */ clear(); refresh(); if (regcomp(&tmp_f_re, tmp_f_s, REG_EXTENDED) != 0) { move(0, 0); printw("Invalid filter"); refresh(); sleep(1); } else { strncpy(f_s, tmp_f_s, sizeof(f_s)); f_re = tmp_f_re; } break; case 'F': f_s[0] = '\0'; break; case 'q': quit = 1; break; default: break; } } } if (!flag_b) { endwin(); el_end(el); } exit(EX_OK); }
int main(int argc, char *argv[]) { Teuchos::GlobalMPISession session(&argc, &argv); Teuchos::RCP<const Zoltan2::Environment> env = rcp(new Zoltan2::Environment); int ierr = 0; /////////////////////////////////////////////////////////// // Test conversions into integers // Assignments that should always work // (since the zgno value fits in an integer) int intIdx; try { int zgno = 123; Zoltan2::TPL_Traits<int,int>::ASSIGN_TPL_T(intIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: int to int"); ierr++; } try { unsigned int zgno = 123; Zoltan2::TPL_Traits<int,unsigned int>::ASSIGN_TPL_T(intIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: unsigned int to int"); ierr++; } try { long zgno = 123; Zoltan2::TPL_Traits<int,long>::ASSIGN_TPL_T(intIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: long to int"); ierr++; } try { size_t zgno = 123; Zoltan2::TPL_Traits<int,size_t>::ASSIGN_TPL_T(intIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: size_t to int"); ierr++; } // Assignments that should not work try { long long zgno = (long long)1 << 40; Zoltan2::TPL_Traits<int,long long>::ASSIGN_TPL_T(intIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("GOOD: big long long to int throws exception"); } try { size_t zgno = (size_t)1 << 40; Zoltan2::TPL_Traits<int,size_t>::ASSIGN_TPL_T(intIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("GOOD: big size_t to int throws exception"); } try { unsigned zgno = (1 << 31) + 1; Zoltan2::TPL_Traits<int,unsigned>::ASSIGN_TPL_T(intIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("GOOD: huge unsigned to int throws exception"); } /////////////////////////////////////////////////////////// // Test conversions into size_t // Assignments that should always work size_t sizetIdx; try { long long zgno = (long long)1 << 40; Zoltan2::TPL_Traits<size_t,long long>::ASSIGN_TPL_T(sizetIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: big long long to size_t"); ierr++; } try { size_t zgno = (size_t)1 << 40; Zoltan2::TPL_Traits<size_t,size_t>::ASSIGN_TPL_T(sizetIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: big size_t to size_t"); ierr++; } /////////////////////////////////////////////////////////// // Test conversions into int64_t // Assignments that should always work int64_t int64Idx; try { long long zgno = (long long)1 << 40; Zoltan2::TPL_Traits<int64_t,long long>::ASSIGN_TPL_T(int64Idx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: big long long to int64_t"); ierr++; } try { size_t zgno = (size_t)1 << 40; Zoltan2::TPL_Traits<int64_t,size_t>::ASSIGN_TPL_T(int64Idx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: big size_t to int64_t"); ierr++; } // Assignments that should not work try { size_t zgno = ((size_t)1 << 63) + 1 ; Zoltan2::TPL_Traits<int64_t,size_t>::ASSIGN_TPL_T(int64Idx, zgno, env); } catch (std::exception &e) { PRINTMSG("GOOD: huge size_t to int64_t threw exception"); } #ifdef HAVE_ZOLTAN2_SCOTCH /////////////////////////////////////////////////////////// // Test conversions into SCOTCH_Num SCOTCH_Num scotchIdx; // Assignments that should always work // (since the zgno value fits in an integer) try { int zgno = 123; Zoltan2::TPL_Traits<SCOTCH_Num,int>::ASSIGN_TPL_T(scotchIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: int to SCOTCH_Num"); ierr++; } try { unsigned int zgno = 123; Zoltan2::TPL_Traits<SCOTCH_Num,unsigned int>::ASSIGN_TPL_T(scotchIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: unsigned int to SCOTCH_Num"); ierr++; } try { long zgno = 123; Zoltan2::TPL_Traits<SCOTCH_Num,long>::ASSIGN_TPL_T(scotchIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: long to SCOTCH_Num"); ierr++; } try { size_t zgno = 123; Zoltan2::TPL_Traits<SCOTCH_Num,size_t>::ASSIGN_TPL_T(scotchIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: size_t to SCOTCH_Num"); ierr++; } if (sizeof(SCOTCH_Num) == 8) { try { long long zgno = (long long)1 << 40; Zoltan2::TPL_Traits<SCOTCH_Num,long long>::ASSIGN_TPL_T(scotchIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: big unsigned int to SCOTCH_Num"); ierr++; } try { size_t zgno = (size_t)1 << 40; Zoltan2::TPL_Traits<SCOTCH_Num,size_t>::ASSIGN_TPL_T(scotchIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: big size_t to SCOTCH_Num"); ierr++; } } // Assignments that should not work if (sizeof(SCOTCH_Num) == 4) { try { long long zgno = (long long)1 << 40; Zoltan2::TPL_Traits<SCOTCH_Num,long long>::ASSIGN_TPL_T(scotchIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("GOOD: big long long to 4-byte SCOTCH_Num throws exception"); } try { size_t zgno = (size_t)1 << 40; Zoltan2::TPL_Traits<SCOTCH_Num,size_t>::ASSIGN_TPL_T(scotchIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("GOOD: big size_t to 4-byte SCOTCH_Num throws exception"); } } #endif // HAVE_ZOLTAN2_SCOTCH #ifdef PARMETIS_IS_OK /////////////////////////////////////////////////////////// // Test conversions into ParMETIS' idx_t idx_t parmetisIdx; // Assignments that should always work // (since the zgno value fits in an integer) try { int zgno = 123; Zoltan2::TPL_Traits<idx_t,int>::ASSIGN_TPL_T(parmetisIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: int to ParMETIS' idx_t"); ierr++; } try { unsigned int zgno = 123; Zoltan2::TPL_Traits<idx_t,unsigned int>::ASSIGN_TPL_T(parmetisIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: unsigned int to ParMETIS' idx_t"); ierr++; } try { long zgno = 123; Zoltan2::TPL_Traits<idx_t,long>::ASSIGN_TPL_T(parmetisIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: long to ParMETIS' idx_t"); ierr++; } try { size_t zgno = 123; Zoltan2::TPL_Traits<idx_t,size_t>::ASSIGN_TPL_T(parmetisIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: size_t to ParMETIS' idx_t"); ierr++; } if (sizeof(idx_t) == 8) { try { long long zgno = (long long)1 << 40; Zoltan2::TPL_Traits<idx_t,long long>::ASSIGN_TPL_T(parmetisIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: big unsigned int to ParMETIS' idx_t"); ierr++; } try { size_t zgno = (size_t)1 << 40; Zoltan2::TPL_Traits<idx_t,size_t>::ASSIGN_TPL_T(parmetisIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("FAIL: big size_t to ParMETIS' idx_t"); ierr++; } } // Assignments that should not work if (sizeof(idx_t) == 4) { try { long long zgno = (long long)1 << 40; Zoltan2::TPL_Traits<idx_t,long long>::ASSIGN_TPL_T(parmetisIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("GOOD: big long long to 4-byte ParMETIS' idx_t throws exception"); } try { size_t zgno = (size_t)1 << 40; Zoltan2::TPL_Traits<idx_t,size_t>::ASSIGN_TPL_T(parmetisIdx, zgno, env); } catch (std::exception &e) { PRINTMSG("GOOD: big size_t to 4-byte ParMETIS' idx_t throws exception"); } } #endif /////////////////////////////////////////////////////////// if (ierr == 0) std::cout << "PASS" << std::endl; else std::cout << "FAIL" << std::endl; return 0; }
int main (int argc, char *argv[]) # endif { int column_num; long field_len; int line_num; char *msg_name; int save_statement_number = 0; # if (defined(_HOST_OS_IRIX) || defined(_HOST_OS_LINUX)) double end_time; double start_time; /* char time[20]; */ double total_cpu_time; struct rusage ru; # else # if !defined(_HOST_OS_UNICOS) long end_clock; # endif float end_time; float start_time; float total_cpu_time; # endif # if defined(_HOST_OS_UNICOS) && defined(_DEBUG) lowmem_check(); # endif # if defined(_TARGET32) && defined(_DEBUG) setbuf(stdout, NULL); setbuf(stderr, NULL); # endif # if defined(_HOST_OS_UNICOS) /* Lots of start up - ignore first call. See the comment block that */ /* precedes procedure cif_summary_rec in fecif.c for a discussion of the */ /* timing methods used by the different platforms. */ SECOND(&start_time); /* M_LOWFIT will eventually be in malloc.h. */ /* When it is remove this definition. */ # define M_LOWFIT 0107 /* Use lowest-fit algorithm for allocation. */ mallopt(M_LOWFIT, 1); # elif defined(_HOST_OS_MAX) /* Use clock() on MPP's (in particular T3E's) because at the time this */ /* change was made, neither SECOND() nor SECONDR() worked on T3E's. */ /* LRR 4 Mar 1997 */ clock(); start_time = 0; /* M_LOWFIT will eventually be in malloc.h. */ /* When it is remove this definition. */ # define M_LOWFIT 0107 /* Use lowest-fit algorithm for allocation. */ mallopt(M_LOWFIT, 1); # elif defined(_HOST_OS_SOLARIS) /* clock() is only semi-useful on a Sun because it rolls over in just over */ /* 2147 seconds (about 36 minutes). So on a Sun, we use clock() and */ /* time() both. If elapsed time <= 2147 seconds, the accounting info will */ /* show milliseconds (from clock()), else it will show seconds (because */ /* that is the accuracy of time()). This resolution should be good enough */ /* for a compilation exceeding 36 minutes. */ start_time = (float) time(NULL); clock(); # elif (defined(_HOST_OS_IRIX) || defined(_HOST_OS_LINUX)) getrusage (RUSAGE_SELF, &ru); start_time = (double) ru.ru_utime.tv_sec + (double) ru.ru_utime.tv_usec * 1e-6 + (double) ru.ru_stime.tv_sec + (double) ru.ru_stime.tv_usec * 1e-6; # else start_time = 0; # endif comp_phase = Pass1_Parsing; stmt_start_line = 1; /* Set in case mem problems */ init_compiler(argc, argv); /* init and process cmd line */ if (on_off_flags.preprocess_only) { goto PREPROCESS_ONLY_SKIP; } stmt_start_line = 0; while (LA_CH_CLASS != Ch_Class_EOF) { comp_phase = Pass1_Parsing; num_prog_unit_errors = 0; /* Accum errs for pgm unit */ OUTPUT_PASS_HEADER(Syntax_Pass); if (save_statement_number != 0) { statement_number = save_statement_number; } parse_prog_unit(); save_statement_number = statement_number; if (LA_CH_CLASS == Ch_Class_EOF) { issue_deferred_msgs(); } /* get current field length and save largest value */ field_len = (long) sbrk(0); # if defined(_HOST_OS_MAX) field_len &= (1 << 32) - 1; # endif if (field_len > max_field_len) { /* Max set in init_compiler */ max_field_len = field_len; /* Track max usage */ } PRINT_IR_TBL; /* If -u ir and DEBUG compiler, print ir. */ OUTPUT_PASS_HEADER(Semantics_Pass); semantics_pass_driver(); /* PASS 2 */ if (SCP_IN_ERR(curr_scp_idx)) { some_scp_in_err = TRUE; } PRINT_ALL_SYM_TBLS; /* If debug print -u options */ PRINT_FORTRAN_OUT; /* Print ir in a fortran format */ line_num = SH_GLB_LINE(SCP_LAST_SH_IDX(curr_scp_idx)); column_num = SH_COL_NUM(SCP_LAST_SH_IDX(curr_scp_idx)); if (num_prog_unit_errors == 0) { if (opt_flags.inline_lvl > Inline_Lvl_0) { comp_phase = Inlining; inline_processing(SCP_FIRST_SH_IDX(curr_scp_idx)); PRINT_IR_TBL3; } } insert_global_directives = TRUE; comp_phase = Pdg_Conversion; if (dump_flags.preinline) { /* Do not do a full compile */ if (ATP_PGM_UNIT(SCP_ATTR_IDX(MAIN_SCP_IDX)) == Module || ATP_PGM_UNIT(SCP_ATTR_IDX(MAIN_SCP_IDX)) == Function || ATP_PGM_UNIT(SCP_ATTR_IDX(MAIN_SCP_IDX)) == Subroutine) { curr_scp_idx = MAIN_SCP_IDX; #ifdef KEY /* Bug 3477 */ if (create_mod_info_file()) { /* Creates a name for the file. */ create_mod_info_tbl(); /* Creates the table. */ output_mod_info_file(); /* Writes the table. */ } #else create_mod_info_file(); /* Creates a name for the file. */ create_mod_info_tbl(); /* Creates the table. */ output_mod_info_file(); /* Writes the table. */ #endif /* KEY Bug 3477 */ free_tables(); /* Frees the tables. */ } } else { #ifdef KEY /* Bug 3477 */ int do_output_file = FALSE; #endif /* KEY Bug 3477 */ if (ATP_PGM_UNIT(SCP_ATTR_IDX(MAIN_SCP_IDX)) == Module) { #ifdef KEY /* Bug 3477 */ do_output_file = create_mod_info_file(); /* Creates a name for the file. */ #else create_mod_info_file(); /* Creates a name for the file. */ #endif /* KEY Bug 3477 */ } if (num_prog_unit_errors == 0 && (binary_output || assembly_output)) { cvrt_to_pdg(compiler_gen_date); } else if (ATP_PGM_UNIT(SCP_ATTR_IDX(MAIN_SCP_IDX)) == Module) { if (!SCP_IN_ERR(MAIN_SCP_IDX)) { curr_scp_idx = MAIN_SCP_IDX; #ifdef KEY /* Bug 3477 */ if (do_output_file) { create_mod_info_tbl(); /* Creates the table. */ output_mod_info_file(); /* Writes the table. */ } #else create_mod_info_tbl(); /* Creates the table. */ output_mod_info_file(); /* Writes the table. */ #endif /* KEY Bug 3477 */ } free_tables(); /* Frees the tables. */ } else { free_tables(); /* Frees the tables. */ } } /* ALERT - At this point, the symbol tables are invalid. */ /* Spit out the End Unit for the current program unit. The End Unit */ /* is needed if the Compiler Information File (CIF) is being produced */ /* and for the buffered message file. */ stmt_start_line = line_num; stmt_start_col = column_num; if (scp_tbl == NULL_IDX) { /* Table has been freed. */ cif_end_unit_rec(program_unit_name); } else { cif_end_unit_rec(AT_OBJ_NAME_PTR(SCP_ATTR_IDX(curr_scp_idx))); } } /* while */ clean_up_module_files(); # ifdef _NAME_SUBSTITUTION_INLINING if (!dump_flags.preinline) # endif terminate_PDGCS(); PRINT_GL_TBL; /* Prints to debug_file ifdef _DEBUG and -u gl */ PRINT_GN_TBL; /* Prints to debug_file ifdef _DEBUG and -u gn */ PREPROCESS_ONLY_SKIP: # if defined(_HOST_OS_UNICOS) SECOND(&end_time); # elif defined(_HOST_OS_MAX) end_clock = clock(); end_time = 0; # elif defined(_HOST_OS_SOLARIS) end_time = (float) time(NULL); end_clock = clock(); # elif (defined(_HOST_OS_IRIX) || defined(_HOST_OS_LINUX)) getrusage(RUSAGE_SELF, &ru); end_time = (double) ru.ru_utime.tv_sec + (double) ru.ru_utime.tv_usec * 1e-6 + (double) ru.ru_stime.tv_sec + (double) ru.ru_stime.tv_usec * 1e-6; # else end_time = 0; # endif total_cpu_time = end_time - start_time; if (cif_need_unit_rec && cif_first_pgm_unit) { /* Catastrophic errors, like a free source form program was compiled */ /* in fixed source form mode, so no Unit record was output. Output */ /* enough records to keep libcif tools happy. This routine needs to be */ /* called whether or not a CIF is being written because the buffered */ /* message file also must have the correct format. */ cif_fake_a_unit(); } /* CAUTION: The following code assumes that non-Cray platforms measure */ /* memory usage in terms of bytes and that there are 4 bytes per word. */ cif_summary_rec(release_level, compiler_gen_date, compiler_gen_time, total_cpu_time, # if defined(_HOST_OS_UNICOS) (long) 0, (some_scp_in_err) ? -3 : max_field_len); # elif defined(_HOST_OS_MAX) end_clock, (some_scp_in_err) ? -3 : max_field_len); # elif (defined(_HOST_OS_IRIX) || defined(_HOST_OS_LINUX)) (long) 0, (some_scp_in_err) ? -3 : max_field_len/4); # else /* defined(_HOST_OS_SOLARIS) */ end_clock, (some_scp_in_err) ? -3 : max_field_len/4); # endif /* Output compilation summary info if the -V option was specified on the */ /* command line. Also, issue the summary information if any messages were */ /* actually issued. */ if (cmd_line_flags.verify_option || num_errors > 0 || num_warnings > 0 || num_cautions > 0 || num_notes > 0 || num_comments > 0 || num_ansi > 0 || (num_optz_msgs > 0 && opt_flags.msgs)) { print_buffered_messages(); print_id_line(); /* Output the summary lines. The compilation time is in seconds. */ /* CAUTION: The following non-Cray code assumes a 32-bit word. */ # if defined(_HOST_OS_UNICOS) PRINTMSG (0, 104, Log_Summary, 0, (double) total_cpu_time); msg_name = "cf90"; # elif defined(_HOST_OS_MAX) PRINTMSG (0, 104, Log_Summary, 0, (double) end_clock/1000000.0); msg_name = "cf90"; # elif defined(_HOST_OS_LINUX) msg_name = PSC_NAME_PREFIX "f95"; # elif (defined(_HOST_OS_IRIX) || defined(_HOST_OS_LINUX)) /* IRIX cannot handle the int to float change necessary to get the */ /* time printed correctly, so we'll convert it to a character string */ /* and use a different message. */ /* */ /* LRR 4/28/97 In an email message from Rich Shapiro to me, he stated */ /* he did not want this line in the summary lines. */ /* sprintf(time, "%-1.2f", (double) total_cpu_time); PRINTMSG (0, 1310, Log_Summary, 0, time); */ msg_name = "cf90"; # elif defined(_HOST_OS_SOLARIS) PRINTMSG (0, 104, Log_Summary, 0, (total_cpu_time <= 2147.0) ? (float) end_clock/1000000.0 : (float) total_cpu_time); msg_name = "cf90"; # endif /* Maximum field length (maximum amount of memory used) in words */ /* (decimal). */ /* CAUTION: Non-Cray platforms are assumed to measure memory usage in */ /* bytes and we assume 4 bytes per word. */ # if defined(_HOST_OS_UNICOS) PRINTMSG (0, 105, Log_Summary, 0, max_field_len); # elif ! (defined(_HOST_OS_IRIX) || defined(_HOST_OS_LINUX)) /* LRR 4/28/97 In an email message from Rich Shapiro to me, he stated */ /* he did not want this line in the summary lines. */ PRINTMSG (0, 105, Log_Summary, 0, max_field_len/4); # endif /* Number of source lines compiled. */ # if (defined(_HOST_OS_IRIX) || defined(_HOST_OS_LINUX)) && !defined(_TARGET_SV2) PRINTMSG (0, 1401, Log_Summary, 0, --curr_glb_line); # else PRINTMSG (0, 106, Log_Summary, 0, --curr_glb_line); # endif /* Number of messages issued. */ # if (defined(_HOST_OS_IRIX) || defined(_HOST_OS_LINUX)) && !defined(_TARGET_SV2) PRINTMSG (0, 1403, Log_Summary, 0, num_errors, num_warnings, (opt_flags.msgs == 0) ? (num_cautions + num_notes + num_comments) : (num_cautions + num_notes + num_comments + num_optz_msgs), num_ansi); # else PRINTMSG (0, 107, Log_Summary, 0, num_errors, num_warnings, (opt_flags.msgs == 0) ? (num_cautions + num_notes + num_comments) : (num_cautions + num_notes + num_comments + num_optz_msgs), num_ansi); /* Code: in words; data: in words. */ /* LRR 4/28/97 In an email message from Rich Shapiro to me, he stated */ /* he did not want this line in the summary lines. */ # if !defined(_TARGET_SV2) /* Prints blank for sv2 right now. */ PRINTMSG (0, 108, Log_Summary, 0, code_size, data_size); # endif # endif if (num_errors > 0 || num_warnings > 0 || num_cautions > 0 || num_notes > 0 || num_comments > 0 || num_ansi > 0 || (num_optz_msgs > 0 && opt_flags.msgs)) { PRINTMSG (0, 1636, Log_Summary, 0, msg_name, msg_name); } } /* End of summary printing. */ # ifdef _DEBUG /* Get memory usage reports for these global tables. */ final_src_input(); MEM_REPORT(file_path_tbl); MEM_REPORT(global_attr_tbl); MEM_REPORT(global_bounds_tbl); MEM_REPORT(global_line_tbl); MEM_REPORT(global_name_tbl); MEM_REPORT(global_type_tbl); MEM_REPORT(str_pool); # endif exit_compiler ((num_errors == 0) ? RC_OKAY : RC_USER_ERROR); } /* main */
/******************************************************************************\ |* *| |* Description: *| |* Do semantics for type declaration initializations. *| |* *| |* Input parameters: *| |* NONE *| |* *| |* Output parameters: *| |* NONE *| |* *| |* Returns: *| |* NOTHING *| |* *| \******************************************************************************/ void default_init_semantics(int attr_idx) { int column; expr_arg_type expr_desc; opnd_type init_opnd; int line; int next_sh_idx; boolean null_init; int old_curr_stmt_sh_idx; opnd_type opnd; int sh_idx; int type_idx; int type_init_sh_idx; TRACE (Func_Entry, "default_init_semantics", NULL); # ifdef _DEBUG if (ATD_CPNT_INIT_IDX(attr_idx) == NULL_IDX || ATD_FLD(attr_idx) != IR_Tbl_Idx || (IR_OPR(ATD_CPNT_INIT_IDX(attr_idx)) != Init_Opr && IR_OPR(ATD_CPNT_INIT_IDX(attr_idx)) != Null_Opr)) { PRINTMSG(AT_DEF_LINE(attr_idx), 626, Internal, AT_DEF_COLUMN(attr_idx), "Init_Opr or Null_Opr", "default_init_semantics"); } # endif /* Generate a type init statement so that expression semantics gets */ /* anything it generates in the correct order. This statement will */ /* be removed. */ old_curr_stmt_sh_idx = curr_stmt_sh_idx; gen_sh(After, Type_Init_Stmt, AT_DEF_LINE(attr_idx), AT_DEF_COLUMN(attr_idx), FALSE, FALSE, TRUE); type_init_sh_idx = curr_stmt_sh_idx; target_array_idx = ATD_ARRAY_IDX(attr_idx); type_idx = ATD_TYPE_IDX(attr_idx); null_init = FALSE; if (TYP_TYPE(type_idx) == Integer || TYP_TYPE(type_idx) == Real || TYP_TYPE(type_idx) == Complex) { check_type_conversion = TRUE; target_type_idx = type_idx; } else if (TYP_TYPE(type_idx) == Character) { if (TYP_CHAR_CLASS(type_idx) == Const_Len_Char) { check_type_conversion = TRUE; target_type_idx = Character_1; target_char_len_idx = TYP_IDX(type_idx); } } expr_mode = Initialization_Expr; xref_state = CIF_Symbol_Reference; expr_desc.rank = 0; COPY_OPND(init_opnd, IR_OPND_R(ATD_CPNT_INIT_IDX(attr_idx))); if (expr_semantics(&init_opnd, &expr_desc)) { if (ATD_POINTER(attr_idx) && (OPND_FLD(init_opnd) == AT_Tbl_Idx || OPND_FLD(init_opnd) == CN_Tbl_Idx || (OPND_FLD(init_opnd) == IR_Tbl_Idx && IR_OPR(OPND_IDX(init_opnd)) != Null_Intrinsic_Opr))) { find_opnd_line_and_column(&init_opnd, &line, &column); PRINTMSG(line, 1559, Error, column, AT_OBJ_NAME_PTR(attr_idx)); AT_DCL_ERR(attr_idx) = TRUE; goto EXIT; } if (!expr_desc.foldable) { /* The initialization expression must be a constant. */ if (ATD_POINTER(attr_idx) && OPND_FLD(init_opnd) == IR_Tbl_Idx && IR_OPR(OPND_IDX(init_opnd)) == Null_Intrinsic_Opr) { /* Pointer components are null'd by default, so we */ /* do not need to keep the null information around. */ null_init = TRUE; goto EXIT; } #ifdef KEY /* Bug 6845 */ else if (AT_OBJ_CLASS(TYP_IDX(ATD_TYPE_IDX(attr_idx))) == Derived_Type && ATT_ALLOCATABLE_CPNT(TYP_IDX(ATD_TYPE_IDX(attr_idx)))) { find_opnd_line_and_column(&init_opnd, &line, &column); PRINTMSG(line, 1680, Error, column, AT_OBJ_NAME_PTR(attr_idx)); AT_DCL_ERR(attr_idx) = TRUE; goto EXIT; } #endif /* KEY Bug 6845 */ find_opnd_line_and_column(&init_opnd, &line, &column); PRINTMSG(line, 842, Error, column); AT_DCL_ERR(attr_idx) = TRUE; } /* The assumption is that if this is IR, we will */ /* never end up with a CN_Tbl_Idx on the left side. */ if (OPND_FLD(init_opnd) == CN_Tbl_Idx) { if (!const_init_semantics(&init_opnd, attr_idx, ATD_CPNT_INIT_IDX(attr_idx))) { AT_DCL_ERR(attr_idx) = TRUE; } } else { COPY_OPND(opnd, init_opnd); while (OPND_FLD(opnd) == IR_Tbl_Idx && OPND_IDX(opnd) != NULL_IDX) { COPY_OPND(opnd, IR_OPND_L(OPND_IDX(opnd))); } if (OPND_FLD(opnd) == AT_Tbl_Idx) { if (!attr_init_semantics(&opnd, attr_idx, ATD_CPNT_INIT_IDX(attr_idx), &expr_desc)) { AT_DCL_ERR(attr_idx) = TRUE; } } else { PRINTMSG(AT_DEF_LINE(attr_idx), 626, Internal, AT_DEF_COLUMN(attr_idx), "AT_Tbl_Idx", "default_init_semantics"); } } } else { /* The initialization expression has an error */ AT_DCL_ERR(attr_idx) = TRUE; } EXIT: expr_mode = Regular_Expr; check_type_conversion = FALSE; target_array_idx = NULL_IDX; sh_idx = SH_NEXT_IDX(old_curr_stmt_sh_idx); if (old_curr_stmt_sh_idx != NULL_IDX) { SH_NEXT_IDX(old_curr_stmt_sh_idx) = SH_NEXT_IDX(type_init_sh_idx); } if (SH_NEXT_IDX(type_init_sh_idx) != NULL_IDX) { SH_PREV_IDX(SH_NEXT_IDX(type_init_sh_idx)) = old_curr_stmt_sh_idx; } curr_stmt_sh_idx = old_curr_stmt_sh_idx; while (sh_idx != type_init_sh_idx) { next_sh_idx = SH_NEXT_IDX(sh_idx); FREE_SH_NODE(sh_idx); sh_idx = next_sh_idx; } FREE_SH_NODE(type_init_sh_idx); if (AT_DCL_ERR(attr_idx) || null_init) { ATD_CPNT_INIT_IDX(attr_idx) = NULL_IDX; ATD_FLD(attr_idx) = NO_Tbl_Idx; } else { ATD_CPNT_INIT_IDX(attr_idx) = OPND_IDX(init_opnd); ATD_FLD(attr_idx) = OPND_FLD(init_opnd); } TRACE (Func_Exit, "default_init_semantics", NULL); return; } /* default_init_semantics */
static void ath_sample_stats(struct ath_ratestats *r, struct ath_rateioctl_rt *rt, struct sample_node *sn) { uint32_t mask; int rix, y; PRINTMSG("static_rix (%d) ratemask 0x%llx\n", sn->static_rix, (long long) sn->ratemask); for (y = 0; y < NUM_PACKET_SIZE_BINS; y++) { PRINTATTR_ON(COLOR_PAIR(y+4) | A_BOLD); PRINTMSG("[%4u] cur rate %d %s since switch: " "packets %d ticks %u\n", bin_to_size(y), dot11rate(rt, sn->current_rix[y]), dot11str(rt, sn->current_rix[y]), sn->packets_since_switch[y], sn->ticks_since_switch[y]); PRINTMSG("[%4u] last sample (%d %s) cur sample (%d %s) " "packets sent %d\n", bin_to_size(y), dot11rate(rt, sn->last_sample_rix[y]), dot11str(rt, sn->last_sample_rix[y]), dot11rate(rt, sn->current_sample_rix[y]), dot11str(rt, sn->current_sample_rix[y]), sn->packets_sent[y]); PRINTATTR_OFF(COLOR_PAIR(y+4) | A_BOLD); PRINTATTR_ON(COLOR_PAIR(3) | A_BOLD); PRINTMSG("[%4u] packets since sample %d sample tt %u\n", bin_to_size(y), sn->packets_since_sample[y], sn->sample_tt[y]); PRINTATTR_OFF(COLOR_PAIR(3) | A_BOLD); PRINTMSG("\n"); } PRINTMSG(" TX Rate TXTOTAL:TXOK EWMA T/ F" " avg last xmit\n"); for (mask = sn->ratemask, rix = 0; mask != 0; mask >>= 1, rix++) { if ((mask & 1) == 0) continue; for (y = 0; y < NUM_PACKET_SIZE_BINS; y++) { if (sn->stats[y][rix].total_packets == 0) continue; if (rix == sn->current_rix[y]) PRINTATTR_ON(COLOR_PAIR(y+4) | A_BOLD); else if (rix == sn->last_sample_rix[y]) PRINTATTR_ON(COLOR_PAIR(3) | A_BOLD); #if 0 else if (sn->stats[y][rix].ewma_pct / 10 < 50) PRINTATTR_ON(COLOR_PAIR(2) | A_BOLD); else if (sn->stats[y][rix].ewma_pct / 10 < 75) PRINTATTR_ON(COLOR_PAIR(1) | A_BOLD); #endif PRINTMSG("[%2u %s:%4u] %8ju:%-8ju " "(%3d.%1d%%) %8ju/%4d %5uuS %u\n", dot11rate(rt, rix), dot11str(rt, rix), bin_to_size(y), (uintmax_t) sn->stats[y][rix].total_packets, (uintmax_t) sn->stats[y][rix].packets_acked, sn->stats[y][rix].ewma_pct / 10, sn->stats[y][rix].ewma_pct % 10, (uintmax_t) sn->stats[y][rix].tries, sn->stats[y][rix].successive_failures, sn->stats[y][rix].average_tx_time, sn->stats[y][rix].last_tx); if (rix == sn->current_rix[y]) PRINTATTR_OFF(COLOR_PAIR(y+4) | A_BOLD); else if (rix == sn->last_sample_rix[y]) PRINTATTR_OFF(COLOR_PAIR(3) | A_BOLD); #if 0 else if (sn->stats[y][rix].ewma_pct / 10 < 50) PRINTATTR_OFF(COLOR_PAIR(2) | A_BOLD); else if (sn->stats[y][rix].ewma_pct / 10 < 75) PRINTATTR_OFF(COLOR_PAIR(1) | A_BOLD); #endif } } }
//--------------------------------------------------------------------- // InitializeNetwork // // Thanks to XBoxMediaPlayer for this code! //--------------------------------------------------------------------- BOOL InitializeNetwork( void ) { g_szTitleIPAddr[0] = 0; if (!IsEthernetConnected()) return FALSE; // if local address is specified if ((!g_NetworkConfig.m_IPAddr.IsEmpty()) && (!g_NetworkConfig.m_SubnetMask.IsEmpty()) && (!g_NetworkConfig.m_Gateway.IsEmpty())) { // Thanks and credits to Team Evox for the description of the // XNetConfigParams structure. TXNetConfigParams configParams; PRINTMSG(( T_INFO, "Loading network configuration..." )); XNetLoadConfigParams( (LPBYTE) &configParams ); PRINTMSG(( T_INFO, "Ready." )); BOOL bXboxVersion2 = (configParams.V2_Tag == 0x58425632 ); // "XBV2" BOOL bDirty = FALSE; PRINTMSG(( T_INFO, "User local address: %s", g_NetworkConfig.m_IPAddr.c_str() )); if (bXboxVersion2) { if (configParams.V2_IP != inet_addr(g_NetworkConfig.m_IPAddr.c_str())) { configParams.V2_IP = inet_addr(g_NetworkConfig.m_IPAddr.c_str()); bDirty = TRUE; } } else { if (configParams.V1_IP != inet_addr(g_NetworkConfig.m_IPAddr.c_str())) { configParams.V1_IP = inet_addr(g_NetworkConfig.m_IPAddr.c_str()); bDirty = TRUE; } } PRINTMSG(( T_INFO, "User subnet mask: %s", g_NetworkConfig.m_SubnetMask.c_str() )); if (bXboxVersion2) { if (configParams.V2_Subnetmask != inet_addr(g_NetworkConfig.m_SubnetMask.c_str())) { configParams.V2_Subnetmask = inet_addr(g_NetworkConfig.m_SubnetMask.c_str()); bDirty = TRUE; } } else { if (configParams.V1_Subnetmask != inet_addr(g_NetworkConfig.m_SubnetMask.c_str())) { configParams.V1_Subnetmask = inet_addr(g_NetworkConfig.m_SubnetMask.c_str()); bDirty = TRUE; } } PRINTMSG(( T_INFO, "User gateway address: %s", g_NetworkConfig.m_Gateway.c_str() )); if (bXboxVersion2) { if (configParams.V2_Defaultgateway != inet_addr(g_NetworkConfig.m_Gateway.c_str())) { configParams.V2_Defaultgateway = inet_addr(g_NetworkConfig.m_Gateway.c_str()); bDirty = TRUE; } } else { if (configParams.V1_Defaultgateway != inet_addr(g_NetworkConfig.m_Gateway.c_str())) { configParams.V1_Defaultgateway = inet_addr(g_NetworkConfig.m_Gateway.c_str()); bDirty = TRUE; } } if (configParams.Flag != (0x04|0x08) ) { configParams.Flag = 0x04 | 0x08; bDirty = TRUE; } if (bDirty) { PRINTMSG(( T_INFO, "Updating network configuration...")); XNetSaveConfigParams( (LPBYTE) &configParams ); PRINTMSG(( T_INFO, "Ready." )); } } XNetStartupParams xnsp; memset(&xnsp, 0, sizeof(xnsp)); xnsp.cfgSizeOfStruct = sizeof(XNetStartupParams); // Bypass security so that we may connect to 'untrusted' hosts xnsp.cfgFlags = XNET_STARTUP_BYPASS_SECURITY; // create more memory for networking xnsp.cfgPrivatePoolSizeInPages = 64; // == 256kb, default = 12 (48kb) xnsp.cfgEnetReceiveQueueLength = 16; // == 32kb, default = 8 (16kb) xnsp.cfgIpFragMaxSimultaneous = 16; // default = 4 xnsp.cfgIpFragMaxPacketDiv256 = 32; // == 8kb, default = 8 (2kb) xnsp.cfgSockMaxSockets = 64; // default = 64 xnsp.cfgSockDefaultRecvBufsizeInK = 128; // default = 16 xnsp.cfgSockDefaultSendBufsizeInK = 128; // default = 16 INT err = XNetStartup(&xnsp); XNADDR xna; DWORD dwState; do { dwState = XNetGetTitleXnAddr(&xna); Sleep(50); } while (dwState==XNET_GET_XNADDR_PENDING); // Convert the addr to a string XNetInAddrToString(xna.ina, g_szTitleIPAddr.GetBuffer(32), 32); WSADATA WsaData; err = WSAStartup( MAKEWORD(2,2), &WsaData ); return ( err == NO_ERROR ); }
static void check_license (void) { # define CRAY_LM_NQE 1 # define CRAY_LM_DPE 2 # define CRAY_LM_F90E 3 # define LM_NOWAIT 0 # define LM_WAIT 1 extern int cray_lm_checkout(int, char *, int, int, char *, double); int ignore = 0; double version = 1.0; TRACE (Func_Entry, "check_license", NULL); # if defined(_TARGET_OS_UNICOS) || defined(_TARGET_OS_MAX) if (cray_lm_checkout(CRAY_LM_DPE, "", LM_NOWAIT, ignore, "", version)) { # else if (cray_lm_checkout(CRAY_LM_F90E, "", LM_NOWAIT, ignore, "", version)) { # endif /* This compiler is not licensed on this hardware. */ PRINTMSG(0, 631, Log_Error, 0); exit_compiler(RC_USER_ERROR); } TRACE (Func_Exit, "check_license", NULL); return; } /* check_license */ # endif /******************************************************************************\ |* *| |* Description: *| |* Check defines compatibility. *| |* *| |* Input parameters: *| |* NONE *| |* *| |* Output parameters: *| |* NONE *| |* *| |* Returns: *| |* NOTHING *| |* *| \******************************************************************************/ static void check_defines_compatibility(void) { TRACE (Func_Entry, "check_defines_compatibility", NULL); /* Make sure that both pairs of a defines are not set. */ # if defined(_MODULE_TO_DOT_o) && defined(_MODULE_TO_DOT_M) PRINTMSG(1, 1114, Internal, 0, "_MODULE_TO_DOT_o", "_MODULE_TO_DOT_M"); # endif # if defined(_HEAP_REQUEST_IN_BYTES) && defined(_HEAP_REQUEST_IN_WORDS) PRINTMSG(1, 1114, Internal, 0, "_HEAP_REQUEST_IN_BYTES", "_HEAP_REQUEST_IN_WORDS"); # endif # if defined(_HOST32) && defined(_HOST64) PRINTMSG(1, 1114, Internal, 0, "_HOST32", "_HOST64"); # endif # if defined(_TARGET32) && defined(_TARGET64) PRINTMSG(1, 1114, Internal, 0, "_TARGET32", "_TARGET64"); # endif # if defined(_TARGET_WORD_ADDRESS) && defined(_TARGET_BYTE_ADDRESS) PRINTMSG(1, 1114, Internal, 0, "_TARGET_WORD_ADDRESS", "_TARGET_BYTE_ADDRESS"); # endif # if 0 /* Make sure at least one defines of a pair is set. */ # if !defined(_MODULE_TO_DOT_o) && !defined(_MODULE_TO_DOT_M) if (!on_off_flags.module_to_mod) { /* Need -em or one of these defined */ PRINTMSG(1, 1116, Internal, 0, "_MODULE_TO_DOT_o", "_MODULE_TO_DOT_M"); } # endif # endif # if !defined(_HEAP_REQUEST_IN_BYTES) && !defined(_HEAP_REQUEST_IN_WORDS) PRINTMSG(1, 1116, Internal, 0, "_HEAP_REQUEST_IN_BYTES", "_HEAP_REQUEST_IN_WORDS"); # endif # if !defined(_HOST32) && !defined(_HOST64) PRINTMSG(1, 1116, Internal, 0, "_HOST32", "_HOST64"); # endif # if !defined(_TARGET32) && !defined(_TARGET64) PRINTMSG(1, 1116, Internal, 0, "_TARGET32", "_TARGET64"); # endif # if !defined(_TARGET_WORD_ADDRESS) && !defined(_TARGET_BYTE_ADDRESS) PRINTMSG(1, 1116, Internal, 0, "_TARGET_WORD_ADDRESS", "_TARGET_BYTE_ADDRESS"); # endif TRACE (Func_Exit, "check_defines_compatibility", NULL); return; } /* check_defines_compatibility */
static void init_compiler (int argc, char *argv[]) { extern void init_lex (void); extern void init_msg_processing (char *[]); extern void init_src_input (void); extern void init_type (void); extern void process_cmd_line (int, char *[]); extern void init_cond_comp(void); extern void enter_predefined_macros(void); extern void init_parse_prog_unit(void); extern void init_PDGCS (void); extern void set_up_token_tables(void); extern void sgi_cmd_line(int *argc, char **argv[]); extern char *operator_str[]; extern void verify_semantic_tbls(void); int idx; TRACE (Func_Entry, "init_compiler", NULL); init_date_time_info (); /* set compilation data and time */ init_msg_processing (argv); /* initialize for messages. Must */ /* preceed process_cmd_line. */ # ifdef _DEBUG check_defines_compatibility(); /* Is the compiler built correctly? */ check_enums_for_change(); /* Some enums must not be changed. */ # endif # if 0 check_license(); # endif /* allocate memory for data structures required across compilation units. */ /* These must preceed process_cmd_line. */ TBL_ALLOC (global_line_tbl); TBL_ALLOC (global_name_tbl); TBL_ALLOC (global_attr_tbl); TBL_ALLOC (global_type_tbl); TBL_ALLOC (global_bounds_tbl); TBL_ALLOC (global_ir_tbl); TBL_ALLOC (global_ir_list_tbl); TBL_ALLOC (global_sh_tbl); TBL_ALLOC (file_path_tbl); TBL_ALLOC (str_pool); init_release_level (); /* Set up release_level from system */ str_pool[0].name_long = 0; str_pool[1].name_long = 0; str_pool[2].name_long = LARGE_WORD_FOR_TBL_SRCH; str_pool_idx = 2; TBL_REALLOC_CK(global_name_tbl, 2); CLEAR_TBL_NTRY(global_name_tbl, 1); CLEAR_TBL_NTRY(global_name_tbl, 2); GN_NAME_IDX(1) = 1; GN_NAME_LEN(1) = HOST_BYTES_PER_WORD; GN_NAME_IDX(2) = 2; GN_NAME_LEN(2) = HOST_BYTES_PER_WORD; /* Initialize the bounds table for deferred shape arrays */ TBL_REALLOC_CK(global_bounds_tbl, 7); for (idx = BD_DEFERRED_1_IDX; idx <= BD_DEFERRED_7_IDX; idx++) { CLEAR_TBL_NTRY(global_bounds_tbl, idx); GB_ARRAY_CLASS(idx) = Deferred_Shape; GB_RANK(idx) = idx; } /* Initialize the conditional compilation tables. It must be done before */ /* the command line processing because of the -D and -U options. */ init_cond_comp (); get_machine_chars(); set_up_token_tables(); /* The following routines sets things such as target_ieee, target_triton */ /* two_word_fcd, word_byte_size ect... */ set_compile_info_for_target(); comp_phase = Cmdline_Parsing; cif_name[0] = NULL_CHAR; assembly_listing_file[0] = NULL_CHAR; debug_file_name[0] = NULL_CHAR; # if (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX)) /* sgi_cmd_line does some option manipulation, process SGI specific */ /* command line options, and strips out things that the front-end doesn't */ /* need to see. */ sgi_cmd_line (&argc,&argv); # endif process_cmd_line (argc, argv); /* pass input args */ # if defined(_INTEGER_1_AND_2) if (on_off_flags.integer_1_and_2) { bit_size_tbl[Integer_1] = 8; bit_size_tbl[Integer_2] = 16; bit_size_tbl[Logical_1] = 8; bit_size_tbl[Logical_2] = 16; storage_bit_size_tbl[Integer_1] = 8; storage_bit_size_tbl[Integer_2] = 16; storage_bit_size_tbl[Logical_1] = 8; storage_bit_size_tbl[Logical_2] = 16; storage_bit_prec_tbl[Integer_1] = 8; storage_bit_prec_tbl[Integer_2] = 16; storage_bit_prec_tbl[Logical_1] = 8; storage_bit_prec_tbl[Logical_2] = 16; stride_mult_unit_in_bits[Integer_1] = 8; stride_mult_unit_in_bits[Integer_2] = 16; stride_mult_unit_in_bits[Logical_1] = 8; stride_mult_unit_in_bits[Logical_2] = 16; linear_to_arith[Integer_1] = AR_Int_8_S; linear_to_arith[Integer_2] = AR_Int_16_S; input_arith_type[Integer_1] = AR_Int_8_U; input_arith_type[Integer_2] = AR_Int_16_U; strcpy(arith_type_string[Integer_1], "AR_Int_8_U"); strcpy(arith_type_string[Integer_2], "AR_Int_16_U"); } # endif comp_phase = Pass1_Parsing; /* only -V info requested */ if (argc == 2 && cmd_line_flags.verify_option) { print_id_line(); exit_compiler(RC_OKAY); } if (num_errors != 0) { /* command line errors */ PRINTMSG(0, 912, Log_Summary, 0, num_errors); exit_compiler(RC_USER_ERROR); } /* Call init_cif even if the user did NOT request Compiler Information */ /* File (CIF) output because the CIF is used for messaging. */ init_cif(comp_date_time, release_level); some_scp_in_err = FALSE; clearing_blk_stk = FALSE; init_type(); make_table_changes (); init_sytb (); /* Must be before src_input for err msgs */ /* Enter conditional compilation predefined macros. This must happen */ /* after process_cmd_line because it calls GETPMC (and the information */ /* from GETPMC is needed to set the predefined macros that depend on the */ /* target machine). This call must also happen after target_triton and */ /* target_ieee have been set so that we can get _CRAYIEEE set correctly. */ /* And finally, this call must come before init_src_input because that */ /* procedure gets the first source line - which could be a conditional */ /* compilation directive. */ enter_predefined_macros(); /* Must do the first call here so that tables needed by conditional */ /* compilation are set up. */ init_parse_prog_unit(); init_src_input(); if (on_off_flags.preprocess_only) { preprocess_only_driver(); issue_deferred_msgs(); TRACE (Func_Exit, "init_compiler", NULL); return; } init_lex (); max_field_len = (long) sbrk(0); /* Keep track of memory usage */ # if defined(_HOST_OS_MAX) max_field_len &= (1 << 32) - 1; # endif /* Pathological case: The file is empty. At least an END statement must */ /* be present to constitute a valid Fortran program. */ if (LA_CH_CLASS == Ch_Class_EOF) { PRINTMSG(0, 1391, Log_Warning, 0, src_file); issue_deferred_msgs(); } # ifdef _NAME_SUBSTITUTION_INLINING if (!dump_flags.preinline) # endif init_PDGCS(); # ifdef _DEBUG verify_semantic_tbls(); /* Make sure flags and messages agree. */ if (strcmp(operator_str[The_Last_Opr], "The_Last_Opr") != 0) { PRINTMSG(1, 689, Internal, 0); } # endif TRACE (Func_Exit, "init_compiler", NULL); return; } /* init_compiler */
void type_init_semantics (void) { int attr_idx; int col; expr_arg_type expr_desc; opnd_type init_opnd; int ir_idx; int line; int list_idx; int opnd_column; int opnd_line; int sh_idx; int type_idx; TRACE (Func_Entry, "type_init_semantics", NULL); /* set comp_gen_expr to TRUE. This forces the fold of REAL */ /* constant expressions. When -Oieeeconform is specified, */ /* the folding of Real and Complex expressions is prevented. */ comp_gen_expr = TRUE; ir_idx = SH_IR_IDX(curr_stmt_sh_idx); attr_idx = IR_IDX_L(ir_idx); COPY_OPND(init_opnd, IR_OPND_R(ir_idx)); line = IR_LINE_NUM_L(ir_idx); col = IR_COL_NUM_L(ir_idx); /* Constraint checks: */ /* * A variable that is a member of blank common should not be */ /* initialized. */ /* * A variable that is a member of a named common block should only be */ /* initialized in a block data program unit. */ /* * A variable that is a member of a task common block must not be */ /* initialized. */ /* * From a CF77 SPR: If an object in a Block Data program unit is NOT */ /* in a common block (and is not equivalenced to an object in common) */ /* but IS initialized, issue a warning. */ if (ATD_IN_COMMON(attr_idx)) { if (SB_BLK_TYPE(ATD_STOR_BLK_IDX(attr_idx)) == Common) { if (SB_BLANK_COMMON(ATD_STOR_BLK_IDX(attr_idx))) { PRINTMSG(line, 1109, Ansi, col); } else if (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) != Blockdata) { # if defined(_ALLOW_DATA_INIT_OF_COMMON) PRINTMSG(line, 692, Ansi, col); # else PRINTMSG(line, 1542, Warning, col); # endif } } else if (SB_BLK_TYPE(ATD_STOR_BLK_IDX(attr_idx)) == Task_Common) { PRINTMSG(line, 851, Error, col); goto EXIT; } } else if (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) == Blockdata && ! (ATD_EQUIV(attr_idx) && SB_IS_COMMON(ATD_STOR_BLK_IDX(attr_idx)))) { PRINTMSG(line, 825, Warning, col); } /* There is no way to initialize a CRI character pointer. */ type_idx = ATD_TYPE_IDX(attr_idx); if (TYP_TYPE(type_idx) == CRI_Ch_Ptr) { PRINTMSG(line, 695, Error, col); goto EXIT; } if (AT_DCL_ERR(attr_idx)) { /* don't do anything else */ goto EXIT; } OPND_FLD(init_target_opnd) = AT_Tbl_Idx; OPND_IDX(init_target_opnd) = attr_idx; OPND_LINE_NUM(init_target_opnd) = line; OPND_COL_NUM(init_target_opnd) = col; target_array_idx = ATD_ARRAY_IDX(attr_idx); if (TYP_TYPE(type_idx) == Integer || TYP_TYPE(type_idx) == Real || TYP_TYPE(type_idx) == Complex) { check_type_conversion = TRUE; target_type_idx = type_idx; } else if (TYP_TYPE(type_idx) == Character) { if (TYP_CHAR_CLASS(type_idx) == Const_Len_Char) { check_type_conversion = TRUE; target_type_idx = Character_1; target_char_len_idx = TYP_IDX(type_idx); } } expr_mode = Initialization_Expr; xref_state = CIF_Symbol_Reference; if (expr_semantics(&init_opnd, &expr_desc)) { if (ATD_POINTER(attr_idx) && (OPND_FLD(init_opnd) == AT_Tbl_Idx || OPND_FLD(init_opnd) == CN_Tbl_Idx || (OPND_FLD(init_opnd) == IR_Tbl_Idx && IR_OPR(OPND_IDX(init_opnd)) != Null_Intrinsic_Opr))) { PRINTMSG(line, 1559, Error, col, AT_OBJ_NAME_PTR(attr_idx)); goto EXIT; } if (! expr_desc.foldable) { /* The initialization expression must be a constant. */ if (ATD_POINTER(attr_idx) && OPND_FLD(init_opnd) == IR_Tbl_Idx && IR_OPR(OPND_IDX(init_opnd)) == Null_Intrinsic_Opr) { goto EXIT; } #ifdef KEY /* Bug 6845 */ else if ((AT_OBJ_CLASS(TYP_IDX(ATD_TYPE_IDX(attr_idx))) == Derived_Type) && ATT_ALLOCATABLE_CPNT(TYP_IDX(ATD_TYPE_IDX(attr_idx)))) { find_opnd_line_and_column(&init_opnd, &opnd_line, &opnd_column); PRINTMSG(opnd_line, 1680, Error, opnd_column, AT_OBJ_NAME_PTR(attr_idx)); goto EXIT; } #endif /* KEY Bug 6845 */ else { find_opnd_line_and_column(&init_opnd, &opnd_line, &opnd_column); PRINTMSG(opnd_line, 842, Error, opnd_column); goto EXIT; } } while (OPND_FLD(init_opnd) == IR_Tbl_Idx) { COPY_OPND(init_opnd, IR_OPND_L(OPND_IDX(init_opnd))); } } else { goto EXIT; } if (OPND_FLD(init_opnd) == AT_Tbl_Idx) { if (attr_init_semantics(&init_opnd, attr_idx, ir_idx, &expr_desc)) { /* pull this init out of stmts. don't need it any more */ sh_idx = curr_stmt_sh_idx; SH_NEXT_IDX(SH_PREV_IDX(sh_idx)) = SH_NEXT_IDX(sh_idx); SH_PREV_IDX(SH_NEXT_IDX(sh_idx)) = SH_PREV_IDX(sh_idx); curr_stmt_sh_idx = SH_PREV_IDX(sh_idx); FREE_IR_NODE(ir_idx); FREE_SH_NODE(sh_idx); } } else { if (const_init_semantics(&init_opnd, attr_idx, ir_idx)) { find_opnd_line_and_column(&init_opnd, &opnd_line, &opnd_column); NTR_IR_LIST_TBL(list_idx); IR_FLD_R(ir_idx) = IL_Tbl_Idx; IR_IDX_R(ir_idx) = list_idx; IR_LIST_CNT_R(ir_idx) = 3; COPY_OPND(IL_OPND(list_idx), init_opnd); NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx)); IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx; list_idx = IL_NEXT_LIST_IDX(list_idx); IL_FLD(list_idx) = CN_Tbl_Idx; IL_IDX(list_idx) = CN_INTEGER_ONE_IDX; IL_LINE_NUM(list_idx) = opnd_line; IL_COL_NUM(list_idx) = opnd_column; NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx)); IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx; list_idx = IL_NEXT_LIST_IDX(list_idx); IL_FLD(list_idx) = CN_Tbl_Idx; IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX; IL_LINE_NUM(list_idx) = opnd_line; IL_COL_NUM(list_idx) = opnd_column; } } EXIT: expr_mode = Regular_Expr; check_type_conversion = FALSE; target_array_idx = NULL_IDX; init_target_opnd = null_opnd; /* reset comp_gen_expr to FALSE. end of compiler generated expression */ comp_gen_expr = FALSE; TRACE (Func_Exit, "type_init_semantics", NULL); return; } /* type_init_semantics */
static void get_machine_chars (void) { # if defined(_TARGET_OS_UNICOS) || defined(_TARGET_OS_MAX) # if defined(_GETPMC_AVAILABLE) extern int GETPMC(long *, char *); /* UNICOS library routine */ # else int idx; char *name; # endif TRACE (Func_Entry, "get_machine_chars", NULL); # if defined(_GETPMC_AVAILABLE) /* Use target_machine to get information about the host machine. */ /* This information is used by ntr_const_tbl to choose the algorithm */ /* it uses to convert and store floating point constants. */ if (GETPMC (target_machine.mc_tbl, "host") == 0) { PRINTMSG (0, 584, Log_Error, 0, "GETPMC"); } host_ieee = target_machine.fld.mcieee; /* Set machine characteristics table based on the target environment. */ /* The target environment is either the machine the compiler is running */ /* on or the machine specified by the TARGET environment variable. */ if (GETPMC (target_machine.mc_tbl, "target") == 0) { PRINTMSG (0, 584, Log_Error, 0, "GETPMC"); } # else name = getenv("TARGET"); if (name == NULL) { PRINTMSG(0, 1052, Log_Error, 0); TRACE (Func_Exit, "get_machine_chars", NULL); exit_compiler(RC_USER_ERROR); } else { strcpy(target_machine.fld.mcpmt, name); /* GETPMC translates the target machine name to upper case. */ for (idx = 0; idx <= strlen(target_machine.fld.mcpmt); ++idx) { target_machine.fld.mcpmt[idx] = toupper(target_machine.fld.mcpmt[idx]); } } # endif TRACE (Func_Exit, "get_machine_chars", NULL); # endif return; } /* get_machine_chars */
static boolean attr_init_semantics(opnd_type *init_opnd, int attr_idx, int ir_idx, expr_arg_type *expr_desc) { int c_type_idx; int column; int i; int line; boolean ok = TRUE; int opnd_column; int opnd_line; char type_str[40]; TRACE (Func_Entry, "attr_init_semantics", NULL); line = IR_LINE_NUM_L(ir_idx); column = IR_COL_NUM_L(ir_idx); c_type_idx = expr_desc->type_idx; find_opnd_line_and_column(init_opnd, &opnd_line, &opnd_column); if (TYP_LINEAR(c_type_idx) == Long_Typeless) { PRINTMSG(opnd_line, 1133, Error, opnd_column); ok = FALSE; } else if (!check_asg_semantics(ATD_TYPE_IDX(attr_idx), c_type_idx, opnd_line, opnd_column)) { type_str[0] = '\0'; strcat(type_str, get_basic_type_str(ATD_TYPE_IDX(attr_idx))); PRINTMSG(line, 843, Error, column, AT_OBJ_NAME_PTR(attr_idx), type_str, get_basic_type_str(c_type_idx)); ok = FALSE; } else if (expr_desc->rank > 0) { /* check array conformance */ if (ATD_ARRAY_IDX(attr_idx) == NULL_IDX) { PRINTMSG(line, 844, Error, column, AT_OBJ_NAME_PTR(attr_idx)); ok = FALSE; } else if (expr_desc->rank == BD_RANK(ATD_ARRAY_IDX(attr_idx))) { for (i = 1; i <= expr_desc->rank; i++) { if (fold_relationals(expr_desc->shape[i-1].idx, BD_XT_IDX(ATD_ARRAY_IDX(attr_idx),i), Ne_Opr)) { PRINTMSG(line, 845, Error, column, AT_OBJ_NAME_PTR(attr_idx)); ok = FALSE; break; } } } else { PRINTMSG(line, 845, Error, column, AT_OBJ_NAME_PTR(attr_idx)); ok = FALSE; } } TRACE (Func_Exit, "attr_init_semantics", NULL); return(ok); } /* attr_init_semantics */
void end_where_semantics (void) { int sh_idx; TRACE (Func_Entry, "end_where_semantics", NULL); where_ir_idx = NULL_IDX; if (where_dealloc_stmt_idx) { SH_NEXT_IDX(where_dealloc_stmt_idx) = SH_NEXT_IDX(curr_stmt_sh_idx); SH_PREV_IDX(where_dealloc_stmt_idx) = curr_stmt_sh_idx; SH_PREV_IDX(SH_NEXT_IDX(curr_stmt_sh_idx)) = where_dealloc_stmt_idx; SH_NEXT_IDX(curr_stmt_sh_idx) = where_dealloc_stmt_idx; where_dealloc_stmt_idx = NULL_IDX; } sh_idx = SH_PARENT_BLK_IDX(curr_stmt_sh_idx); while (sh_idx != NULL_IDX && SH_STMT_TYPE(sh_idx) != Where_Cstrct_Stmt) { sh_idx = SH_PARENT_BLK_IDX(sh_idx); } if (sh_idx != NULL_IDX && (SH_PARENT_BLK_IDX(sh_idx) == NULL_IDX || (SH_STMT_TYPE(SH_PARENT_BLK_IDX(sh_idx)) != Where_Cstrct_Stmt && SH_STMT_TYPE(SH_PARENT_BLK_IDX(sh_idx)) != Else_Where_Stmt && SH_STMT_TYPE(SH_PARENT_BLK_IDX(sh_idx)) != Else_Where_Mask_Stmt))) { alloc_block_start_idx = NULL_IDX; alloc_block_end_idx = NULL_IDX; } if (sh_idx != NULL_IDX && SH_PARENT_BLK_IDX(sh_idx) != NULL_IDX) { sh_idx = SH_PARENT_BLK_IDX(sh_idx); if (SH_STMT_TYPE(sh_idx) == Where_Cstrct_Stmt || SH_STMT_TYPE(sh_idx) == Else_Where_Stmt || SH_STMT_TYPE(sh_idx) == Else_Where_Mask_Stmt) { if (IR_FLD_L(SH_IR_IDX(sh_idx)) == IL_Tbl_Idx) { where_ir_idx = IL_IDX(IR_IDX_L(SH_IR_IDX(sh_idx))); } } else if (SH_STMT_TYPE(sh_idx) == Forall_Cstrct_Stmt) { active_forall_sh_idx = sh_idx; } # ifdef _DEBUG else { PRINTMSG(SH_GLB_LINE(sh_idx), 626, Internal, SH_COL_NUM(sh_idx), "Forall_Opr", "end_where_semantics"); } # endif } TRACE (Func_Exit, "end_where_semantics", NULL); return; } /* end_where_semantics */
// ----------------------------------------------------------------------------- // Debugging aid... // ----------------------------------------------------------------------------- void PrintBuffer(short* pbuf) { PRINTMSG(1, (TEXT("\r\n-------------Print Buffer @0x%08X\r\n"), pbuf)); }
int run(int argc, char **argv) { if (argc < 4) { PRINTMSG("Usage: " << argv[0] << " <outputDir> <robotFile> <objectFile>"); return 0; } std::string outputDirectory(argv[1]); std::string robotFilename(argv[2]); std::string objectFilename(argv[3]); PRINTMSG("Creating database"); std::string name = "Database1"; SHARED_PTR<GraspIt::GraspItSceneManager> graspitMgr(new GraspIt::GraspItSceneManagerHeadless()); SHARED_PTR<GraspIt::GraspItSimpleDBManager> mgr(new GraspIt::GraspItSimpleDBManager(name, graspitMgr)); std::string robotName("Robot1"); std::string objectName("Object1"); PRINTMSG("Now loading robot"); int robotID = -1; int objectID = -1; // here we'd have to put the robot joint names, we'll leave this empty for this test fle std::vector<std::string> jointNames; if ((robotID = mgr->loadRobotToDatabase(robotFilename, robotName, jointNames)) < 0) { PRINTERROR("Could not load robot"); return 0; } PRINTMSG("Now loading object"); if ((objectID = mgr->loadObjectToDatabase(objectFilename, objectName, true)) < 0) { PRINTERROR("Could not load object"); return 0; } // Now objects should be in the database only, but not in the world. // Re-add them to test if the world still workds afterwards: PRINTMSG("Now loading robot to world"); if (mgr->loadToWorld(robotID, GraspIt::EigenTransform::Identity()) != 0) { PRINTERROR("Could not add the robot to the graspit world"); return 0; } PRINTMSG("Now loading object to world"); if (mgr->loadToWorld(objectID, GraspIt::EigenTransform::Identity()) != 0) { PRINTERROR("Could not add the object to the graspit world"); return 0; } PRINTMSG("Saving world files"); // test to see if it worked: save as world bool createDir = true; // if true, the directory will be created, if it doesn't exist. graspitMgr->saveGraspItWorld(outputDirectory + "/dbtest/world.xml", createDir); graspitMgr->saveInventorWorld(outputDirectory + "/dbtest/world.iv", createDir); PRINTMSG("Quitting program."); return 0; }
static boolean const_init_semantics(opnd_type *init_opnd, int attr_idx, int ir_idx) { int a_type_idx; long_type another_constant[MAX_WORDS_FOR_NUMERIC]; int c_type_idx; char *char_ptr; char *c_char_ptr; int column; int const_idx; long64 i; int line; boolean ok = TRUE; int opnd_column; int opnd_line; opnd_type tar_opnd; char type_str[40]; TRACE (Func_Entry, "const_init_semantics", NULL); line = IR_LINE_NUM_L(ir_idx); column = IR_COL_NUM_L(ir_idx); a_type_idx = ATD_TYPE_IDX(attr_idx); c_type_idx = CN_TYPE_IDX(OPND_IDX((*init_opnd))); find_opnd_line_and_column(init_opnd, &opnd_line, &opnd_column); if (TYP_LINEAR(c_type_idx) == Long_Typeless) { PRINTMSG(opnd_line, 1133, Error, opnd_column); ok = FALSE; goto EXIT; } else if (!check_asg_semantics(a_type_idx, c_type_idx, opnd_line, opnd_column)) { type_str[0] = '\0'; strcat(type_str, get_basic_type_str(a_type_idx)); PRINTMSG(line, 843, Error, column, AT_OBJ_NAME_PTR(attr_idx), type_str, get_basic_type_str(c_type_idx)); ok = FALSE; goto EXIT; } if (TYP_TYPE(a_type_idx) == Character) { if (fold_relationals(TYP_IDX(a_type_idx), TYP_IDX(c_type_idx), Ne_Opr)) { /* assumes that these are both CN_Tbl_Idx */ /* create new constant for the right length and put the */ /* original string in it. Truncate or blank pad to fit. */ const_idx = ntr_const_tbl(a_type_idx, TRUE, NULL); char_ptr = (char *)&CN_CONST(const_idx); c_char_ptr = (char *)&CN_CONST(OPND_IDX((*init_opnd))); for (i = 0; i < CN_INT_TO_C(TYP_IDX(a_type_idx)); i++) { char_ptr[i] = (i >= CN_INT_TO_C(TYP_IDX(c_type_idx))) ? ' ' : c_char_ptr[i]; } while (i % TARGET_CHARS_PER_WORD != 0) { char_ptr[i] = ' '; i++; } OPND_IDX((*init_opnd)) = const_idx; } /* If this is default initialization, the substring reference will */ /* need to be generated when something is actually initialized. */ if (ATD_CLASS(attr_idx) != Struct_Component) { COPY_OPND(tar_opnd, IR_OPND_L(ir_idx)); if (gen_whole_substring(&tar_opnd, 0)) { COPY_OPND(IR_OPND_L(ir_idx), tar_opnd); } } } else if (TYP_TYPE(c_type_idx) == Character || TYP_TYPE(c_type_idx) == Typeless) { /* cast the character or typeless constant to the target type */ OPND_IDX((*init_opnd)) = cast_typeless_constant(OPND_IDX((*init_opnd)), a_type_idx, opnd_line, opnd_column); } else if (TYP_TYPE(c_type_idx) != Character && TYP_TYPE(c_type_idx) != Typeless && TYP_LINEAR(c_type_idx) != TYP_LINEAR(a_type_idx)) { /* PDGCS does not like it if the value is not the same size as the */ /* target; for example, the value is a double precision constant and */ /* the target is a single precision variable. So explicitly convert */ /* the value to the type and kind type parameter of the target for */ /* all combinations to be consistent. */ if (folder_driver( (char *) &CN_CONST(OPND_IDX((*init_opnd))), c_type_idx, NULL, NULL_IDX, another_constant, &a_type_idx, opnd_line, opnd_column, 1, Cvrt_Opr)) { OPND_IDX((*init_opnd)) = ntr_const_tbl(ATD_TYPE_IDX(attr_idx), FALSE, another_constant); } } EXIT: TRACE (Func_Exit, "const_init_semantics", NULL); return(ok); } /* const_init_semantics */
int main(int argc, char *argv[]) { Teuchos::GlobalMPISession session(&argc, &argv); int ierr = 0; /////////////////////////////////////////////////////////// // Test conversions into integers // Assignments that should always work // (since the zgno value fits in an integer) int intIdx; try { int zgno = 123; Zoltan2::TPL_Traits<int,int>::ASSIGN_TPL_T(intIdx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: int to int"); ierr++; } try { unsigned int zgno = 123; Zoltan2::TPL_Traits<int,unsigned int>::ASSIGN_TPL_T(intIdx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: unsigned int to int"); ierr++; } try { long zgno = 123; Zoltan2::TPL_Traits<int,long>::ASSIGN_TPL_T(intIdx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: long to int"); ierr++; } try { size_t zgno = 123; Zoltan2::TPL_Traits<int,size_t>::ASSIGN_TPL_T(intIdx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: size_t to int"); ierr++; } // Assignments that should not work try { long long zgno = (long long)1 << 40; Zoltan2::TPL_Traits<int,long long>::ASSIGN_TPL_T(intIdx, zgno); } catch (std::exception &e) { PRINTMSG("GOOD: big long long to int throws exception"); } try { size_t zgno = (size_t)1 << 40; Zoltan2::TPL_Traits<int,size_t>::ASSIGN_TPL_T(intIdx, zgno); } catch (std::exception &e) { PRINTMSG("GOOD: big size_t to int throws exception"); } try { unsigned zgno = (1 << 31) + 1; Zoltan2::TPL_Traits<int,unsigned>::ASSIGN_TPL_T(intIdx, zgno); } catch (std::exception &e) { PRINTMSG("GOOD: huge unsigned to int throws exception"); } /////////////////////////////////////////////////////////// // Test conversions into size_t // Assignments that should always work size_t sizetIdx; try { long long zgno = (long long)1 << 40; Zoltan2::TPL_Traits<size_t,long long>::ASSIGN_TPL_T(sizetIdx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: big long long to size_t"); ierr++; } try { size_t zgno = (size_t)1 << 40; Zoltan2::TPL_Traits<size_t,size_t>::ASSIGN_TPL_T(sizetIdx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: big size_t to size_t"); ierr++; } /////////////////////////////////////////////////////////// // Test conversions into int64_t // Assignments that should always work int64_t int64Idx; try { long long zgno = (long long)1 << 40; Zoltan2::TPL_Traits<int64_t,long long>::ASSIGN_TPL_T(int64Idx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: big long long to int64_t"); ierr++; } try { size_t zgno = (size_t)1 << 40; Zoltan2::TPL_Traits<int64_t,size_t>::ASSIGN_TPL_T(int64Idx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: big size_t to int64_t"); ierr++; } // Assignments that should not work try { size_t zgno = ((size_t)1 << 63) + 1 ; Zoltan2::TPL_Traits<int64_t,size_t>::ASSIGN_TPL_T(int64Idx, zgno); } catch (std::exception &e) { PRINTMSG("GOOD: huge size_t to int64_t threw exception"); } #ifdef HAVE_ZOLTAN2_SCOTCH /////////////////////////////////////////////////////////// // Test conversions into SCOTCH_Num SCOTCH_Num scotchIdx; // Assignments that should always work // (since the zgno value fits in an integer) try { int zgno = 123; Zoltan2::TPL_Traits<SCOTCH_Num,int>::ASSIGN_TPL_T(scotchIdx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: int to SCOTCH_Num"); ierr++; } try { unsigned int zgno = 123; Zoltan2::TPL_Traits<SCOTCH_Num,unsigned int>::ASSIGN_TPL_T(scotchIdx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: unsigned int to SCOTCH_Num"); ierr++; } try { long zgno = 123; Zoltan2::TPL_Traits<SCOTCH_Num,long>::ASSIGN_TPL_T(scotchIdx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: long to SCOTCH_Num"); ierr++; } try { size_t zgno = 123; Zoltan2::TPL_Traits<SCOTCH_Num,size_t>::ASSIGN_TPL_T(scotchIdx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: size_t to SCOTCH_Num"); ierr++; } if (sizeof(SCOTCH_Num) == 8) { try { long long zgno = (long long)1 << 40; Zoltan2::TPL_Traits<SCOTCH_Num,long long>::ASSIGN_TPL_T(scotchIdx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: big unsigned int to SCOTCH_Num"); ierr++; } try { size_t zgno = (size_t)1 << 40; Zoltan2::TPL_Traits<SCOTCH_Num,size_t>::ASSIGN_TPL_T(scotchIdx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: big size_t to SCOTCH_Num"); ierr++; } } // Assignments that should not work if (sizeof(SCOTCH_Num) == 4) { try { long long zgno = (long long)1 << 40; Zoltan2::TPL_Traits<SCOTCH_Num,long long>::ASSIGN_TPL_T(scotchIdx, zgno); } catch (std::exception &e) { PRINTMSG("GOOD: big long long to 4-byte SCOTCH_Num throws exception"); } try { size_t zgno = (size_t)1 << 40; Zoltan2::TPL_Traits<SCOTCH_Num,size_t>::ASSIGN_TPL_T(scotchIdx, zgno); } catch (std::exception &e) { PRINTMSG("GOOD: big size_t to 4-byte SCOTCH_Num throws exception"); } } #endif // HAVE_ZOLTAN2_SCOTCH #ifdef PARMETIS_IS_OK /////////////////////////////////////////////////////////// // Test conversions into ParMETIS' idx_t idx_t parmetisIdx; // Assignments that should always work // (since the zgno value fits in an integer) try { int zgno = 123; Zoltan2::TPL_Traits<idx_t,int>::ASSIGN_TPL_T(parmetisIdx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: int to ParMETIS' idx_t"); ierr++; } try { unsigned int zgno = 123; Zoltan2::TPL_Traits<idx_t,unsigned int>::ASSIGN_TPL_T(parmetisIdx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: unsigned int to ParMETIS' idx_t"); ierr++; } try { long zgno = 123; Zoltan2::TPL_Traits<idx_t,long>::ASSIGN_TPL_T(parmetisIdx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: long to ParMETIS' idx_t"); ierr++; } try { size_t zgno = 123; Zoltan2::TPL_Traits<idx_t,size_t>::ASSIGN_TPL_T(parmetisIdx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: size_t to ParMETIS' idx_t"); ierr++; } if (sizeof(idx_t) == 8) { try { long long zgno = (long long)1 << 40; Zoltan2::TPL_Traits<idx_t,long long>::ASSIGN_TPL_T(parmetisIdx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: big unsigned int to ParMETIS' idx_t"); ierr++; } try { size_t zgno = (size_t)1 << 40; Zoltan2::TPL_Traits<idx_t,size_t>::ASSIGN_TPL_T(parmetisIdx, zgno); } catch (std::exception &e) { PRINTMSG("FAIL: big size_t to ParMETIS' idx_t"); ierr++; } } // Assignments that should not work if (sizeof(idx_t) == 4) { try { long long zgno = (long long)1 << 40; Zoltan2::TPL_Traits<idx_t,long long>::ASSIGN_TPL_T(parmetisIdx, zgno); } catch (std::exception &e) { PRINTMSG("GOOD: big long long to 4-byte ParMETIS' idx_t throws exception"); } try { size_t zgno = (size_t)1 << 40; Zoltan2::TPL_Traits<idx_t,size_t>::ASSIGN_TPL_T(parmetisIdx, zgno); } catch (std::exception &e) { PRINTMSG("GOOD: big size_t to 4-byte ParMETIS' idx_t throws exception"); } } #endif /////////////////////////////////////////////////////////// // Test conversions into ZOLTAN_ID_PTR ZOLTAN_ID_PTR zoltanGID = new ZOLTAN_ID_TYPE[4]; { typedef char test_t; test_t zgno = 'a'; zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0; Zoltan2::TPL_Traits<ZOLTAN_ID_PTR,test_t>::ASSIGN_TPL_T(zoltanGID, zgno); if (zoltanGID[0] != ZOLTAN_ID_TYPE(zgno) || zoltanGID[1] != 0 || zoltanGID[2] != 0 || zoltanGID[3] != 0) { PRINTMSG("FAIL: int to ZOLTAN_ID_PTR"); ierr++; } } { typedef short test_t; test_t zgno = 63; zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0; Zoltan2::TPL_Traits<ZOLTAN_ID_PTR,test_t>::ASSIGN_TPL_T(zoltanGID, zgno); if (zoltanGID[0] != ZOLTAN_ID_TYPE(zgno) || zoltanGID[1] != 0 || zoltanGID[2] != 0 || zoltanGID[3] != 0) { PRINTMSG("FAIL: int to ZOLTAN_ID_PTR"); ierr++; } } { typedef int test_t; test_t zgno = 123; zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0; Zoltan2::TPL_Traits<ZOLTAN_ID_PTR,test_t>::ASSIGN_TPL_T(zoltanGID, zgno); if (zoltanGID[0] != ZOLTAN_ID_TYPE(zgno) || zoltanGID[1] != 0 || zoltanGID[2] != 0 || zoltanGID[3] != 0) { PRINTMSG("FAIL: int to ZOLTAN_ID_PTR"); ierr++; } } { typedef unsigned int test_t; test_t zgno = 456; zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0; Zoltan2::TPL_Traits<ZOLTAN_ID_PTR,test_t>::ASSIGN_TPL_T(zoltanGID, zgno); if (zoltanGID[0] != zgno || zoltanGID[1] != 0 || zoltanGID[2] != 0 || zoltanGID[3] != 0) { PRINTMSG("FAIL: unsigned int to ZOLTAN_ID_PTR"); ierr++; } } { typedef long long test_t; test_t zgno = ((test_t)1 << 34) + (test_t)17; zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0; Zoltan2::TPL_Traits<ZOLTAN_ID_PTR,test_t>::ASSIGN_TPL_T(zoltanGID, zgno); if (zoltanGID[0] != 17 || zoltanGID[1] != 4 || zoltanGID[2] != 0 || zoltanGID[3] != 0) { PRINTMSG("FAIL: long long to ZOLTAN_ID_PTR"); ierr++; } } { typedef unsigned long long test_t; test_t zgno = ((test_t)1 << 36) + (test_t)25; zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0; Zoltan2::TPL_Traits<ZOLTAN_ID_PTR,test_t>::ASSIGN_TPL_T(zoltanGID, zgno); if (zoltanGID[0] != 25 || zoltanGID[1] != 16 || zoltanGID[2] != 0 || zoltanGID[3] != 0) { PRINTMSG("FAIL: unsigned long long to ZOLTAN_ID_PTR"); ierr++; } } { typedef size_t test_t; test_t zgno = 0; for (size_t i = 0; i < 8*sizeof(test_t); i++) zgno += (test_t)1<<i; zoltanGID[0] = 0; zoltanGID[1] = 0; zoltanGID[2] = 0; zoltanGID[3] = 0; Zoltan2::TPL_Traits<ZOLTAN_ID_PTR,test_t>::ASSIGN_TPL_T(zoltanGID, zgno); int num_gid = sizeof(test_t) / sizeof(ZOLTAN_ID_TYPE); for (int i = 0; i < num_gid; i++) if (zoltanGID[i] != std::numeric_limits<ZOLTAN_ID_TYPE>::max()) { PRINTMSG("FAIL: size_t to ZOLTAN_ID_PTR"); ierr++; } for (int i = num_gid; i < 4; i++) if (zoltanGID[i] != 0) { PRINTMSG("FAIL: size_t to ZOLTAN_ID_PTR"); ierr++; } } delete [] zoltanGID; /////////////////////////////////////////////////////////// if (ierr == 0) std::cout << "PASS" << std::endl; else std::cout << "FAIL" << std::endl; return 0; }
void gen_default_init_code(int attr_idx) { expr_arg_type expr_desc; operator_type operator; opnd_type opnd; TRACE (Func_Entry, "gen_default_init_code", NULL); if (AT_DCL_ERR(attr_idx)) { goto EXIT; } if (SB_RUNTIME_INIT(ATD_STOR_BLK_IDX(attr_idx))) { /* The var is on the stack, or is automatic, a darg or a func */ /* result. Generate runtime code for the initialization. */ operator = Asg_Opr; } else if (ATD_IN_COMMON(attr_idx)) { operator = Init_Opr; # if 0 # if defined(_TARGET_OS_SOLARIS) || (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN)) func = gen_common_dv_init; # else func = gen_static_dv_whole_def; # endif # endif } else { operator = Init_Opr; } if (!ATD_IM_A_DOPE(attr_idx) && TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Structure && ATT_DEFAULT_INITIALIZED(TYP_IDX(ATD_TYPE_IDX(attr_idx))) && !AT_DCL_ERR(TYP_IDX(ATD_TYPE_IDX(attr_idx)))) { OPND_FLD(opnd) = AT_Tbl_Idx; OPND_IDX(opnd) = attr_idx; OPND_LINE_NUM(opnd) = AT_DEF_LINE(attr_idx); OPND_COL_NUM(opnd) = AT_DEF_COLUMN(attr_idx); # if defined(_F_MINUS_MINUS) if (ATD_ARRAY_IDX(attr_idx) || ATD_PE_ARRAY_IDX(attr_idx)) { # else if (ATD_ARRAY_IDX(attr_idx)) { # endif gen_whole_subscript(&opnd, &expr_desc); } process_all_initialized_cpnts(&opnd, TYP_IDX(ATD_TYPE_IDX(attr_idx)), operator); } EXIT: TRACE (Func_Exit, "gen_default_init_code", NULL); return; } /* gen_default_init_code */ /******************************************************************************\ |* *| |* Description: *| |* recursively go through all components of a structure to look for *| |* default initialization. Then call the supplied routine func for *| |* processing. *| |* *| |* Input parameters: *| |* left_opnd - current base of sub-object reference. *| |* type_idx - defined type attr. *| |* operator - Whether to use Init_Opr or Asg_Opr. *| |* *| |* Output parameters: *| |* NONE *| |* *| |* Returns: *| |* NOTHING *| |* *| \******************************************************************************/ static void process_all_initialized_cpnts(opnd_type *left_opnd, int type_idx, operator_type operator) { int attr_idx; expr_arg_type expr_desc; opnd_type expr_opnd; int init_idx; int ir_idx; int list_idx; opnd_type opnd; int sn_idx; TRACE (Func_Entry, "process_all_initialized_cpnts", NULL); sn_idx = ATT_FIRST_CPNT_IDX(type_idx); while (sn_idx != NULL_IDX) { attr_idx = SN_ATTR_IDX(sn_idx); /* A component */ if (ATD_CPNT_INIT_IDX(attr_idx) != NULL_IDX) { NTR_IR_TBL(ir_idx); IR_OPR(ir_idx) = Struct_Opr; IR_TYPE_IDX(ir_idx) = ATD_TYPE_IDX(attr_idx); IR_LINE_NUM(ir_idx) = AT_DEF_LINE(attr_idx); IR_COL_NUM(ir_idx) = AT_DEF_COLUMN(attr_idx); COPY_OPND(IR_OPND_L(ir_idx), (*left_opnd)); IR_FLD_R(ir_idx) = AT_Tbl_Idx; IR_IDX_R(ir_idx) = attr_idx; IR_LINE_NUM_R(ir_idx) = AT_DEF_LINE(attr_idx); IR_COL_NUM_R(ir_idx) = AT_DEF_COLUMN(attr_idx); if (IR_FLD_L(ir_idx) == IR_Tbl_Idx) { IR_RANK(ir_idx) = IR_RANK(IR_IDX_L(ir_idx)); } NTR_IR_TBL(init_idx); IR_OPR(init_idx) = operator; IR_LINE_NUM(init_idx) = AT_DEF_LINE(attr_idx); IR_COL_NUM(init_idx) = AT_DEF_COLUMN(attr_idx); IR_TYPE_IDX(init_idx) = TYPELESS_DEFAULT_TYPE; IR_FLD_L(init_idx) = IR_Tbl_Idx; IR_IDX_L(init_idx) = ir_idx; IR_LINE_NUM_L(init_idx)= AT_DEF_LINE(attr_idx); IR_COL_NUM_L(init_idx) = AT_DEF_COLUMN(attr_idx); if (operator == Asg_Opr) { if (ATD_FLD(attr_idx) == IR_Tbl_Idx) { /* This should be an Init_Opr */ if (IR_OPR(ATD_CPNT_INIT_IDX(attr_idx)) != Init_Opr) { PRINTMSG(AT_DEF_LINE(attr_idx), 626, Internal, AT_DEF_COLUMN(attr_idx), "An Init Opr", "process_all_initialized_cpnts"); } COPY_OPND(IR_OPND_R(init_idx), IL_OPND(IR_IDX_R(ATD_CPNT_INIT_IDX(attr_idx)))); } else { IR_IDX_R(init_idx) = ATD_CPNT_INIT_IDX(attr_idx); IR_FLD_R(init_idx) = (fld_type) ATD_FLD(attr_idx); IR_LINE_NUM_R(init_idx) = AT_DEF_LINE(attr_idx); IR_COL_NUM_R(init_idx) = AT_DEF_COLUMN(attr_idx); } if (ATD_ARRAY_IDX(attr_idx) != NULL_IDX || TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Character) { xref_state = CIF_No_Usage_Rec; expr_desc.rank = 0; OPND_FLD(expr_opnd) = IR_Tbl_Idx; OPND_IDX(expr_opnd) = ir_idx;; if (expr_semantics(&expr_opnd, &expr_desc)) { COPY_OPND(IR_OPND_L(init_idx), expr_opnd); } } gen_sh(After, Assignment_Stmt, AT_DEF_LINE(attr_idx), AT_DEF_COLUMN(attr_idx), FALSE, FALSE, TRUE); } else { /* Init_Opr */ if (ATD_FLD(attr_idx) == IR_Tbl_Idx) { /* This should be an Init_Opr */ if (IR_OPR(ATD_CPNT_INIT_IDX(attr_idx)) != Init_Opr) { PRINTMSG(AT_DEF_LINE(attr_idx), 626, Internal, AT_DEF_COLUMN(attr_idx), "An Init Opr", "process_all_initialized_cpnts"); } IR_FLD_R(init_idx) = IL_Tbl_Idx; IR_IDX_R(init_idx) = IR_IDX_R(ATD_CPNT_INIT_IDX(attr_idx)); IR_LIST_CNT_R(init_idx) = 3; } else { NTR_IR_LIST_TBL(list_idx); IR_FLD_R(init_idx) = IL_Tbl_Idx; IR_IDX_R(init_idx) = list_idx; IR_LIST_CNT_R(init_idx) = 3; IL_IDX(list_idx) = ATD_CPNT_INIT_IDX(attr_idx); IL_FLD(list_idx) = (fld_type) ATD_FLD(attr_idx); IL_LINE_NUM(list_idx) = AT_DEF_LINE(attr_idx); IL_COL_NUM(list_idx) = AT_DEF_COLUMN(attr_idx); NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx)); IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx; list_idx = IL_NEXT_LIST_IDX(list_idx); IL_FLD(list_idx) = CN_Tbl_Idx; IL_IDX(list_idx) = CN_INTEGER_ONE_IDX; IL_LINE_NUM(list_idx) = AT_DEF_LINE(attr_idx); IL_COL_NUM(list_idx) = AT_DEF_COLUMN(attr_idx); NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx)); IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx; list_idx = IL_NEXT_LIST_IDX(list_idx); IL_FLD(list_idx) = CN_Tbl_Idx; IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX; IL_LINE_NUM(list_idx) = AT_DEF_LINE(attr_idx); IL_COL_NUM(list_idx) = AT_DEF_COLUMN(attr_idx); } gen_sh(After, Type_Init_Stmt, AT_DEF_LINE(attr_idx), AT_DEF_COLUMN(attr_idx), FALSE, FALSE, TRUE); } SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE; SH_IR_IDX(curr_stmt_sh_idx) = init_idx; } else if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Structure && ATT_DEFAULT_INITIALIZED(TYP_IDX(ATD_TYPE_IDX(attr_idx)))) { NTR_IR_TBL(ir_idx); IR_OPR(ir_idx) = Struct_Opr; IR_TYPE_IDX(ir_idx) = ATD_TYPE_IDX(attr_idx); IR_LINE_NUM(ir_idx) = AT_DEF_LINE(attr_idx); IR_COL_NUM(ir_idx) = AT_DEF_COLUMN(attr_idx); COPY_OPND(IR_OPND_L(ir_idx), (*left_opnd)); IR_FLD_R(ir_idx) = AT_Tbl_Idx; IR_IDX_R(ir_idx) = attr_idx; IR_LINE_NUM_R(ir_idx) = AT_DEF_LINE(attr_idx); IR_COL_NUM_R(ir_idx) = AT_DEF_COLUMN(attr_idx); OPND_FLD(opnd) = IR_Tbl_Idx; OPND_IDX(opnd) = ir_idx; if (IR_FLD_L(ir_idx) == IR_Tbl_Idx) { IR_RANK(ir_idx) = IR_RANK(IR_IDX_L(ir_idx)); } if (ATD_ARRAY_IDX(attr_idx) != NULL_IDX) { gen_whole_subscript(&opnd, &expr_desc); } process_all_initialized_cpnts(&opnd, TYP_IDX(ATD_TYPE_IDX(attr_idx)), operator); } sn_idx = SN_SIBLING_LINK(sn_idx); } TRACE (Func_Exit, "process_all_initialized_cpnts", NULL); return; } /* process_all_initialized_cpnts */