这篇教程C++ sp函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中sp函数的典型用法代码示例。如果您正苦于以下问题:C++ sp函数的具体用法?C++ sp怎么用?C++ sp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了sp函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: spbool frame::safe_for_sender(JavaThread *thread) { address _SP = (address) sp(); address _FP = (address) fp(); address _UNEXTENDED_SP = (address) unextended_sp(); // sp must be within the stack bool sp_safe = (_SP <= thread->stack_base()) && (_SP >= thread->stack_base() - thread->stack_size()); if (!sp_safe) { return false; } // unextended sp must be within the stack and above or equal sp bool unextended_sp_safe = (_UNEXTENDED_SP <= thread->stack_base()) && (_UNEXTENDED_SP >= _SP); if (!unextended_sp_safe) return false; // an fp must be within the stack and above (but not equal) sp bool fp_safe = (_FP <= thread->stack_base()) && (_FP > _SP); // We know sp/unextended_sp are safe only fp is questionable here // If the current frame is known to the code cache then we can attempt to // to construct the sender and do some validation of it. This goes a long way // toward eliminating issues when we get in frame construction code if (_cb != NULL ) { // First check if frame is complete and tester is reliable // Unfortunately we can only check frame complete for runtime stubs and nmethod // other generic buffer blobs are more problematic so we just assume they are // ok. adapter blobs never have a frame complete and are never ok. if (!_cb->is_frame_complete_at(_pc)) { if (_cb->is_compiled() || _cb->is_adapter_blob() || _cb->is_runtime_stub()) { return false; } } // Could just be some random pointer within the codeBlob if (!_cb->code_contains(_pc)) { return false; } // Entry frame checks if (is_entry_frame()) { // an entry frame must have a valid fp. if (!fp_safe) { return false; } // Validate the JavaCallWrapper an entry frame must have address jcw = (address)entry_frame_call_wrapper(); bool jcw_safe = (jcw <= thread->stack_base()) && ( jcw > _FP); return jcw_safe; } intptr_t* younger_sp = sp(); intptr_t* _SENDER_SP = sender_sp(); // sender is actually just _FP bool adjusted_stack = is_interpreted_frame(); address sender_pc = (address)younger_sp[I7->sp_offset_in_saved_window()] + pc_return_offset; // We must always be able to find a recognizable pc CodeBlob* sender_blob = CodeCache::find_blob_unsafe(sender_pc); if (sender_pc == NULL || sender_blob == NULL) { return false; } // Could be a zombie method if (sender_blob->is_zombie() || sender_blob->is_unloaded()) { return false; } // It should be safe to construct the sender though it might not be valid frame sender(_SENDER_SP, younger_sp, adjusted_stack); // Do we have a valid fp? address sender_fp = (address) sender.fp(); // an fp must be within the stack and above (but not equal) current frame's _FP bool sender_fp_safe = (sender_fp <= thread->stack_base()) && (sender_fp > _FP); if (!sender_fp_safe) { return false; }//.........这里部分代码省略.........
开发者ID:campolake,项目名称:openjdk9,代码行数:101,
示例2: DSTACKvoid ClientMap::renderMap(video::IVideoDriver* driver, s32 pass){ INodeDefManager *nodemgr = m_gamedef->ndef(); //m_dout<<DTIME<<"Rendering map..."<<std::endl; DSTACK(__FUNCTION_NAME); bool is_transparent_pass = pass == scene::ESNRP_TRANSPARENT; std::string prefix; if(pass == scene::ESNRP_SOLID) prefix = "CM: solid: "; else prefix = "CM: transparent: "; /* This is called two times per frame, reset on the non-transparent one */ if(pass == scene::ESNRP_SOLID) { m_last_drawn_sectors.clear(); } /* Get time for measuring timeout. Measuring time is very useful for long delays when the machine is swapping a lot. */ int time1 = time(0); /* Get animation parameters */ float animation_time = m_client->getAnimationTime(); int crack = m_client->getCrackLevel(); u32 daynight_ratio = m_client->getEnv().getDayNightRatio(); m_camera_mutex.Lock(); v3f camera_position = m_camera_position; v3f camera_direction = m_camera_direction; f32 camera_fov = m_camera_fov; m_camera_mutex.Unlock(); /* Get all blocks and draw all visible ones */ v3s16 cam_pos_nodes = floatToInt(camera_position, BS); v3s16 box_nodes_d = m_control.wanted_range * v3s16(1,1,1); v3s16 p_nodes_min = cam_pos_nodes - box_nodes_d; v3s16 p_nodes_max = cam_pos_nodes + box_nodes_d; // Take a fair amount as we will be dropping more out later // Umm... these additions are a bit strange but they are needed. v3s16 p_blocks_min( p_nodes_min.X / MAP_BLOCKSIZE - 3, p_nodes_min.Y / MAP_BLOCKSIZE - 3, p_nodes_min.Z / MAP_BLOCKSIZE - 3); v3s16 p_blocks_max( p_nodes_max.X / MAP_BLOCKSIZE + 1, p_nodes_max.Y / MAP_BLOCKSIZE + 1, p_nodes_max.Z / MAP_BLOCKSIZE + 1); u32 vertex_count = 0; u32 meshbuffer_count = 0; // For limiting number of mesh animations per frame u32 mesh_animate_count = 0; u32 mesh_animate_count_far = 0; // Number of blocks in rendering range u32 blocks_in_range = 0; // Number of blocks occlusion culled u32 blocks_occlusion_culled = 0; // Number of blocks in rendering range but don't have a mesh u32 blocks_in_range_without_mesh = 0; // Blocks that had mesh that would have been drawn according to // rendering range (if max blocks limit didn't kick in) u32 blocks_would_have_drawn = 0; // Blocks that were drawn and had a mesh u32 blocks_drawn = 0; // Blocks which had a corresponding meshbuffer for this pass u32 blocks_had_pass_meshbuf = 0; // Blocks from which stuff was actually drawn u32 blocks_without_stuff = 0; /* Collect a set of blocks for drawing */ core::map<v3s16, MapBlock*> drawset; { ScopeProfiler sp(g_profiler, prefix+"collecting blocks for drawing", SPT_AVG); for(core::map<v2s16, MapSector*>::Iterator si = m_sectors.getIterator();//.........这里部分代码省略.........
开发者ID:AMDmi3,项目名称:minetest,代码行数:101,
示例3: mainint main(int argc, char **argv) { SmartPointer<Foo> sp(nullptr); std::cout << sp->Sum() << std::endl; return 0;}
开发者ID:movb,项目名称:stepic,代码行数:5,
示例4: collisionMoveSimplecollisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef, f32 pos_max_d, const aabb3f &box_0, f32 stepheight, f32 dtime, v3f &pos_f, v3f &speed_f, v3f &accel_f,ActiveObject* self, bool collideWithObjects){ static bool time_notification_done = false; Map *map = &env->getMap(); //TimeTaker tt("collisionMoveSimple"); ScopeProfiler sp(g_profiler, "collisionMoveSimple avg", SPT_AVG); collisionMoveResult result; /* Calculate new velocity */ if (dtime > 0.5) { if (!time_notification_done) { time_notification_done = true; infostream << "collisionMoveSimple: maximum step interval exceeded," " lost movement details!"<<std::endl; } dtime = 0.5; } else { time_notification_done = false; } speed_f += accel_f * dtime; // If there is no speed, there are no collisions if(speed_f.getLength() == 0) return result; // Limit speed for avoiding hangs speed_f.Y=rangelim(speed_f.Y,-5000,5000); speed_f.X=rangelim(speed_f.X,-5000,5000); speed_f.Z=rangelim(speed_f.Z,-5000,5000); /* Collect node boxes in movement range */ std::vector<aabb3f> cboxes; std::vector<bool> is_unloaded; std::vector<bool> is_step_up; std::vector<bool> is_object; std::vector<int> bouncy_values; std::vector<v3s16> node_positions; { //TimeTaker tt2("collisionMoveSimple collect boxes"); ScopeProfiler sp(g_profiler, "collisionMoveSimple collect boxes avg", SPT_AVG); v3s16 oldpos_i = floatToInt(pos_f, BS); v3s16 newpos_i = floatToInt(pos_f + speed_f * dtime, BS); s16 min_x = MYMIN(oldpos_i.X, newpos_i.X) + (box_0.MinEdge.X / BS) - 1; s16 min_y = MYMIN(oldpos_i.Y, newpos_i.Y) + (box_0.MinEdge.Y / BS) - 1; s16 min_z = MYMIN(oldpos_i.Z, newpos_i.Z) + (box_0.MinEdge.Z / BS) - 1; s16 max_x = MYMAX(oldpos_i.X, newpos_i.X) + (box_0.MaxEdge.X / BS) + 1; s16 max_y = MYMAX(oldpos_i.Y, newpos_i.Y) + (box_0.MaxEdge.Y / BS) + 1; s16 max_z = MYMAX(oldpos_i.Z, newpos_i.Z) + (box_0.MaxEdge.Z / BS) + 1; bool any_position_valid = false; for(s16 x = min_x; x <= max_x; x++) for(s16 y = min_y; y <= max_y; y++) for(s16 z = min_z; z <= max_z; z++) { v3s16 p(x,y,z); bool is_position_valid; MapNode n = map->getNodeNoEx(p, &is_position_valid); if (is_position_valid) { // Object collides into walkable nodes any_position_valid = true; const ContentFeatures &f = gamedef->getNodeDefManager()->get(n); if(f.walkable == false) continue; int n_bouncy_value = itemgroup_get(f.groups, "bouncy"); std::vector<aabb3f> nodeboxes = n.getCollisionBoxes(gamedef->ndef()); for(std::vector<aabb3f>::iterator i = nodeboxes.begin(); i != nodeboxes.end(); ++i) { aabb3f box = *i; box.MinEdge += v3f(x, y, z)*BS; box.MaxEdge += v3f(x, y, z)*BS; cboxes.push_back(box); is_unloaded.push_back(false); is_step_up.push_back(false); bouncy_values.push_back(n_bouncy_value); node_positions.push_back(p); is_object.push_back(false); } } else { // Collide with unloaded nodes aabb3f box = getNodeBox(p, BS); cboxes.push_back(box);//.........这里部分代码省略.........
开发者ID:taserman21,项目名称:minetest,代码行数:101,
示例5: spvoid OutdoorPvP::OnCreatureCreate(Creature* creature){ CreatureScriptPair sp(creature->GetGUID().GetCounter(), creature); m_CreatureScriptStore.insert(sp);}
开发者ID:gragonvlad,项目名称:NewNPCBots,代码行数:5,
示例6: tbvoid tb(void) { // print a mini-trace if (!trace) return; sp("@");printHex((unsigned long)fetchptr); spb(' '); sp("s");printHex(sym); spb(' '); sp("i");printHex(inchar); speol();}
开发者ID:billroy,项目名称:Bitlash-2.0-RC3,代码行数:6,
示例7: previousvoid frame::patch_fp(int* fp) { frame previous(NULL, ((int*) sp()) - frame_sender_sp_offset, NULL); previous.set_link(fp);}
开发者ID:sebkirche,项目名称:strongtalk,代码行数:4,
示例8: sp// Return a unique id for this frame. The id must have a value where// we can distinguish identity and younger/older relationship. NULL// represents an invalid (incomparable) frame.inline intptr_t* frame::id() const { return sp();}
开发者ID:tetratec,项目名称:Runescape-Launcher,代码行数:6,
示例9: spinline intptr_t* frame::unextended_sp() const { return sp(); }
开发者ID:MuniyappanV,项目名称:jdk-source-code,代码行数:1,
示例10: spvoid frame::patch_pc(char* pc) { char** pc_addr = (char**) sp() - 1; *pc_addr = pc;}
开发者ID:sebkirche,项目名称:strongtalk,代码行数:4,
示例11: sender_spinline int frame::frame_size() const { return sender_sp() - sp(); }
开发者ID:MuniyappanV,项目名称:jdk-source-code,代码行数:1,
示例12: PEG_METHOD_ENTERvoid Cql2Dnf::_buildEvalHeap(){ PEG_METHOD_ENTER(TRC_CQL, "Cql2Dnf::_buildEvalHeap"); Stack<stack_el> stack; // Counter for Operands Uint32 j = 0; for (Uint32 i = 0, n = _operations.size(); i < n; i++) { OperationType op = _operations[i]; switch (op) { case CQL_OR: case CQL_AND: { PEGASUS_ASSERT(stack.size() >= 2); stack_el op1 = stack.top(); stack.pop(); stack_el op2 = stack.top(); // generate Eval expression eval_heap.append(eval_el(0, op , op1.opn, op1.is_terminal, op2.opn , op2.is_terminal)); stack.top() = stack_el(eval_heap.size()-1, false); break; } case CQL_NOT: { PEGASUS_ASSERT(stack.size() >= 1); stack_el op1 = stack.top(); // generate Eval expression eval_heap.append(eval_el(0, op , op1.opn, op1.is_terminal, -1, true)); stack.top() = stack_el(eval_heap.size()-1, false); break; } case CQL_EQ: case CQL_NE: case CQL_LT: case CQL_LE: case CQL_GT: case CQL_GE: case CQL_ISA: case CQL_LIKE: { PEGASUS_ASSERT(_operands.size() >= 2); CQLExpression lhs = _operands[j++]; CQLExpression rhs = _operands[j++]; CQLSimplePredicate sp(lhs,rhs,_convertOpType(op)); terminal_heap.push(term_el(false, sp)); stack.push(stack_el(terminal_heap.size()-1, true)); break; } case CQL_IS_NULL: { PEGASUS_ASSERT(_operands.size() >= 1); CQLExpression expression = _operands[j++]; CQLSimplePredicate dummy(expression,IS_NULL); terminal_heap.push(term_el(false, dummy)); stack.push(stack_el(terminal_heap.size()-1, true)); break; } case CQL_IS_NOT_NULL: { PEGASUS_ASSERT(_operands.size() >= 1); CQLExpression expression = _operands[j++]; CQLSimplePredicate dummy(expression,IS_NOT_NULL); terminal_heap.push(term_el(false, dummy)); stack.push(stack_el(terminal_heap.size()-1, true)); break; } case CQL_NOOP: default: break; } }//.........这里部分代码省略.........
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:101,
示例13: mainint main(void){ int64 t0; int64 x0=10000000000; int64 x1=32; int64 x2=32; s=(int64*)calloc(q,sizeof(int64)); sa(0); sa(1000); sa(1000);_1: if(sp()!=0)goto _3;else goto _2;_2: sp(); printf("%lld ", (int64)(sp())); return 0;_3: x2=sr(); sa(sr()); x1=sr();_4: {int64 v0=sp();int64 v1=sp();sa(v0);sa(v1);} sa(sp()-1LL); sa(sr()); if(sp()!=0)goto _6;else goto _5;_5: sp(); sp(); sa(sp()+x1); sa(tm(sp(),x0)); sa(x2-1); sa(x2-1); goto _1;_6: {int64 v0=sp();int64 v1=sp();sa(v0);sa(v1);} t0=tm(sr()*x1,x0); x1=t0; goto _4;}
开发者ID:Mikescher,项目名称:Project-Euler_Befunge,代码行数:43,
示例14: constrainStackbool TraceBuilder::constrainStack(int32_t idx, TypeConstraint tc) { return constrainStack(sp(), idx, tc);}
开发者ID:krady,项目名称:hhvm,代码行数:3,
示例15: installSpeciesbool installSpecies(size_t k, const XML_Node& s, thermo_t& th, SpeciesThermo* spthermo_ptr, int rule, XML_Node* phaseNode_ptr, VPSSMgr* vpss_ptr, SpeciesThermoFactory* factory){ std::string xname = s.name(); if (xname != "species") { throw CanteraError("installSpecies", "Unexpected XML name of species XML_Node: " + xname); } if (rule) { th.ignoreUndefinedElements(); } // get the composition of the species const XML_Node& a = s.child("atomArray"); map<string,string> comp; getMap(a, comp); // construct a vector of atom numbers for each element in phase th. Elements // not declared in the species (i.e., not in map comp) will have zero // entries in the vector. size_t nel = th.nElements(); vector_fp ecomp(nel, 0.0); compositionMap comp_map = parseCompString(a.value()); for (size_t m = 0; m < nel; m++) { std::string& es = comp[th.elementName(m)]; if (!es.empty()) { ecomp[m] = fpValueCheck(es); } } // get the species charge, if any. Note that the charge need // not be explicitly specified if special element 'E' // (electron) is one of the elements. doublereal chrg = 0.0; if (s.hasChild("charge")) { chrg = getFloat(s, "charge"); } // get the species size, if any. (This is used by surface // phases to represent how many sites a species occupies.) doublereal sz = 1.0; if (s.hasChild("size")) { sz = getFloat(s, "size"); } if (vpss_ptr) { th.addUniqueSpecies(s["name"], &ecomp[0], chrg, sz); VPStandardStateTP* vp_ptr = dynamic_cast<VPStandardStateTP*>(&th); vp_ptr->createInstallPDSS(k, s, phaseNode_ptr); } else { SpeciesThermoInterpType* st = newSpeciesThermoInterpType(s); Species sp(s["name"], comp_map, st, chrg, sz); // Read gas-phase transport data, if provided if (s.hasChild("transport") && s.child("transport")["model"] == "gas_transport") { XML_Node& tr = s.child("transport"); string geometry, dummy; getString(tr, "geometry", geometry, dummy); double diam = getFloat(tr, "LJ_diameter"); double welldepth = getFloat(tr, "LJ_welldepth"); double dipole = 0.0; getOptionalFloat(tr, "dipoleMoment", dipole); double polar = 0.0; getOptionalFloat(tr, "polarizability", polar); double rot = 0.0; getOptionalFloat(tr, "rotRelax", rot); double acentric = 0.0; getOptionalFloat(tr, "acentric_factor", acentric); GasTransportData* gastran = new GasTransportData; gastran->setCustomaryUnits(sp.name, geometry, diam, welldepth, dipole, polar, rot, acentric); sp.transport.reset(gastran); gastran->validate(sp); } th.addSpecies(sp); } return true;}
开发者ID:hkmoffat,项目名称:cantera,代码行数:90,
示例16: ThreadStartedvoid *EmergeThread::Thread() { ThreadStarted(); log_register_thread("EmergeThread" + itos(id)); DSTACK(__FUNCTION_NAME); BEGIN_DEBUG_EXCEPTION_HANDLER v3s16 last_tried_pos(-32768,-32768,-32768); // For error output v3s16 p; u8 flags; map = (ServerMap *)&(m_server->m_env->getMap()); emerge = m_server->m_emerge; mapgen = emerge->mapgen[id]; enable_mapgen_debug_info = emerge->mapgen_debug_info; while (!StopRequested()) try { if (!popBlockEmerge(&p, &flags)) { qevent.wait(); continue; } last_tried_pos = p; if (blockpos_over_limit(p)) continue; bool allow_generate = flags & BLOCK_EMERGE_ALLOWGEN; EMERGE_DBG_OUT("p=" PP(p) " allow_generate=" << allow_generate); /* Try to fetch block from memory or disk. If not found and asked to generate, initialize generator. */ BlockMakeData data; MapBlock *block = NULL; std::map<v3s16, MapBlock *> modified_blocks; if (getBlockOrStartGen(p, &block, &data, allow_generate) && mapgen) { { ScopeProfiler sp(g_profiler, "EmergeThread: Mapgen::makeChunk", SPT_AVG); TimeTaker t("mapgen::make_block()"); mapgen->makeChunk(&data); if (enable_mapgen_debug_info == false) t.stop(true); // Hide output } { //envlock: usually 0ms, but can take either 30 or 400ms to acquire JMutexAutoLock envlock(m_server->m_env_mutex); ScopeProfiler sp(g_profiler, "EmergeThread: after " "Mapgen::makeChunk (envlock)", SPT_AVG); map->finishBlockMake(&data, modified_blocks); block = map->getBlockNoCreateNoEx(p); if (block) { /* Do some post-generate stuff */ v3s16 minp = data.blockpos_min * MAP_BLOCKSIZE; v3s16 maxp = data.blockpos_max * MAP_BLOCKSIZE + v3s16(1,1,1) * (MAP_BLOCKSIZE - 1); // Ignore map edit events, they will not need to be sent // to anybody because the block hasn't been sent to anybody MapEditEventAreaIgnorer ign(&m_server->m_ignore_map_edit_events_area, VoxelArea(minp, maxp)); try { // takes about 90ms with -O1 on an e3-1230v2 m_server->getScriptIface()->environment_OnGenerated( minp, maxp, emerge->getBlockSeed(minp)); } catch(LuaError &e) { m_server->setAsyncFatalError(e.what()); } EMERGE_DBG_OUT("ended up with: " << analyze_block(block)); m_server->m_env->activateBlock(block, 0); } } } /* Set sent status of modified blocks on clients */ // Add the originally fetched block to the modified list if (block) modified_blocks[p] = block; if (modified_blocks.size() > 0) { m_server->SetBlocksNotSent(modified_blocks); } } catch (VersionMismatchException &e) { std::ostringstream err; err << "World data version mismatch in MapBlock "<<PP(last_tried_pos)<<std::endl; err << "----"<<std::endl; err << "/""<<e.what()<<"/""<<std::endl;//.........这里部分代码省略.........
开发者ID:prodigeni,项目名称:minetest,代码行数:101,
示例17: UHD_SAFE_MAINint UHD_SAFE_MAIN(int argc, char *argv[]){ if (uhd::set_thread_priority_safe(1,true)) { std::cout << "set priority went well " << std::endl; }; #if 0 int portno=30000; //int s=socket(AF_INET,SOCK_STREAM,0); struct sockaddr_in server; struct hostent *hp; struct in_addr ipv4addr; inet_pton(AF_INET, "127.0.0.1", &ipv4addr); bzero((char *)&server, sizeof (server)); hp = gethostbyaddr(&ipv4addr,sizeof(ipv4addr), AF_INET); bcopy(hp->h_addr, (char *)&server.sin_addr, hp->h_length); server.sin_family = hp->h_addrtype; server.sin_port = htons(portno); int s = socket(hp->h_addrtype, SOCK_STREAM, 0); if (s < 0) std::cerr << "ERROR opening socket"; connect(s, (struct sockaddr *)&server, sizeof(server)); usleep(1003); char buffer[6]; usleep(1e6); buffer[0]=65; buffer[1]=66; buffer[2]=67; buffer[3]=68; buffer[4]=10; buffer[5]=0; short nb[5]; nb[0]=htons(23); nb[1]=htons(-24); nb[2]=htons(77); nb[3]=htons(-18); nb[4]=htons(-33); std::cout << "strlen=" << strlen(buffer) << "/n"; for (int i1=0;i1<10;i1++) { std::cout << "buffer[" << i1 << "]=" << (unsigned int)buffer[i1] << "/n"; }; //int n = write(s,buffer,strlen(buffer)); int n = write(s,nb,sizeof(nb)); std::cout << "n=" << n << "/n"; if (n < 0) std::cerr << "ERROR writing to socket"; close(s); usleep(100e6); #endif //variables to be set by po std::string args; double seconds_in_future; size_t total_num_samps, total_num_repeats; int send_to_listener; double rate, freq_tx, freq_rx; float gain; std::string filename_rx, filename_tx; uhd::tx_streamer::sptr tx_stream; uhd::rx_streamer::sptr rx_stream; uhd::device_addr_t dev_addr; uhd::usrp::multi_usrp::sptr dev; uhd::stream_args_t stream_args; //setup the program options po::options_description desc("Allowed options"); desc.add_options() ("help", "help message") ("args", po::value<std::string>(&args)->default_value(""), "simple uhd device address args") ("secs", po::value<double>(&seconds_in_future)->default_value(0.5), "number of seconds in the future to transmit") ("nsamps", po::value<size_t>(&total_num_samps)->default_value(1000), "Total number of samples to transmit and receive") ("nrep", po::value<size_t>(&total_num_repeats)->default_value(1), "Total number of repeats") ("rate", po::value<double>(&rate)->default_value(100e6/8), "rate of outgoing and ingoing samples") ("freq_rx", po::value<double>(&freq_rx)->default_value(20e6), "receive center frequency in Hz") ("freq_tx", po::value<double>(&freq_tx)->default_value(20e6), "transmit center frequency in Hz") ("filename_tx",po::value<std::string>(&filename_tx)->default_value("data_to_usrp.dat"), "tx filename") ("filename_rx",po::value<std::string>(&filename_rx)->default_value("data_from_usrp.dat"), "rx filename") ("gain",po::value<float>(&gain)->default_value(0), "gain of transmitter") ("n",po::value<int>(&send_to_listener)->default_value(0), "Every n:th received buffer is sent to a client listening on port 3000. ") ; //.........这里部分代码省略.........
开发者ID:dublinsky,项目名称:kth_usrp_utilities,代码行数:101,
示例18: uinline bool CDS_YHay<Tprec, Dim>::calcCoefficients3D () { prec_t dyz = dy * dz, dyz_dx = Gamma * dyz / dx; prec_t dxz = dx * dz, dxz_dy = Gamma * dxz / dy; prec_t dxy = dx * dy, dxy_dz = Gamma * dxy / dz; prec_t dxyz_dt = dx * dy * dz / dt; prec_t ce, cep, cem, cw, cwp, cwm, CE, CW; prec_t cn, cnp, cnm, cs, csp, csm, CN, CS; prec_t cf, cfp, cfm, cb, cbp, cbm, CF, CB; prec_t RaGaVol = Rayleigh * Gamma * 0.5 * dx * dy * dz; aE = 0.0; aW = 0.0; aN = 0.0; aS = 0.0; aF = 0.0; aB = 0.0; aP = 0.0; sp = 0.0; for (int k = bk; k <= ek; ++k) for (int i = bi; i <= ei; ++i) for (int j = bj; j <= ej; ++j) { CE = ce = ( u(i ,j,k) + u(i ,j+1,k ) ) * 0.5 * dyz; CW = cw = ( u(i-1,j,k) + u(i-1,j+1,k ) ) * 0.5 * dyz; CN = cn = ( v(i ,j,k) + v(i ,j+1,k ) ) * 0.5 * dxz; CS = cs = ( v(i ,j,k) + v(i ,j-1,k ) ) * 0.5 * dxz; CF = cf = ( w(i ,j,k) + w(i ,j ,k+1) ) * 0.5 * dxy; CB = cb = ( w(i-1,j,k) + w(i-1,j ,k+1) ) * 0.5 * dxy; cem = cep = 0; cwm = cwp = 0; cnm = cnp = 0; csm = csp = 0; cfm = cfp = 0; cbm = cbp = 0; if ( ce > 0 ){ CE = 0; cep = ce * 0.5 * (-phi_0(i,j,k) + phi_0(i+1,j,k)); } else { cem = ce * 0.5 * (phi_0(i,j,k) - phi_0(i+1,j,k)); } if ( cw > 0 ){ cwp = cw * 0.5 * (-phi_0(i-1,j,k) + phi_0(i,j,k)); } else { CW = 0.0; cwm = cw * 0.5 * (phi_0(i-1,j,k) - phi_0(i,j,k)); } if ( cn > 0 ){ CN = 0; cnp = cn * 0.5 * (-phi_0(i,j,k) + phi_0(i,j+1,k)); } else { cnm = cn * 0.5 * (phi_0(i,j,k) - phi_0(i,j+1,k)); } if ( cs > 0 ){ csp = cs * 0.5 * (-phi_0(i,j-1,k) + phi_0(i,j,k)); } else { CS = 0.0; csm = cs * 0.5 * (phi_0(i,j-1,k) - phi_0(i,j,k)); } if ( cf > 0 ){ CF = 0; cfp = cf * 0.5 * (-phi_0(i,j,k) + phi_0(i,j,k+1)); } else { cfm = cf * 0.5 * (phi_0(i,j,k) - phi_0(i,j,k+1)); } if ( cb > 0 ){ cbp = cb * 0.5 * (-phi_0(i,j,k-1) + phi_0(i,j,k)); } else { CB = 0.0; cbm = cb * 0.5 * (phi_0(i,j,k-1) - phi_0(i,j,k)); } aE (i,j,k) = dyz_dx - CE; aW (i,j,k) = dyz_dx + CW; aN (i,j,k) = dxz_dy - CN; aS (i,j,k) = dxz_dy + CS; aF (i,j,k) = dxy_dz - CF; aB (i,j,k) = dxy_dz + CB; aP (i,j,k) = aE (i,j,k) + aW (i,j,k) + aN (i,j,k) + aS (i,j,k) + aF (i,j,k) + aB (i,j,k) + dxyz_dt + (ce - cw) + (cn - cs) + (cn - cs); sp (i,j,k) += v(i,j,k) * dxyz_dt - ( p(i,j+1,k) - p(i,j,k) ) * dxz + RaGaVol * ( T(i,j,k) + T(i,j+1,k) ) - (cep + cem - cwp - cwm + cnp + cnm - csp - csm + cfp + cfm - cbp - cbm); } calc_dv_3D(); applyBoundaryConditions3D(); return 0;}
开发者ID:jesushl,项目名称:TUNAM,代码行数:90,
示例19: constrainStackvoid TraceBuilder::constrainStack(int32_t idx, DataTypeCategory cat) { constrainStack(sp(), idx, cat);}
开发者ID:jacano1969,项目名称:hiphop-php,代码行数:3,
示例20: DSTACKint RemoteClient::GetNextBlocks ( ServerEnvironment *env, EmergeManager * emerge, float dtime, double m_uptime, std::vector<PrioritySortedBlockTransfer> &dest){ DSTACK(FUNCTION_NAME); auto lock = lock_unique_rec(); if (!lock->owns_lock()) return 0; // Increment timers m_nothing_to_send_pause_timer -= dtime; m_nearest_unsent_reset_timer += dtime; m_time_from_building += dtime; if (m_nearest_unsent_reset) { m_nearest_unsent_reset = 0; m_nearest_unsent_reset_timer = 999; m_nothing_to_send_pause_timer = 0; m_time_from_building = 999; } if(m_nothing_to_send_pause_timer >= 0) return 0; Player *player = env->getPlayer(peer_id); // This can happen sometimes; clients and players are not in perfect sync. if(player == NULL) return 0; v3f playerpos = player->getPosition(); v3f playerspeed = player->getSpeed(); if(playerspeed.getLength() > 1000.0*BS) //cheater or bug, ignore him return 0; v3f playerspeeddir(0,0,0); if(playerspeed.getLength() > 1.0*BS) playerspeeddir = playerspeed / playerspeed.getLength(); // Predict to next block v3f playerpos_predicted = playerpos + playerspeeddir*MAP_BLOCKSIZE*BS; v3s16 center_nodepos = floatToInt(playerpos_predicted, BS); v3s16 center = getNodeBlockPos(center_nodepos); // Camera position and direction v3f camera_pos = player->getEyePosition(); v3f camera_dir = v3f(0,0,1); camera_dir.rotateYZBy(player->getPitch()); camera_dir.rotateXZBy(player->getYaw()); //infostream<<"camera_dir=("<<camera_dir<<")"<< " camera_pos="<<camera_pos<<std::endl; /* Get the starting value of the block finder radius. */ if(m_last_center != center) { m_last_center = center; m_nearest_unsent_reset_timer = 999; } if (m_last_direction.getDistanceFrom(camera_dir)>0.4) { // 1 = 90deg m_last_direction = camera_dir; m_nearest_unsent_reset_timer = 999; } /*infostream<<"m_nearest_unsent_reset_timer=" <<m_nearest_unsent_reset_timer<<std::endl;*/ // Reset periodically to workaround for some bugs or stuff if(m_nearest_unsent_reset_timer > 120.0) { m_nearest_unsent_reset_timer = 0; m_nearest_unsent_d = 0; m_nearest_unsent_reset = 0; //infostream<<"Resetting m_nearest_unsent_d for "<<peer_id<<std::endl; } //s16 last_nearest_unsent_d = m_nearest_unsent_d; s16 d_start = m_nearest_unsent_d; //infostream<<"d_start="<<d_start<<std::endl; static const u16 max_simul_sends_setting = g_settings->getU16 ("max_simultaneous_block_sends_per_client"); static const u16 max_simul_sends_usually = max_simul_sends_setting; /* Check the time from last addNode/removeNode. Decrease send rate if player is building stuff. */ static const auto full_block_send_enable_min_time_from_building = g_settings->getFloat("full_block_send_enable_min_time_from_building"); if(m_time_from_building < full_block_send_enable_min_time_from_building) { /*//.........这里部分代码省略.........
开发者ID:carriercomm,项目名称:freeminer,代码行数:101,
示例21: spvoid RigidBody2D::_direct_state_changed(Object *p_state) { //eh.. fuck#ifdef DEBUG_ENABLED state=p_state->cast_to<Physics2DDirectBodyState>();#else state=(Physics2DDirectBodyState*)p_state; //trust it#endif if (contact_monitor) { //untag all int rc=0; for( Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.front();E;E=E->next()) { for(int i=0;i<E->get().shapes.size();i++) { E->get().shapes[i].tagged=false; rc++; } } _RigidBody2DInOut *toadd=(_RigidBody2DInOut*)alloca(state->get_contact_count()*sizeof(_RigidBody2DInOut)); int toadd_count=0;//state->get_contact_count(); RigidBody2D_RemoveAction *toremove=(RigidBody2D_RemoveAction*)alloca(rc*sizeof(RigidBody2D_RemoveAction)); int toremove_count=0; //put the ones to add for(int i=0;i<state->get_contact_count();i++) { ObjectID obj = state->get_contact_collider_id(i); int local_shape = state->get_contact_local_shape(i); int shape = state->get_contact_collider_shape(i); toadd[i].local_shape=local_shape; toadd[i].id=obj; toadd[i].shape=shape;// bool found=false; Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.find(obj); if (!E) { toadd_count++; continue; } ShapePair sp( shape,local_shape ); int idx = E->get().shapes.find(sp); if (idx==-1) { toadd_count++; continue; } E->get().shapes[idx].tagged=true; } //put the ones to remove for( Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.front();E;E=E->next()) { for(int i=0;i<E->get().shapes.size();i++) { if (!E->get().shapes[i].tagged) { toremove[toremove_count].body_id=E->key(); toremove[toremove_count].pair=E->get().shapes[i]; toremove_count++; } } } //process remotions for(int i=0;i<toremove_count;i++) { _body_inout(0,toremove[i].body_id,toremove[i].pair.body_shape,toremove[i].pair.local_shape); } //process aditions for(int i=0;i<toadd_count;i++) { _body_inout(1,toadd[i].id,toadd[i].shape,toadd[i].local_shape); } } set_block_transform_notify(true); // don't want notify (would feedback loop) if (mode!=MODE_KINEMATIC) set_global_transform(state->get_transform()); linear_velocity=state->get_linear_velocity(); angular_velocity=state->get_angular_velocity(); active=!state->is_sleeping(); if (get_script_instance()) get_script_instance()->call("_integrate_forces",state); set_block_transform_notify(false); // want it back//.........这里部分代码省略.........
开发者ID:BigJoe02,项目名称:godot,代码行数:101,
示例22: QLineFQList<Polygon> Polygon::convexPartition() const { // precondition: ccw; see mnbayazit.com/406/bayazit for details about how this works QList<Polygon> list; qreal d, dist1, dist2; QPointF ip, ip1, ip2; // intersection points int ind1, ind2; Polygon poly1, poly2; for(int i = 0; i < size(); ++i) { if(reflex(i)) { dist1 = dist2 = std::numeric_limits<qreal>::max(); for(int j = 0; j < size(); ++j) { if(left(at(i - 1), at(i), at(j)) && rightOn(at(i - 1), at(i), at(j - 1))) { // if ray (i-1)->(i) intersects with edge (j, j-1) QLineF(at(i - 1), at(i)).intersect(QLineF(at(j), at(j - 1)), &ip); if(right(at(i + 1), at(i), ip)) { // intersection point isn't caused by backwards ray d = sqdist(at(i), ip); if(d < dist1) { // take the closest intersection so we know it isn't blocked by another edge dist1 = d; ind1 = j; ip1 = ip; } } } if(left(at(i + 1), at(i), at(j + 1)) && rightOn(at(i + 1), at(i), at(j))) { // if ray (i+1)->(i) intersects with edge (j+1, j) QLineF(at(i + 1), at(i)).intersect(QLineF(at(j), at(j + 1)), &ip); if(left(at(i - 1), at(i), ip)) { d = sqdist(at(i), ip); if(d < dist2) { dist2 = d; ind2 = j; ip2 = ip; } } } } if(ind1 == (ind2 + 1) % size()) { // no vertices in range QPointF sp((ip1 + ip2) / 2); poly1 = copy(i, ind2); poly1.append(sp); poly2 = copy(ind1, i); poly2.append(sp); } else { double highestScore = 0, bestIndex = ind1, score; while(ind2 < ind1) ind2 += size(); for(int j = ind1; j <= ind2; ++j) { if(canSee(i, j)) { score = 1 / (sqdist(at(i), at(j)) + 1); if(reflex(j)) { if(rightOn(at(j - 1), at(j), at(i)) && leftOn(at(j + 1), at(j), at(i))) { score += 3; } else { score += 2; } } else { score += 1; } if(score > highestScore) { bestIndex = j; highestScore = score; } } } poly1 = copy(i, bestIndex); poly2 = copy(bestIndex, i); } list += poly1.convexPartition(); list += poly2.convexPartition(); return list; } } // polygon is already convex if(size() > b2_maxPolygonVertices) { poly1 = copy(0, size() / 2); poly2 = copy(size() / 2, 0); list += poly1.convexPartition(); list += poly2.convexPartition(); } else list.append(*this); return list;}
开发者ID:AntonioModer,项目名称:phed,代码行数:78,
示例23: onvoid Language_C::_write_parse_func( std::ostream &os ) { StreamSepMaker<std::ostream> on( os ); int nb_spaces = 5; String sp( nb_spaces, ' ' ); on.beg = sp.c_str(); // parse os << "int parse" << f_suf << "( " << cp->struct_name << " *sipe_data, SIPE_CHARP data, SIPE_CHARP end ) {/n"; if ( nb_marks ) on << "SIPE_CHARP beg_data = data;/n"; on << "if ( sipe_data->_inp_cont )"; on << " goto *sipe_data->_inp_cont;"; on << ""; on << "#define INCR( N ) if ( ++data >= end ) goto p_##N; c_##N:"; on << ""; // blocks for( int i = 0; i < block_seq.size(); ++i ) { Block *b = block_seq[ i ]; if ( not b->write ) continue; // if ( b->label >= 0 ) { os << "l_" << b->label << ":"; on.first_beg = on.beg + std::min( nb_spaces, 3 + nb_digits( b->label ) ); } // if ( b->state ) { // action if ( b->state->action ) b->state->action->write_code( on, this ); // end ? if ( b->state->end ) { on << "sipe_data->_inp_cont = &&l_" << b->label << ";"; on << "return " << b->state->end << ";"; } // if ( b->state->set_mark ) { on << "sipe_data->_mark[ " << marks[ b->state ] << " ] = data;"; on << "sipe_data->_mark_data[ " << marks[ b->state ] << " ].clear();"; } // if ( b->state->use_mark ) { int nm = marks[ b->state->use_mark ]; on << "if ( sipe_data->_mark[ " << nm << " ] ) {"; on << " data = sipe_data->_mark[ " << nm << " ];"; on << "} else {"; // on << " std::cout << '-' << sipe_data->_mark_data[ " << nm << " ] << '-' << std::endl;"; on << " sipe_data->_inp_cont = &&cnt_mark_" << b << ";"; on << " SIPE_CHARP beg = (SIPE_CHARP)sipe_data->_mark_data[ " << nm << " ].data();"; on << " int res = parse( sipe_data, beg, beg + sipe_data->_mark_data[ " << nm << " ].size() );"; on << " if ( res )"; on << " return res;"; on << " data = beg_data;"; on << " goto *sipe_data->_inp_cont;"; on << "}"; os << "cnt_mark_" << b << ":/n"; } // if ( b->state->rem_mark ) { } // if ( b->state->incc ) { on << "INCR( " << cnt.size() << " )"; Cnt c; c.block = b; c.label = b->label; cnt << c; } } // if ( b->ko ) { if ( b->t_ok ) { // if ( cond ) goto ok; String cond = b->cond.ok_cpp( "*data", &b->not_in ); on << "if ( " << cond << " ) goto l_" << b->ok->label << ";"; } else { // if ( not cond ) goto ko; String cond = b->cond.ko_cpp( "*data", &b->not_in ); on << "if ( " << cond << " ) goto l_" << b->ko->label << ";"; } } // if ( b->write_goto ) on << "goto l_" << b->write_goto->label << ";"; } // cnt for( int i = 0; i < cnt.size(); ++i ) { os << "p_" << i << ":"; on.first_beg = on.beg + std::min( nb_spaces, 3 + nb_digits( i ) ); if ( const State *m = cnt[ i ].block->mark ) {//.........这里部分代码省略.........
开发者ID:structure-computation,项目名称:Sipe,代码行数:101,
示例24: TESTTEST(RecordIOTest, Randomized) { SCOPED_TRACE(to<std::string>("Random seed is ", FLAGS_random_seed)); std::mt19937 rnd(FLAGS_random_seed); size_t recordCount = std::uniform_int_distribution<uint32_t>(30, 300)(rnd); std::uniform_int_distribution<uint32_t> recordSizeDist(1, 3 << 16); std::uniform_int_distribution<uint32_t> charDist(0, 255); std::uniform_int_distribution<uint32_t> junkDist(0, 1 << 20); // corrupt 1/5 of all records std::uniform_int_distribution<uint32_t> corruptDist(0, 4); std::vector<std::pair<fbstring, off_t>> records; std::vector<off_t> corruptPositions; records.reserve(recordCount); TemporaryFile file; fbstring record; // Recreate the writer multiple times so we test that we create a // continuous stream for (size_t i = 0; i < 3; ++i) { RecordIOWriter writer(File(file.fd())); for (size_t j = 0; j < recordCount; ++j) { off_t beginPos = writer.filePos(); record.clear(); size_t recordSize = recordSizeDist(rnd); record.reserve(recordSize); for (size_t k = 0; k < recordSize; ++k) { record.push_back(charDist(rnd)); } writer.write(iobufs({record})); bool corrupt = (corruptDist(rnd) == 0); if (corrupt) { // Corrupt one random byte in the record (including header) std::uniform_int_distribution<uint32_t> corruptByteDist( 0, recordSize + recordio_helpers::headerSize() - 1); off_t corruptRel = corruptByteDist(rnd); VLOG(1) << "n=" << records.size() << " bpos=" << beginPos << " rsize=" << record.size() << " corrupt rel=" << corruptRel << " abs=" << beginPos + corruptRel; corruptPositions.push_back(beginPos + corruptRel); } else { VLOG(2) << "n=" << records.size() << " bpos=" << beginPos << " rsize=" << record.size() << " good"; records.emplace_back(std::move(record), beginPos); } } VLOG(1) << "n=" << records.size() << " close abs=" << writer.filePos(); } for (auto& pos : corruptPositions) { corrupt(file.fd(), pos); } { size_t i = 0; RecordIOReader reader(File(file.fd())); for (auto& r : reader) { SCOPED_TRACE(i); ASSERT_LT(i, records.size()); EXPECT_EQ(records[i].first, sp(r.first)); EXPECT_EQ(records[i].second, r.second); ++i; } EXPECT_EQ(records.size(), i); }}
开发者ID:15Koala,项目名称:folly,代码行数:71,
示例25: DSTACKvoid Client::step(float dtime){ DSTACK(__FUNCTION_NAME); // Limit a bit if(dtime > 2.0) dtime = 2.0; if(m_ignore_damage_timer > dtime) m_ignore_damage_timer -= dtime; else m_ignore_damage_timer = 0.0; m_animation_time += dtime; if(m_animation_time > 60.0) m_animation_time -= 60.0; m_time_of_day_update_timer += dtime; ReceiveAll(); /* Packet counter */ { float &counter = m_packetcounter_timer; counter -= dtime; if(counter <= 0.0) { counter = 20.0; infostream << "Client packetcounter (" << m_packetcounter_timer << "):"<<std::endl; m_packetcounter.print(infostream); m_packetcounter.clear(); } } // UGLY hack to fix 2 second startup delay caused by non existent // server client startup synchronization in local server or singleplayer mode static bool initial_step = true; if (initial_step) { initial_step = false; } else if(m_state == LC_Created) { float &counter = m_connection_reinit_timer; counter -= dtime; if(counter <= 0.0) { counter = 2.0; Player *myplayer = m_env.getLocalPlayer(); FATAL_ERROR_IF(myplayer == NULL, "Local player not found in environment."); // Send TOSERVER_INIT_LEGACY // [0] u16 TOSERVER_INIT_LEGACY // [2] u8 SER_FMT_VER_HIGHEST_READ // [3] u8[20] player_name // [23] u8[28] password (new in some version) // [51] u16 minimum supported network protocol version (added sometime) // [53] u16 maximum supported network protocol version (added later than the previous one) char pName[PLAYERNAME_SIZE]; char pPassword[PASSWORD_SIZE]; memset(pName, 0, PLAYERNAME_SIZE * sizeof(char)); memset(pPassword, 0, PASSWORD_SIZE * sizeof(char)); std::string hashed_password = translatePassword(myplayer->getName(), m_password); snprintf(pName, PLAYERNAME_SIZE, "%s", myplayer->getName()); snprintf(pPassword, PASSWORD_SIZE, "%s", hashed_password.c_str()); sendLegacyInit(pName, pPassword); if (LATEST_PROTOCOL_VERSION >= 25) sendInit(myplayer->getName()); } // Not connected, return return; } /* Do stuff if connected */ /* Run Map's timers and unload unused data */ const float map_timer_and_unload_dtime = 5.25; if(m_map_timer_and_unload_interval.step(dtime, map_timer_and_unload_dtime)) { ScopeProfiler sp(g_profiler, "Client: map timer and unload"); std::vector<v3s16> deleted_blocks; m_env.getMap().timerUpdate(map_timer_and_unload_dtime, g_settings->getFloat("client_unload_unused_data_timeout"), &deleted_blocks); /* Send info to server NOTE: This loop is intentionally iterated the way it is. */ std::vector<v3s16>::iterator i = deleted_blocks.begin();//.........这里部分代码省略.........
开发者ID:4aiman,项目名称:Magichet-stable,代码行数:101,
示例26: returninline address* frame::I0_addr() const { return (address*) &sp()[ I0->sp_offset_in_saved_window()]; }
开发者ID:campolake,项目名称:openjdk9,代码行数:1,
注:本文中的sp函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ spListElementCreate函数代码示例 C++ sources函数代码示例 |