void try_loading(HANDLE hfile, global_routing_params*& params, LARGE_INTEGER size) { if(params != NULL) delete [] (unsigned char*)params; params = NULL; unsigned char* view_of_file = (unsigned char*)MapViewOfFile(hfile, FILE_MAP_READ, 0, 0, 0); unsigned char* buffer = NULL; __try { buffer = new unsigned char[size.QuadPart]; memcpy(buffer, view_of_file, size.QuadPart); UnmapViewOfFile(view_of_file); view_of_file = NULL; const size_t routing_params_size = global_size(params = rebase(buffer)); if(size.QuadPart != routing_params_size || !routing_params_size) // validates parameters throw; // will be catched at the parent except clause } __except(EXCEPTION_EXECUTE_HANDLER) { if(view_of_file) UnmapViewOfFile(view_of_file); if(buffer) delete [] buffer; params = NULL; throw std::wstring(L"The " LOCAL_PARAMS_FILE L" file is corrupted. Please delete the " \ L"file and open Audio Router again.\n"); } }
void DB::newPart(bool doRebase) { if(doRebase) { rebase(/* force */ true); } m_pio->newPart(); }
void OctTree::handleObjectPlacement(OctTree::ObjType * obj) { int whereIsObj; BoundingBox objbox = boundingBox.boundingBoxForCollideable(obj); /// Remove object and try the parent. if (parent != NULL && boundingBox.numCornersContained(objbox) != kNumNodes) { remove(obj); parent->handleObjectPlacement(obj); } /// We need to rebase and then add the object. else { /// First, if the do not enclode the object, then while (boundingBox.numCornersContained(objbox) != kNumNodes) { whereIsObj = whichChildForPoint(obj->getPosition()); rebase((~whereIsObj) & (kNumNodes - 1)); } UTIL_ASSERT(encloses(obj->getPosition())); UTIL_ASSERT(boundingBox.numCornersContained(objbox) == kNumNodes); BoundingBox childbox = boundingBoxForChild(whichChildForPoint( obj->getPosition())); /// We pass it onto the child if (!objectLiesOnChildBoundaries(obj) && (activeChildren != 0 || numDirectlyHeldObjects() > getMaxLeafObjects()) && (GUtils::norm(getBoundingBox().getDimensions()) / 2.0) > kMinLeafDim && childbox.numCornersContained(objbox) == kNumNodes) { remove(obj); whereIsObj = whichChildForPoint(obj->getPosition()); UTIL_ASSERT(0 <= whereIsObj && whereIsObj < kNumNodes); if (children[whereIsObj] == NULL) { children[whereIsObj] = createChild(whereIsObj); } //setChildActive(whereIsObj, true); children[whereIsObj]->insert(obj); } /// We keep it to ourselves else { UTIL_ASSERT(encloses(obj->getPosition())); UTIL_ASSERT(boundingBox.numCornersContained(objbox) == kNumNodes); add(obj); updateActiveStates(this); obj->setPositionChanged(false); } } }
void AsemanSensors::refresh() { p->r_vector.x = p->pr_vector.x; p->r_vector.y = p->pr_vector.y; p->r_vector.z = p->pr_vector.z; p->a_vector = rebase(p->pa_vector); p->g_vector = rebase(p->pg_vector); return; const AsemanSensorsResItem & resX0 = analizeItem(p->a_vector.x,p->a_vector.y,p->a_vector.z,false); const AsemanSensorsResItem & resY0 = analizeItem(p->a_vector.y,p->a_vector.x,p->a_vector.z,false); const AsemanSensorsResItem & resX1 = analizeItem(p->a_vector.x,p->a_vector.y,p->a_vector.z,true); const AsemanSensorsResItem & resY1 = analizeItem(p->a_vector.y,p->a_vector.x,p->a_vector.z,true); AsemanSensorsResItem resX; if( qAbs(qAbs(90-resX0.beta*180/M_PI)-qAbs(angleY())) < qAbs(qAbs(90-resX1.beta*180/M_PI)-qAbs(angleY())) ) resX = resX0; else resX = resX1; AsemanSensorsResItem resY; if( qAbs(qAbs(90-resY0.beta*180/M_PI)-qAbs(angleX())) < qAbs(qAbs(90-resY1.beta*180/M_PI)-qAbs(angleX())) ) resY = resY0; else resY = resY1; int rvector_x_sign = angleX()<0? -1 : 1; int rvector_y_sign = angleY()<0? -1 : 1; p->r_vector.x = rvector_x_sign*(M_PI/2-resY.beta)*180/M_PI + p->zeroX*M_PI/180; p->r_vector.y = rvector_y_sign*(M_PI/2-resX.beta)*180/M_PI + p->zeroY*M_PI/180; p->a_vector.x = resX.newX; p->a_vector.y = resY.newX; }
void MachOObject::load() { if (isLoaded()) throw std::logic_error("Module already loaded"); if (strcmp(m_file->platform(), ARCH_NAME) != 0) { std::stringstream ss; ss << "This version of Darling dyld cannot load binaries for " << m_file->platform() << "."; throw std::runtime_error(ss.str()); } loadSegments(); transitionState(dyld_image_state_mapped); if (m_slide > 0) rebase(); transitionState(dyld_image_state_rebased); readSymbols(); readExports(); MachOMgr::instance()->add(this, isMainModule()); loadDependencies(); performRelocations(); performBinds(); transitionState(dyld_image_state_bound); transitionState(dyld_image_state_dependents_initialized); // registerEHSection(); if (isMainModule()) fillInProgramVars(); fillInDyldData(); setInitialSegmentProtection(); setupTLS(); MachOMgr::instance()->notifyAdd(this); runInitializers(); transitionState(dyld_image_state_initialized); m_file->closeFd(); if (MachOMgr::instance()->printLibraries()) std::cerr << "dyld: Loaded " << this->path() << std::endl; }
/*Rebase a function upon another to reduce the differences The main requiment is that the functions order still unchanged Don't delete useless functions and add new functions as last, or in another file*/ void rebase(TProtoFunc* func, TProtoFunc* base) { //Set the right filename and line number //luaS_free(func->fileName); func->lineDefined = base->lineDefined; func->fileName = base->fileName; //Uniformize the const list in order to reduce the differences uniform_const_list(func, base); //Recursively rebase nested functions //It assumes that the subfunctions has the same index for (int j = 0; j < func->nconsts; ++j) if (ttype(&func->consts[j]) == LUA_T_PROTO && ttype(&base->consts[j]) == LUA_T_PROTO) rebase(tfvalue(&func->consts[j]), tfvalue(&base->consts[j])); }
Uri::Uri(const Uri& other) : buffer(&other.buffer->copy()), port(other.port) { char* old_base = static_cast<char*>(*other.buffer); char* new_base = static_cast<char*>(*this->buffer); rebase(old_base, other.fragment, new_base, fragment); rebase(old_base, other.host, new_base, host); rebase(old_base, other.path, new_base, path); rebase(old_base, other.query, new_base, query); rebase(old_base, other.scheme, new_base, scheme); rebase(old_base, other.userinfo, new_base, userinfo); }
D20System::D20System() { pathfinding = &pathfindingSys; actSeq = &actSeqSys; d20Class = &d20ClassSys; d20Status = &d20StatusSys; rebase(D20StatusInitFromInternalFields, 0x1004F910); rebase(D20ObjRegistryAppend, 0x100DFAD0); rebase(d20EditorMode, 0x10AA3284); rebase(globD20Action, 0x1186AC00); rebase(ToHitProc, 0x100B7160); // rebase(d20Defs, 0x102CC5C8); d20Defs = (D20ActionDef*)&d20ActionDefsNew; d20ActionsTabFile = &_d20actionTabFile; d20actionTabLineParser = &_d20actionTabLineParser; //rebase(ToEEd20ActionNames, 0x102CD2BC); rebase(_d20aTriggerCombatCheck, 0x1008AE90);//ActnSeq * @<eax> rebase(_tumbleCheck, 0x1008AA90); rebase(_d20aTriggersAOO, 0x1008A9C0); rebase(CreateRollHistory, 0x100DFFF0); }
void TPIO::refreshOldPages(page_id_t threshold, size_t pgsPerTx) { // rOP: refreshOldPages // // case 1: // rOP s---e // Rebase s---e // // no prob // // case 2: // rOP s---e // Rebase s---e s---e // // no prob // // case 3: // rOP s-!---e // Rebase s-----e // // no prob. rOP waits until rebase is done // // case 4: // rOP s---e // Rebase s-!---e // // rebase need to wait until rOP finishes... BAD! // if(m_bDuringRefresh) { std::cout << "already during refresh" << std::endl; return; } PTNK_MEMBARRIER_COMPILER; if(! PTNK_CAS(&m_bDuringRefresh, false, true)) { std::cout << "already during refresh (CAS failed)" << std::endl; return; } PTNK_MEMBARRIER_COMPILER; #ifdef VERBOSE_REFRESH std::cout << "refresh start" << std::endl << *this; #endif void* cursor = NULL; do { unique_ptr<TPIOTxSession> tx(newTransaction()); Page pgStart(tx->readPage(tx->pgidStartPage())); pgStart.refreshAllLeafPages(&cursor, threshold, pgsPerTx, tx.get()); #ifdef VERBOSE_REFRESH tx->dumpStat(); #endif if(! tryCommit(tx.get(), COMMIT_REFRESH)) { std::cerr << "refresh ci failed!" << std::endl; } } while(cursor); PTNK_MEMBARRIER_COMPILER; m_bDuringRefresh = false; #ifdef VERBOSE_REFRESH std::cout << "refresh end" << std::endl << *this; #endif rebase(/* force = */ true); }
/** Reads contiguous buffer from dataset. The size of buffer must be the same as size of dataspace This function is threadsafe */ void read(T *buffer) const { timer t; apply(&H5Dread, this->parent_.id(), rebase(range_), buffer); // printf("File::read size=%lu bytes, rate=%f mb/s\n", // (sizeof(T)*size_), (sizeof(T)*size_)/(t*1e6)); }
/** Writes contiguous buffer into dataset. The size of buffer must be the same as size of dataspace This function is threadsafe */ void write(const T *buffer) { timer t; apply(&H5Dwrite, this->parent_.id(), rebase(range_), (T*) buffer); // printf("File::write size=%lu bytes, %f mb/s\n", // (sizeof(T)*size_), (sizeof(T)*size_)/(t*1e6)); }
void get(const std::vector<range> &r, void *buffer) const { _get(rebase(r), buffer); }
void put(const std::vector<range> &r, const void *buffer) { _put(rebase(r), buffer); }
PythonCheatsAddresses() { rebase(cheats, 0x102B02E8); }