void uaeserialdev_install (void) { uint32_t functable, datatable; uint32_t initcode, openfunc, closefunc, expungefunc; uint32_t beginiofunc, abortiofunc; if (!currprefs.uaeserial) return; ROM_uaeserialdev_resname = ds (_T("uaeserial.device")); ROM_uaeserialdev_resid = ds (_T("UAE serial.device 0.1")); /* initcode */ initcode = here (); calltrap (deftrap (dev_init)); dw (RTS); /* Open */ openfunc = here (); calltrap (deftrap (dev_open)); dw (RTS); /* Close */ closefunc = here (); calltrap (deftrap (dev_close)); dw (RTS); /* Expunge */ expungefunc = here (); calltrap (deftrap (dev_expunge)); dw (RTS); /* BeginIO */ beginiofunc = here (); calltrap (deftrap (dev_beginio)); dw (RTS); /* AbortIO */ abortiofunc = here (); calltrap (deftrap (dev_abortio)); dw (RTS); /* FuncTable */ functable = here (); dl (openfunc); /* Open */ dl (closefunc); /* Close */ dl (expungefunc); /* Expunge */ dl (EXPANSION_nullfunc); /* Null */ dl (beginiofunc); /* BeginIO */ dl (abortiofunc); /* AbortIO */ dl (0xFFFFFFFFul); /* end of table */ /* DataTable */ datatable = here (); dw (0xE000); /* INITBYTE */ dw (0x0008); /* LN_TYPE */ dw (0x0300); /* NT_DEVICE */ dw (0xC000); /* INITLONG */ dw (0x000A); /* LN_NAME */ dl (ROM_uaeserialdev_resname); dw (0xE000); /* INITBYTE */ dw (0x000E); /* LIB_FLAGS */ dw (0x0600); /* LIBF_SUMUSED | LIBF_CHANGED */ dw (0xD000); /* INITWORD */ dw (0x0014); /* LIB_VERSION */ dw (0x0004); /* 0.4 */ dw (0xD000); /* INITWORD */ dw (0x0016); /* LIB_REVISION */ dw (0x0000); dw (0xC000); /* INITLONG */ dw (0x0018); /* LIB_IDSTRING */ dl (ROM_uaeserialdev_resid); dw (0x0000); /* end of table */ ROM_uaeserialdev_init = here (); dl (0x00000100); /* size of device base */ dl (functable); dl (datatable); dl (initcode); nscmd_cmd = here (); dw (NSCMD_DEVICEQUERY); dw (CMD_RESET); dw (CMD_READ); dw (CMD_WRITE); dw (CMD_CLEAR); dw (CMD_START); dw (CMD_STOP); dw (CMD_FLUSH); dw (SDCMD_BREAK); dw (SDCMD_SETPARAMS); dw (SDCMD_QUERY); dw (0); }
Box* interpretFunction(llvm::Function *f, int nargs, Box* arg1, Box* arg2, Box* arg3, Box* *args) { assert(f); #ifdef TIME_INTERPRETS Timer _t("to interpret", 1000000); long this_us = 0; #endif static StatCounter interpreted_runs("interpreted_runs"); interpreted_runs.log(); llvm::DataLayout dl(f->getParent()); //f->dump(); //assert(nargs == f->getArgumentList().size()); SymMap symbols; void* frame_ptr = __builtin_frame_address(0); interpreter_roots[frame_ptr] = &symbols; UnregisterHelper helper(frame_ptr); int i = 0; for (llvm::Function::arg_iterator AI = f->arg_begin(), end = f->arg_end(); AI != end; AI++, i++) { if (i == 0) symbols.insert(std::make_pair(static_cast<llvm::Value*>(&(*AI)), Val(arg1))); else if (i == 1) symbols.insert(std::make_pair(static_cast<llvm::Value*>(&(*AI)), Val(arg2))); else if (i == 2) symbols.insert(std::make_pair(static_cast<llvm::Value*>(&(*AI)), Val(arg3))); else { assert(i == 3); assert(f->getArgumentList().size() == 4); assert(f->getArgumentList().back().getType() == g.llvm_value_type_ptr->getPointerTo()); symbols.insert(std::make_pair(static_cast<llvm::Value*>(&(*AI)), Val((int64_t)args))); //printf("loading %%4 with %p\n", (void*)args); break; } } llvm::BasicBlock *prevblock = NULL; llvm::BasicBlock *curblock = &f->getEntryBlock(); while (true) { for (llvm::BasicBlock::iterator it = curblock->begin(), end = curblock->end(); it != end; ++it) { if (VERBOSITY("interpreter") >= 2) { printf("executing in %s: ", f->getName().data()); fflush(stdout); it->dump(); //f->dump(); } #define SET(v) set(symbols, it, (v)) if (llvm::LoadInst *li = llvm::dyn_cast<llvm::LoadInst>(it)) { llvm::Value *ptr = li->getOperand(0); Val v = fetch(ptr, dl, symbols); //printf("loading from %p\n", v.o); if (width(li, dl) == 1) { Val r = Val(*(bool*)v.o); SET(r); continue; } else if (width(li, dl) == 8) { Val r = Val(*(int64_t*)v.o); SET(r); continue; } else { li->dump(); RELEASE_ASSERT(0, ""); } } else if (llvm::StoreInst *si = llvm::dyn_cast<llvm::StoreInst>(it)) { llvm::Value *val = si->getOperand(0); llvm::Value *ptr = si->getOperand(1); Val v = fetch(val, dl, symbols); Val p = fetch(ptr, dl, symbols); //printf("storing %lx at %lx\n", v.n, p.n); if (width(val, dl) == 1) { *(bool*)p.o = v.b; continue; } else if (width(val, dl) == 8) { *(int64_t*)p.o = v.n; continue; } else { si->dump(); RELEASE_ASSERT(0, ""); } } else if (llvm::CmpInst *ci = llvm::dyn_cast<llvm::CmpInst>(it)) { assert(ci->getType() == g.i1); Val a0 = fetch(ci->getOperand(0), dl, symbols); Val a1 = fetch(ci->getOperand(1), dl, symbols); llvm::CmpInst::Predicate pred = ci->getPredicate(); switch (pred) { case llvm::CmpInst::ICMP_EQ: SET(a0.n == a1.n); continue; case llvm::CmpInst::ICMP_NE: SET(a0.n != a1.n); continue; case llvm::CmpInst::ICMP_SLT: SET(a0.n < a1.n); continue; case llvm::CmpInst::ICMP_SLE: SET(a0.n <= a1.n); continue; case llvm::CmpInst::ICMP_SGT: SET(a0.n > a1.n); continue; case llvm::CmpInst::ICMP_SGE: SET(a0.n >= a1.n); continue; case llvm::CmpInst::FCMP_OEQ: SET(a0.d == a1.d); continue; case llvm::CmpInst::FCMP_UNE: SET(a0.d != a1.d); continue; case llvm::CmpInst::FCMP_OLT: SET(a0.d < a1.d); continue; case llvm::CmpInst::FCMP_OLE: SET(a0.d <= a1.d); continue; case llvm::CmpInst::FCMP_OGT: SET(a0.d > a1.d); continue; case llvm::CmpInst::FCMP_OGE: SET(a0.d >= a1.d); continue; default: ci->dump(); RELEASE_ASSERT(0, ""); } continue; } else if (llvm::BinaryOperator *bo = llvm::dyn_cast<llvm::BinaryOperator>(it)) { if (bo->getOperand(0)->getType() == g.i64 || bo->getOperand(0)->getType() == g.i1) { //assert(bo->getOperand(0)->getType() == g.i64); //assert(bo->getOperand(1)->getType() == g.i64); Val a0 = fetch(bo->getOperand(0), dl, symbols); Val a1 = fetch(bo->getOperand(1), dl, symbols); llvm::Instruction::BinaryOps opcode = bo->getOpcode(); switch (opcode) { case llvm::Instruction::Add: SET(a0.n + a1.n); continue; case llvm::Instruction::And: SET(a0.n & a1.n); continue; case llvm::Instruction::AShr: SET(a0.n >> a1.n); continue; case llvm::Instruction::Mul: SET(a0.n * a1.n); continue; case llvm::Instruction::Or: SET(a0.n | a1.n); continue; case llvm::Instruction::Shl: SET(a0.n << a1.n); continue; case llvm::Instruction::Sub: SET(a0.n - a1.n); continue; case llvm::Instruction::Xor: SET(a0.n ^ a1.n); continue; default: bo->dump(); RELEASE_ASSERT(0, ""); } continue; } else if (bo->getOperand(0)->getType() == g.double_) { //assert(bo->getOperand(0)->getType() == g.i64); //assert(bo->getOperand(1)->getType() == g.i64); double lhs = fetch(bo->getOperand(0), dl, symbols).d; double rhs = fetch(bo->getOperand(1), dl, symbols).d; llvm::Instruction::BinaryOps opcode = bo->getOpcode(); switch (opcode) { case llvm::Instruction::FAdd: SET(lhs + rhs); continue; case llvm::Instruction::FMul: SET(lhs * rhs); continue; case llvm::Instruction::FSub: SET(lhs - rhs); continue; default: bo->dump(); RELEASE_ASSERT(0, ""); } continue; } else { bo->dump(); RELEASE_ASSERT(0, ""); } } else if (llvm::GetElementPtrInst *gep = llvm::dyn_cast<llvm::GetElementPtrInst>(it)) {
QValueList< ulong > NaughtyProcessMonitor::pidList() const { #ifdef __linux__ QStringList dl(QDir("/proc").entryList()); QValueList< ulong > pl; for(QStringList::ConstIterator it(dl.begin()); it != dl.end(); ++it) if(((*it)[0].isDigit())) pl << (*it).toUInt(); return pl; #elif defined(__OpenBSD__) int mib[3]; int nprocs = 0, nentries; size_t size; struct kinfo_proc *kp; int i; QValueList< ulong > l; // fetch number of processes mib[0] = CTL_KERN; mib[1] = KERN_NPROCS; if(-1 == sysctl(mib, 2, &nprocs, &size, NULL, 0)) return l; // magic size evaluation ripped from ps size = (5 * nprocs * sizeof(struct kinfo_proc)) / 4; kp = (struct kinfo_proc *)calloc(size, sizeof(char)); // fetch process info mib[0] = CTL_KERN; mib[1] = KERN_PROC; mib[2] = KERN_PROC_ALL; if(-1 == sysctl(mib, 3, kp, &size, NULL, 0)) { free(kp); return l; } nentries = size / sizeof(struct kinfo_proc); // time statistics and euid data are fetched only for processes in // the pidList, so, instead of doing one sysctl per process for // getLoad and canKill calls, simply cache the data we already have. d->cacheLoadMap_.clear(); d->uidMap_.clear(); for(i = 0; i < nentries; i++) { l << (unsigned long)kp[i].kp_proc.p_pid; d->cacheLoadMap_.insert(kp[i].kp_proc.p_pid, (kp[i].kp_proc.p_uticks + kp[i].kp_proc.p_sticks)); d->uidMap_.insert(kp[i].kp_proc.p_pid, kp[i].kp_eproc.e_ucred.cr_uid); } free(kp); return l; #else QValueList< ulong > l; return l; #endif }
int main(int argc, char** argv) { int ppw=20; // Point per wavelength std::string filename="ellipsecavitynormcond10.txt"; std::vector<double> freqs; freqs.push_back(9.9771201566136298); freqs.push_back(28.807002784875433); freqs.push_back(60.218097688523919); freqs.push_back(91.632551202864647); std::vector<double> norm_sl(freqs.size()); std::vector<double> norm_dl(freqs.size()); std::vector<double> norm_combined1(freqs.size()); std::vector<double> norm_combined2(freqs.size()); std::vector<double> cond_sl(freqs.size()); std::vector<double> cond_dl(freqs.size()); std::vector<double> cond_combined1(freqs.size()); std::vector<double> cond_combined2(freqs.size()); clock_t start, finish; double time; start=clock(); #ifdef BEM2DMPI MPI_Init(&argc, &argv); int nprow=4; // Number of rows in process grid int npcol=2; // Number of columns in process grid int mb=24; // Row Block size int nb=24; // Column Block size bem2d::BlacsSystem* b=bem2d::BlacsSystem::Initialize(nprow,npcol,mb,nb); // Exit if Context could not be created or process does not belong to context if (!b) { std::cout << "Could not create Blacs context" << std::endl; MPI_Finalize(); exit(1); } if ((b->get_myrow()==-1)&&(b->get_mycol()==-1)) { MPI_Finalize(); exit(0); } #endif for (int j=0;j<freqs.size();j++){ int n=10; double a= 1; double ah=1.3; double b=0.5; double bh=0.6; double t0=0.3*bem2d::PI; double t1=acos(-a/ah*cos(t0)); double alpha=bh*sin(t1)-b*sin(t0); //bem2d::freqtype k={n*bem2d::PI/2/b,0}; bem2d::freqtype k={freqs[j],0}; double eta1=k.re; // Coupling between conj. double and single layer pot. double eta2=cbrt(k.re*k.re); bem2d::Point p0(-a*cos(t0),b*sin(t0)); bem2d::Point p1(-a*cos(t0),alpha+b*sin(t0)); bem2d::Point p2(-a*cos(t0),-alpha-b*sin(t0)); bem2d::Point p3(-a*cos(t0),-b*sin(t0)); bem2d::pCurve cobj(new bem2d::Circle); bem2d::AnalyticCurve circle(n,cobj); int L=0; bem2d::pCurve Arc(new bem2d::EllipseArc(a,b,bem2d::PI-t0,-bem2d::PI+t0)); bem2d::AnalyticCurve ellipseArc(ppw,k,Arc,0,L); bem2d::pCurve Arc2(new bem2d::EllipseArc(ah,bh,-t1,t1)); bem2d::AnalyticCurve ellipseArc2(ppw,k,Arc2,0,L); bem2d::Line l0(p1,p0,ppw,k,L); bem2d::Line l1(p3,p2,ppw,k,L); std::vector<bem2d::pGeometry> geoms; geoms.push_back(ellipseArc2.GetGeometry()); geoms.push_back(l0.GetGeometry()); geoms.push_back(ellipseArc.GetGeometry()); geoms.push_back(l1.GetGeometry()); bem2d::pGeometry pgeom(new bem2d::Geometry(geoms)); bem2d::PolBasis::AddBasis(0,pgeom); // Add constant basis functions // Discretize the single and double layer potential bem2d::SingleLayer sl(k); bem2d::ConjDoubleLayer cdl(k); bem2d::DoubleLayer dl(k); bem2d::QuadOption quadopts; quadopts.L=5; quadopts.N=5; quadopts.sigma=0.15; #ifdef BEM2DMPI if (b->IsRoot()){ std::cout << "Discretize Kernels with n=" << pgeom->size() << std::endl; } #else std::cout << "Discretize Kernels with n=" << pgeom->size() << std::endl; #endif bem2d::Matrix dsl=*(DiscreteKernel(*pgeom,quadopts,sl)); bem2d::Matrix ddl=(*DiscreteKernel(*pgeom,quadopts,dl)); bem2d::Matrix dcdl=*(DiscreteKernel(*pgeom,quadopts,cdl)); bem2d::Matrix Id=*(EvalIdent(*pgeom, quadopts)); bem2d::Matrix combined1=Id+2.0*dcdl-bem2d::complex(0,2.0)*eta1*dsl; bem2d::Matrix combined2=Id+2.0*dcdl-bem2d::complex(0,2.0)*eta2*dsl; dsl=2.0*bem2d::ChangeBasis(dsl,Id); ddl=2.0*bem2d::ChangeBasis(ddl,Id); dcdl=2.0*bem2d::ChangeBasis(dcdl,Id); combined1=bem2d::ChangeBasis(combined1,Id); combined2=bem2d::ChangeBasis(combined2,Id); #ifdef BEM2DMPI if (b->IsRoot()){ std::cout << "Compute norms and condition numbers" << std::endl; } #else std::cout << "Compute norms and condition numbers" << std::endl; #endif bem2d::L2NormCond(dsl,norm_sl[j],cond_sl[j]); bem2d::L2NormCond(ddl,norm_dl[j],cond_dl[j]); bem2d::L2NormCond(combined1,norm_combined1[j],cond_combined1[j]); bem2d::L2NormCond(combined2,norm_combined2[j],cond_combined2[j]); //bem2d::WriteMatrix("cavity_matrix2", combined1); } finish=clock(); time=(double(finish)-double(start))/CLOCKS_PER_SEC/60; #ifdef BEM2DMPI if (b->IsRoot()){ #endif std::ofstream out(filename.c_str()); out << "Single Layer" << std::endl; for (int j=0;j<freqs.size();j++){ out << "k=" << freqs[j] << " Norm: " << norm_sl[j] << " Norm of Inverse: " << cond_sl[j]/norm_sl[j] << " Condition Nr.: " << cond_sl[j] << std::endl; } out << "Double Layer" << std::endl; for (int j=0;j<freqs.size();j++){ out << "k=" << freqs[j] << " Norm: " << norm_dl[j] << " Norm of Inverse: " << cond_dl[j]/norm_dl[j] << " Condition Nr.: " << cond_dl[j] << std::endl; } out << "Combined Layer eta=k" << std::endl; for (int j=0;j<freqs.size();j++){ out << "k=" << freqs[j] << " Norm: " << norm_combined1[j] << " Norm of Inverse: " << cond_combined1[j]/norm_combined1[j] << " Condition Nr.: " << cond_combined1[j] << std::endl; } out << "Combined Layer eta=k^(2/3)" << std::endl; for (int j=0;j<freqs.size();j++){ out << "k=" << freqs[j] << " Norm: " << norm_combined2[j] << " Norm of Inverse: " << cond_combined2[j]/norm_combined2[j] << " Condition Nr.: " << cond_combined2[j] << std::endl; } out << "Overalll time (minutes): " << time << std::endl; std::cout << "Overall time (minutes): " << time << std::endl; out.close(); #ifdef BEM2DMPI } #endif #ifdef BEM2DMPI bem2d::BlacsSystem::Release(); MPI_Finalize(); #endif }
void ProviderManagerMap::initialize() { String libExt = FileSystem::getDynamicLibraryExtension(); // first add the default: ProvMgrIfcInfo defaultPMEntry; defaultPMEntry.path.clear(); defaultPMEntry.ifcName = "C++Default"; defaultPMEntry.ifcVersions.append(String("2.1.0")); defaultPMEntry.ifcVersions.append(String("2.2.0")); defaultPMEntry.ifcVersions.append(String("2.3.0")); defaultPMEntry.ifcVersions.append(String("2.5.0")); defaultPMEntry.ifcVersions.append(String("2.6.0")); defaultPMEntry.ifcVersions.append(String("2.9.0")); _pmArray.append(defaultPMEntry); // now check for plugins String dirName = ConfigManager::getInstance()->getCurrentValue( "providerManagerDir"); dirName = ConfigManager::getHomedPath(dirName); PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL3, "Looking for ProviderManagers in %s.", (const char*)dirName.getCString())); // check to make sure that this ifc type is handled by one of the // provider managers in the directory String testname = String("providermanager")+libExt; for (Dir dir(dirName); dir.more(); dir.next()) { String filename = dir.getName(); String lowerFilename = filename; lowerFilename.toLower(); if ((lowerFilename.subString(lowerFilename.size()-testname.size()) == testname) && (lowerFilename != FileSystem::buildLibraryFileName("defaultprovidermanager")) && (lowerFilename != FileSystem::buildLibraryFileName("pegprovidermanager"))) { String fullPath = dirName + "/" + filename; // found a file... assume it's a ProviderManager library PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Found file %s. Checking to see if it is a ProviderManager.", (const char*)fullPath.getCString())); DynamicLibrary dl(fullPath); if (!dl.load()) { Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, MessageLoaderParms( "Server.ProviderRegistrationManager.ProviderManagerMap." "LOAD_ERROR", "Error loading library $0: $1.", fullPath, dl.getLoadErrorMessage())); continue; // to the next file } Uint32 (*get_peg_ver)() = (Uint32(*)()) dl.getSymbol("getPegasusVersion"); if (get_peg_ver == 0) { Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, MessageLoaderParms( "Server.ProviderRegistrationManager.ProviderManagerMap." "MISSING_GET_PG_VERSION", "Library $0 does not contain expected function " "'getPegasusVersion'.", fullPath)); continue; } Uint32 peg_ver = get_peg_ver(); if (peg_ver != PEGASUS_VERSION_NUMBER) { Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, MessageLoaderParms( "Server.ProviderRegistrationManager.ProviderManagerMap." "WRONG_VERSION", "Provider Manager $0 returned Pegasus " "version $1. Expected $2.", fullPath, peg_ver, PEGASUS_VERSION_NUMBER)); continue; } const char** (*get_ifc)() = (const char**(*)()) dl.getSymbol( "getProviderManagerInterfaceNames"); const char** (*get_ver)(const char *) = (const char**(*)(const char *)) dl.getSymbol( "getProviderManagerInterfaceVersions"); if (get_ifc == 0) { Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, MessageLoaderParms( "Server.ProviderRegistrationManager.ProviderManagerMap." "MISSING_GET_IFC_NAMES", "Provider Manager $0 does not contain expected " "function 'getProviderManagerInterfaceNames'", fullPath)); continue; // to the next file } if (get_ver == 0) { Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, MessageLoaderParms( "Server.ProviderRegistrationManager.ProviderManagerMap." "MISSING_GET_IFC_VERSIONS", "Provider Manager $0 does not contain expected " "function 'getProviderManagerInterfaceVersions'", fullPath)); continue; // to the next file } const char ** ifcNames = get_ifc(); if ((ifcNames!=NULL) && (*ifcNames!=NULL)) { for (int i=0; ifcNames[i]!=NULL; i++) { const char *ifcName = ifcNames[i]; ProvMgrIfcInfo entry; entry.path = fullPath; entry.ifcName = ifcName; // now get the versions const char ** ifcVersions = get_ver(ifcName); for (int j=0; ifcVersions[j]!=NULL; j++) { entry.ifcVersions.append(String(ifcVersions[j])); PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL3, "Adding Provider type %s version %s " "handled by ProviderManager %s", ifcName,ifcVersions[j], (const char*)fullPath.getCString())); } _pmArray.append(entry); } } } } _bInitialized = true; }
bool AVRDAGToDAGISel::SelectInlineAsmMemoryOperand(const SDValue &Op, unsigned ConstraintCode, std::vector<SDValue> &OutOps) { // Yes hardcoded 'm' symbol. Just because it also has been hardcoded in // SelectionDAGISel (callee for this method). assert(ConstraintCode == InlineAsm::Constraint_m || ConstraintCode == InlineAsm::Constraint_Q && "Unexpected asm memory constraint"); MachineRegisterInfo &RI = MF->getRegInfo(); const AVRSubtarget &STI = MF->getSubtarget<AVRSubtarget>(); const TargetLowering &TL = *STI.getTargetLowering(); SDLoc dl(Op); auto DL = CurDAG->getDataLayout(); const RegisterSDNode *RegNode = dyn_cast<RegisterSDNode>(Op); // If address operand is of PTRDISPREGS class, all is OK, then. if (RegNode && RI.getRegClass(RegNode->getReg()) == &AVR::PTRDISPREGSRegClass) { OutOps.push_back(Op); return false; } if (Op->getOpcode() == ISD::FrameIndex) { SDValue Base, Disp; if (SelectAddr(Op.getNode(), Op, Base, Disp)) { OutOps.push_back(Base); OutOps.push_back(Disp); return false; } return true; } // If Op is add 'register, immediate' and // register is either virtual register or register of PTRDISPREGSRegClass if (Op->getOpcode() == ISD::ADD || Op->getOpcode() == ISD::SUB) { SDValue CopyFromRegOp = Op->getOperand(0); SDValue ImmOp = Op->getOperand(1); ConstantSDNode *ImmNode = dyn_cast<ConstantSDNode>(ImmOp); unsigned Reg; bool CanHandleRegImmOpt = true; CanHandleRegImmOpt &= ImmNode != 0; CanHandleRegImmOpt &= ImmNode->getAPIntValue().getZExtValue() < 64; if (CopyFromRegOp->getOpcode() == ISD::CopyFromReg) { RegisterSDNode *RegNode = cast<RegisterSDNode>(CopyFromRegOp->getOperand(1)); Reg = RegNode->getReg(); CanHandleRegImmOpt &= (TargetRegisterInfo::isVirtualRegister(Reg) || AVR::PTRDISPREGSRegClass.contains(Reg)); } else { CanHandleRegImmOpt = false; } // If we detect proper case - correct virtual register class // if needed and go to another inlineasm operand. if (CanHandleRegImmOpt) { SDValue Base, Disp; if (RI.getRegClass(Reg) != &AVR::PTRDISPREGSRegClass) { SDLoc dl(CopyFromRegOp); unsigned VReg = RI.createVirtualRegister(&AVR::PTRDISPREGSRegClass); SDValue CopyToReg = CurDAG->getCopyToReg(CopyFromRegOp, dl, VReg, CopyFromRegOp); SDValue NewCopyFromRegOp = CurDAG->getCopyFromReg(CopyToReg, dl, VReg, TL.getPointerTy(DL)); Base = NewCopyFromRegOp; } else { Base = CopyFromRegOp; } if (ImmNode->getValueType(0) != MVT::i8) { Disp = CurDAG->getTargetConstant(ImmNode->getAPIntValue().getZExtValue(), dl, MVT::i8); } else { Disp = ImmOp; } OutOps.push_back(Base); OutOps.push_back(Disp); return false; } } // More generic case. // Create chain that puts Op into pointer register // and return that register. unsigned VReg = RI.createVirtualRegister(&AVR::PTRDISPREGSRegClass); SDValue CopyToReg = CurDAG->getCopyToReg(Op, dl, VReg, Op); SDValue CopyFromReg = CurDAG->getCopyFromReg(CopyToReg, dl, VReg, TL.getPointerTy(DL)); OutOps.push_back(CopyFromReg); return false; }
bool CSdp::download() { if (downloaded) //allow download only once of the same sdp return true; filename=fileSystem->getSpringDir() + PATH_DELIMITER+"packages"+PATH_DELIMITER; DEBUG_LINE("%s\n",filename.c_str()); if (!fileSystem->directoryExists(filename)) { fileSystem->createSubdirs(filename); } int count=0; filename += this->md5 + ".sdp"; CFileSystem::FileData tmp; md5AtoI(md5,tmp.md5); std::list<CFileSystem::FileData> files; if (!fileSystem->parseSdp(filename,files)) { //file isn't avaiable, download it IDownload dl(filename); dl.addMirror(url + "/packages/" + md5 + ".sdp"); httpDownload->download(dl); fileSystem->parseSdp(filename,files); //parse downloaded file } std::list<CFileSystem::FileData>::iterator it; /* CHttpDownload* tmp=httpDownload; //FIXME: extend interface? tmp->setCount(files.size()); */ int i=0; it=files.begin(); while (it!=files.end()) { i++; std::string tmpmd5=""; md5ItoA((*it).md5, tmpmd5); std::string filename=tmpmd5.substr(2); filename.append(".gz"); std::string path("/pool/"); path += tmpmd5.at(0); path += tmpmd5.at(1); path += "/"; std::string file=fileSystem->getSpringDir() + path + filename; //absolute filename if (!fileSystem->directoryExists(fileSystem->getSpringDir()+path)) { fileSystem->createSubdirs(fileSystem->getSpringDir()+path); } if (!fileSystem->fileExists(file)) { //add non-existing files to download list count++; (*it).download=true; } else { (*it).download=false; } if (i%10==0) DEBUG_LINE("\r%d/%d checked",i,(int)files.size()); it++; } DEBUG_LINE("\r%d/%d need to download %d files\n",i,(unsigned int)files.size(),count); if (count>0) { //FIXME httpDownload->setCount(count); downloaded=downloadStream(this->url+"/streamer.cgi?"+this->md5,files); files.clear(); DEBUG_LINE("Sucessfully downloaded %d files: %s %s\n",count,shortname.c_str(),name.c_str()); } else { DEBUG_LINE("Already downloaded: %s\n", shortname.c_str()); downloaded=true; } return downloaded; }
int main(int argc, char** argv) { int ppw=10; // Point per wavelength std::string filename="kitenormcond10.txt"; std::vector<double> freqs; freqs.push_back(5); freqs.push_back(10); freqs.push_back(20); freqs.push_back(40); freqs.push_back(80); freqs.push_back(160); freqs.push_back(320); freqs.push_back(640); std::vector<double> norm_sl(freqs.size()); std::vector<double> norm_dl(freqs.size()); std::vector<double> norm_combined1(freqs.size()); std::vector<double> norm_combined2(freqs.size()); std::vector<double> cond_sl(freqs.size()); std::vector<double> cond_dl(freqs.size()); std::vector<double> cond_combined1(freqs.size()); std::vector<double> cond_combined2(freqs.size()); clock_t start, finish; double time; start=clock(); #ifdef BEM2DMPI MPI_Init(&argc, &argv); int nprow=4; // Number of rows in process grid int npcol=2; // Number of columns in process grid int mb=24; // Row Block size int nb=24; // Column Block size bem2d::BlacsSystem* b=bem2d::BlacsSystem::Initialize(nprow,npcol,mb,nb); // Exit if Context could not be created or process does not belong to context if (!b) { std::cout << "Could not create Blacs context" << std::endl; MPI_Finalize(); exit(1); } if ((b->get_myrow()==-1)&&(b->get_mycol()==-1)) { MPI_Finalize(); exit(0); } #endif for (int j=0; j<freqs.size(); j++) { bem2d::freqtype k= {(double)freqs[j],0}; double eta1=k.re; // Coupling between conj. double and single layer pot. double eta2=cbrt(k.re*k.re); bem2d::pCurve kobj(new bem2d::Kite); int n=(int)(kobj->Length()*k.re*ppw/2.0/bem2d::PI); bem2d::AnalyticCurve kite(n,kobj); bem2d::pGeometry pgeom=kite.GetGeometry(); bem2d::PolBasis::AddBasis(0,pgeom); // Add constant basis functions // Discretize the single and double layer potential bem2d::SingleLayer sl(k); bem2d::ConjDoubleLayer cdl(k); bem2d::DoubleLayer dl(k); bem2d::QuadOption quadopts; quadopts.L=3; quadopts.N=5; quadopts.sigma=0.15; #ifdef BEM2DMPI if (b->IsRoot()) { std::cout << "Discretize Kernels with n=" << n << std::endl; } #else std::cout << "Discretize Kernels with n=" << n << std::endl; #endif bem2d::Matrix dsl=*(DiscreteKernel(*pgeom,quadopts,sl)); bem2d::Matrix ddl=(*DiscreteKernel(*pgeom,quadopts,dl)); bem2d::Matrix dcdl=*(DiscreteKernel(*pgeom,quadopts,cdl)); bem2d::Matrix Id=*(EvalIdent(*pgeom, quadopts)); bem2d::Matrix combined1=Id+2.0*dcdl-bem2d::complex(0,2.0)*eta1*dsl; bem2d::Matrix combined2=Id+2.0*dcdl-bem2d::complex(0,2.0)*eta2*dsl; dsl=2.0*bem2d::ChangeBasis(dsl,Id); ddl=2.0*bem2d::ChangeBasis(ddl,Id); dcdl=2.0*bem2d::ChangeBasis(dcdl,Id); combined1=bem2d::ChangeBasis(combined1,Id); combined2=bem2d::ChangeBasis(combined2,Id); #ifdef BEM2DMPI if (b->IsRoot()) { std::cout << "Compute norms and condition numbers" << std::endl; } #else std::cout << "Compute norms and condition numbers" << std::endl; #endif bem2d::L2NormCond(dsl,norm_sl[j],cond_sl[j]); bem2d::L2NormCond(ddl,norm_dl[j],cond_dl[j]); bem2d::L2NormCond(combined1,norm_combined1[j],cond_combined1[j]); bem2d::L2NormCond(combined2,norm_combined2[j],cond_combined2[j]); } finish=clock(); time=(double(finish)-double(start))/CLOCKS_PER_SEC/60; #ifdef BEM2DMPI if (b->IsRoot()) { #endif std::ofstream out(filename.c_str()); out << "Single Layer" << std::endl; for (int j=0; j<freqs.size(); j++) { out << "k=" << freqs[j] << " Norm: " << norm_sl[j] << " Norm of Inverse: " << cond_sl[j]/norm_sl[j] << " Condition Nr.: " << cond_sl[j] << std::endl; } out << "Double Layer" << std::endl; for (int j=0; j<freqs.size(); j++) { out << "k=" << freqs[j] << " Norm: " << norm_dl[j] << " Norm of Inverse: " << cond_dl[j]/norm_dl[j] << " Condition Nr.: " << cond_dl[j] << std::endl; } out << "Combined Layer eta=k" << std::endl; for (int j=0; j<freqs.size(); j++) { out << "k=" << freqs[j] << " Norm: " << norm_combined1[j] << " Norm of Inverse: " << cond_combined1[j]/norm_combined1[j] << " Condition Nr.: " << cond_combined1[j] << std::endl; } out << "Combined Layer eta=k^(2/3)" << std::endl; for (int j=0; j<freqs.size(); j++) { out << "k=" << freqs[j] << " Norm: " << norm_combined2[j] << " Norm of Inverse: " << cond_combined2[j]/norm_combined2[j] << " Condition Nr.: " << cond_combined2[j] << std::endl; } out << "Overalll time (minutes): " << time << std::endl; std::cout << "Overall time (minutes): " << time << std::endl; out.close(); #ifdef BEM2DMPI } #endif #ifdef BEM2DMPI bem2d::BlacsSystem::Release(); MPI_Finalize(); #endif }
bool CSdp::download() { if (downloaded) //allow download only once of the same sdp return true; filename=fileSystem->getSpringDir() + PATH_DELIMITER+"packages"+PATH_DELIMITER; LOG_DEBUG("%s",filename.c_str()); if (!fileSystem->directoryExists(filename)) { fileSystem->createSubdirs(filename); } int count=0; filename += this->md5 + ".sdp"; const std::string tmpFile = filename + ".tmp"; std::list<FileData*> files; bool rename = false; if (!fileSystem->fileExists(filename)) { //.sdp isn't avaiable, download it IDownload dl(tmpFile); dl.addMirror(url + "/packages/" + this->md5 + ".sdp"); httpDownload->download(&dl); fileSystem->parseSdp(tmpFile,files); //parse downloaded file rename = true; } else { fileSystem->parseSdp(filename,files); //parse downloaded file } std::list<FileData*>::iterator it; HashMD5 md5= HashMD5(); FileData tmp=FileData(); int i=0; for(it = files.begin(); it!=files.end(); ++it) { //check which file are available on local disk -> create list of files to download i++; md5.Set((*it)->md5, sizeof((*it)->md5)); std::string file; fileSystem->getPoolFilename(md5.toString(), file); if (!fileSystem->fileExists(file)) { //add non-existing files to download list count++; (*it)->download=true; } else { (*it)->download=false; } if (i%10==0) { LOG_DEBUG("\r%d/%d checked",i,(int)files.size()); } } LOG_DEBUG("\r%d/%d need to download %d files",i,(unsigned int)files.size(),count); std::string root = fileSystem->getSpringDir(); root += PATH_DELIMITER; root += "pool"; root += PATH_DELIMITER; if (!createPoolDirs(root)) { LOG_ERROR("Creating pool directories failed"); count = 0; } if (count>0) { downloaded=downloadStream(this->url+"/streamer.cgi?"+this->md5,files); LOG_DEBUG("Sucessfully downloaded %d files: %s %s",count,shortname.c_str(),name.c_str()); } else { LOG_DEBUG("Already downloaded: %s", shortname.c_str()); downloaded=true; } for(it = files.begin(); it!=files.end(); ++it) { //free memory delete *it; } if ((rename) && (!fileSystem->Rename(tmpFile, filename))) { LOG_ERROR("Couldn't rename %s to %s", tmpFile.c_str(), filename.c_str()); } return downloaded; }
void netdev_install (void) { uae_u32 functable, datatable; uae_u32 initcode, openfunc, closefunc, expungefunc; uae_u32 beginiofunc, abortiofunc; if (!currprefs.sana2) return; if (log_net) write_log (_T("netdev_install(): 0x%x\n"), here ()); ethernet_enumerate_free (); ethernet_enumerate (td, NULL); ROM_netdev_resname = ds (getdevname()); ROM_netdev_resid = ds (_T("UAE net.device 0.2")); timerdevname = ds (_T("timer.device")); /* initcode */ initcode = here (); calltrap (deftrap2 (dev_init, TRAPFLAG_EXTRA_STACK, _T("uaenet.init"))); dw (RTS); /* Open */ openfunc = here (); calltrap (deftrap2 (dev_open, TRAPFLAG_EXTRA_STACK, _T("uaenet.open"))); dw (RTS); /* Close */ closefunc = here (); calltrap (deftrap2 (dev_close, TRAPFLAG_EXTRA_STACK, _T("uaenet.close"))); dw (RTS); /* Expunge */ expungefunc = here (); calltrap (deftrap2 (dev_expunge, TRAPFLAG_EXTRA_STACK, _T("uaenet.expunge"))); dw (RTS); /* BeginIO */ beginiofunc = here (); calltrap (deftrap2 (dev_beginio, TRAPFLAG_EXTRA_STACK, _T("uaenet.beginio"))); dw (RTS); /* AbortIO */ abortiofunc = here (); calltrap (deftrap2 (dev_abortio, TRAPFLAG_EXTRA_STACK, _T("uaenet.abortio"))); dw (RTS); /* FuncTable */ functable = here (); dl (openfunc); /* Open */ dl (closefunc); /* Close */ dl (expungefunc); /* Expunge */ dl (EXPANSION_nullfunc); /* Null */ dl (beginiofunc); /* BeginIO */ dl (abortiofunc); /* AbortIO */ dl (0xFFFFFFFFul); /* end of table */ /* DataTable */ datatable = here (); dw (0xE000); /* INITBYTE */ dw (0x0008); /* LN_TYPE */ dw (0x0300); /* NT_DEVICE */ dw (0xC000); /* INITLONG */ dw (0x000A); /* LN_NAME */ dl (ROM_netdev_resname); dw (0xE000); /* INITBYTE */ dw (0x000E); /* LIB_FLAGS */ dw (0x0600); /* LIBF_SUMUSED | LIBF_CHANGED */ dw (0xD000); /* INITWORD */ dw (0x0014); /* LIB_VERSION */ dw (0x0004); /* 0.4 */ dw (0xD000); /* INITWORD */ dw (0x0016); /* LIB_REVISION */ dw (0x0000); /* end of table already ??? */ dw (0xC000); /* INITLONG */ dw (0x0018); /* LIB_IDSTRING */ dl (ROM_netdev_resid); dw (0x0000); /* end of table */ ROM_netdev_init = here (); dl (0x00000100); /* size of device base */ dl (functable); dl (datatable); dl (initcode); nscmd_cmd = here (); dw (CMD_READ); dw (CMD_WRITE); dw (CMD_FLUSH); dw (S2_DEVICEQUERY); dw (S2_GETSTATIONADDRESS); dw (S2_CONFIGINTERFACE); dw (S2_ADDMULTICASTADDRESS); dw (S2_DELMULTICASTADDRESS); dw (S2_MULTICAST); dw (S2_BROADCAST); dw (S2_TRACKTYPE); dw (S2_UNTRACKTYPE); dw (S2_GETTYPESTATS); dw (S2_GETSPECIALSTATS); dw (S2_GETGLOBALSTATS); dw (S2_ONEVENT); dw (S2_READORPHAN); dw (S2_ONLINE); dw (S2_OFFLINE); dw (S2_ADDMULTICASTADDRESSES); dw (S2_DELMULTICASTADDRESSES); dw (NSCMD_DEVICEQUERY); dw (0); }
int main (int argc, char ** argv) { if(argc <= 2){ throw std::runtime_error("No parameters given. Usage: " + usage(argv[0])); } //Parse all parameters std::map<std::string, std::string> parameter_name_value_map; bool parse_succeeded = Utils::parseParamters(argc, argv, parameter_name_value_map); if(!parse_succeeded){ throw std::runtime_error("Mangled command line arguments. " + usage(argv[0])); } //check if we found a config file. if(parameter_name_value_map.count("conf") == 0){ throw std::runtime_error("No config file was given" + usage(argv[0])); } std::string config_file = parameter_name_value_map["conf"]; parameter_name_value_map.erase("conf"); Utils::Config conf(config_file, parameter_name_value_map); Utils::RgbLabelConversion label_converter(conf.getJsonValueAsString(conf.get<std::string>("color_coding_key"))); Utils::DataLoader dl(conf); libf::DataStorage::ptr d = dl.loadAllTrainingData("train_images", conf.get<bool>("vccs_rectification")); std::map<int,int> dist; for(int a = 0; a < d->getSize(); a++){ dist[d->getClassLabel(a)]++; } for(auto b : dist){ std::cout <<b.first << " "<< b.second << std::endl; } std::cout << d->getSize() << std::endl; libf::RandomForestLearner<libf::DecisionTreeLearner> forestLearner; forestLearner.getTreeLearner().setNumFeatures(ceil(sqrt(d->getDimensionality()))); forestLearner.getTreeLearner().setMinSplitExamples(conf.get<int>("min_split_samples")); forestLearner.getTreeLearner().setNumBootstrapExamples(d->getSize()); forestLearner.getTreeLearner().setUseBootstrap(true); //forestLearner.getTreeLearner().setUseClassFrequencies(true); forestLearner.getTreeLearner().setMaxDepth(conf.get<int>("max_depth")); forestLearner.setNumTrees(conf.get<int>("number_trees")); forestLearner.setNumThreads(8); auto state = forestLearner.createState(); libf::ConsoleGUI<decltype(state)> gui(state); auto forest = forestLearner.learn(d, state); std::filebuf fb; if (fb.open (conf.getPath("model_path"),std::ios::out)){ std::ostream os(&fb); forest->write(os); } fb.close(); gui.join(); return 0; }
void scsidev_install (void) { uae_u32 functable, datatable; uae_u32 initcode, openfunc, closefunc, expungefunc; uae_u32 beginiofunc, abortiofunc; if (!currprefs.scsi) return; if (log_scsi) write_log ("scsidev_install(): 0x%x\n", here ()); ROM_scsidev_resname = ds (UAEDEV_SCSI); ROM_scsidev_resid = ds ("UAE scsi.device 0.2"); /* initcode */ initcode = here (); calltrap (deftrap (dev_init)); dw (RTS); /* Open */ openfunc = here (); calltrap (deftrap (dev_open)); dw (RTS); /* Close */ closefunc = here (); calltrap (deftrap (dev_close)); dw (RTS); /* Expunge */ expungefunc = here (); calltrap (deftrap (dev_expunge)); dw (RTS); /* BeginIO */ beginiofunc = here (); calltrap (deftrap (dev_beginio)); dw (RTS); /* AbortIO */ abortiofunc = here (); calltrap (deftrap (dev_abortio)); dw (RTS); /* FuncTable */ functable = here (); dl (openfunc); /* Open */ dl (closefunc); /* Close */ dl (expungefunc); /* Expunge */ dl (EXPANSION_nullfunc); /* Null */ dl (beginiofunc); /* BeginIO */ dl (abortiofunc); /* AbortIO */ dl (0xFFFFFFFFul); /* end of table */ /* DataTable */ datatable = here (); dw (0xE000); /* INITBYTE */ dw (0x0008); /* LN_TYPE */ dw (0x0300); /* NT_DEVICE */ dw (0xC000); /* INITLONG */ dw (0x000A); /* LN_NAME */ dl (ROM_scsidev_resname); dw (0xE000); /* INITBYTE */ dw (0x000E); /* LIB_FLAGS */ dw (0x0600); /* LIBF_SUMUSED | LIBF_CHANGED */ dw (0xD000); /* INITWORD */ dw (0x0014); /* LIB_VERSION */ dw (0x0004); /* 0.4 */ dw (0xD000); /* INITWORD */ dw (0x0016); /* LIB_REVISION */ dw (0x0000); /* end of table already ??? */ dw (0xC000); /* INITLONG */ dw (0x0018); /* LIB_IDSTRING */ dl (ROM_scsidev_resid); dw (0x0000); /* end of table */ ROM_scsidev_init = here (); dl (0x00000100); /* size of device base */ dl (functable); dl (datatable); dl (initcode); diskdev_install (); }
bool ChatPanel::Say(const wxString& message) { static const unsigned int flood_threshold = 5; slLogDebugFunc(""); wxStringTokenizer lines(message, _T('\n')); if (lines.CountTokens() > flood_threshold) { PasteDialog dl(this, wxString::Format(_("Are you sure you want to paste %d lines?"), lines.CountTokens())); switch (dl.ShowModal()) { case wxID_NO: return true; case PasteDialog::pasteButtonReturnCode: { wxString url = Paste2Pastebin(message); if (url != wxEmptyString && wxStringTokenizer(url, _T('\n')).CountTokens() <= flood_threshold) { Say(url); return true; } else { customMessageBoxNoModal(SL_MAIN_ICON, _("Failed to post to pastebin.com.")); return false; } } default: break; } } while (lines.HasMoreTokens()) { wxString line = lines.GetNextToken(); wxLogMessage(_T( "line: %s" ), line.c_str()); if (line.Find('/') == 0) { if (ui().ExecuteSayCommand(line)) return true; } if (line == _T( "/ver" )) { //!this instance is not replaced with GetAppname for sake of help/debug online OutputLine(_(" You have SpringLobby v") + TowxString(getSpringlobbyVersion()), sett().GetChatColorNormal()); return true; } if (line == _T( "/clear" )) { m_chatlog_text->SetValue(wxEmptyString); return true; } if (m_type == CPT_Channel) { if (m_channel == 0) { OutputError(_("You are not in channel or channel does not exist.")); return true; } if (line.StartsWith(_T( "/" ))) { if (m_channel->ExecuteSayCommand(STD_STRING(line))) return true; if (m_channel->GetServer().ExecuteSayCommand(STD_STRING(line))) return true; OutputError(wxString::Format(_("Command (%s) does not exist, use /help for a list of available commands."), line.c_str())); return true; } m_channel->Say(STD_STRING(line)); } else if (m_type == CPT_Battle) { if (m_battle == 0) { OutputError(_("You are not in battle or battle does not exist, use /help for a list of available commands.")); return true; } if (line.StartsWith(_T( "/" ))) { if (m_battle->ExecuteSayCommand(STD_STRING(line))) return true; if (m_battle->GetServer().ExecuteSayCommand(STD_STRING(line))) return true; OutputError(wxString::Format(_("Command (%s) does not exist, use /help for a list of available commands."), line.c_str())); return true; } m_battle->Say(STD_STRING(line)); } else if (m_type == CPT_User) { if (m_user == 0) { OutputError(_(" User is offline.")); return true; } if (line.StartsWith(_T( "/" ))) { if (m_user->ExecuteSayCommand(STD_STRING(line))) return true; if (m_user->GetServer().ExecuteSayCommand(STD_STRING(line))) return true; OutputError(wxString::Format(_("Command (%s) does not exist, use /help for a list of available commands."), line.c_str())); return true; } m_user->Say(STD_STRING(line)); } else if (m_type == CPT_Server) { if (m_server == 0) { OutputError(_("Not connected to server")); return true; } if (line.StartsWith(_T( "/" ))) { if (m_server->ExecuteSayCommand(STD_STRING(line))) return true; OutputError(wxString::Format(_("Command (%s) does not exist, use /help for a list of available commands."), line.c_str())); return true; } //we need to disable the channel tab if leaving manually if (line.Upper().StartsWith(_T( "LEAVE" ))) { wxString channame = line.AfterFirst(' ').BeforeFirst(' '); try { Channel& chan = m_server->GetChannel(STD_STRING(channame)); chan.Leave(); chan.uidata.panel = 0; } catch (assert_exception) { } } m_server->SendCmd(STD_STRING(line), ""); OutputLine(_(" Sent: \"") + line + _("\""), sett().GetChatColorNormal()); } } return true; }
int tst_insdel(MENU_ARGS) { /* Test of: SM/RM(4) (= IRM (Insertion/replacement mode)) ICH (Insert Character) DCH (Delete character) IL (Insert line) DL (Delete line) */ int i, row, col, sw, dblchr, scr132; for (scr132 = 0; scr132 <= 1; scr132++) { if (scr132) { deccolm(TRUE); sw = max_cols; } else { deccolm(FALSE); sw = min_cols; } ed(2); cup(1, 1); for (row = 1; row <= max_lines; row++) { cup(row, 1); for (col = 1; col <= sw; col++) printf("%c", 'A' - 1 + row); } cup(4, 1); printf("Screen accordion test (Insert & Delete Line). "); holdit(); ri(); el(2); decstbm(2, max_lines - 1); decom(TRUE); cup(1, 1); for (row = 1; row <= max_lines; row++) { il(row); dl(row); } decom(FALSE); decstbm(0, 0); cup(2, 1); printf("Top line: A's, bottom line: %c's, this line, nothing more. ", 'A' - 1 + max_lines); holdit(); cup(2, 1); ed(0); cup(1, 2); printf("B"); cub(1); sm("4"); for (col = 2; col <= sw - 1; col++) printf("*"); rm("4"); cup(4, 1); printf("Test of 'Insert Mode'. The top line should be 'A*** ... ***B'. "); holdit(); ri(); el(2); cup(1, 2); dch(sw - 2); cup(4, 1); printf("Test of 'Delete Character'. The top line should be 'AB'. "); holdit(); for (dblchr = 1; dblchr <= 2; dblchr++) { ed(2); for (row = 1; row <= max_lines; row++) { cup(row, 1); if (dblchr == 2) decdwl(); for (col = 1; col <= sw / dblchr; col++) printf("%c", 'A' - 1 + row); cup(row, sw / dblchr - row); dch(row); } cup(4, 1); println("The right column should be staggered "); printf("by one. "); holdit(); } ed(2); cup(1, 1); println("If your terminal has the ANSI 'Insert Character' function"); println("(the VT102 does not), then you should see a line like this"); println(" A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"); println("below:"); println(""); for (i = 'Z'; i >= 'A'; i--) { printf("%c%c", i, BS); ich(2); } cup(10, 1); holdit(); if (sw == max_cols) deccolm(FALSE); } return MENU_NOHOLD; }
void checkValid( int nKeys ) const { ASSERT( bt() ); ASSERT( bt()->isHead() ); bt()->assertValid( order(), true ); ASSERT_EQUALS( nKeys, bt()->fullValidate( dl(), order() ) ); }
void hardfile_install (void) { uae_u32 functable, datatable; uae_u32 initcode, openfunc, closefunc, expungefunc; uae_u32 beginiofunc, abortiofunc; ROM_hardfile_resname = ds ("uaehf.device"); ROM_hardfile_resid = ds ("UAE hardfile.device 0.2"); /* initcode */ initcode = filesys_initcode; /* Open */ openfunc = here (); calltrap (deftrap (hardfile_open)); dw (RTS); /* Close */ closefunc = here (); calltrap (deftrap (hardfile_close)); dw (RTS); /* Expunge */ expungefunc = here (); calltrap (deftrap (hardfile_expunge)); dw (RTS); /* BeginIO */ beginiofunc = here (); calltrap (deftrap (hardfile_beginio)); dw (0x48E7); dw (0x8002); /* movem.l d0/a6,-(a7) */ dw (0x0829); dw (0); dw (30); /* btst #0,30(a1) */ dw (0x6608); /* bne.b +8 */ dw (0x2C78); dw (0x0004); /* move.l 4,a6 */ dw (0x4EAE); dw (-378); /* jsr ReplyMsg(a6) */ dw (0x4CDF); dw (0x4001); /* movem.l (a7)+,d0/a6 */ dw (RTS); /* AbortIO */ abortiofunc = here (); calltrap (deftrap (hardfile_abortio)); dw (RTS); /* FuncTable */ functable = here (); dl (openfunc); /* Open */ dl (closefunc); /* Close */ dl (expungefunc); /* Expunge */ dl (EXPANSION_nullfunc); /* Null */ dl (beginiofunc); /* BeginIO */ dl (abortiofunc); /* AbortIO */ dl (0xFFFFFFFFul); /* end of table */ /* DataTable */ datatable = here (); dw (0xE000); /* INITBYTE */ dw (0x0008); /* LN_TYPE */ dw (0x0300); /* NT_DEVICE */ dw (0xC000); /* INITLONG */ dw (0x000A); /* LN_NAME */ dl (ROM_hardfile_resname); dw (0xE000); /* INITBYTE */ dw (0x000E); /* LIB_FLAGS */ dw (0x0600); /* LIBF_SUMUSED | LIBF_CHANGED */ dw (0xD000); /* INITWORD */ dw (0x0014); /* LIB_VERSION */ dw (0x0004); /* 0.4 */ dw (0xD000); dw (0x0016); /* LIB_REVISION */ dw (0x0000); dw (0xC000); dw (0x0018); /* LIB_IDSTRING */ dl (ROM_hardfile_resid); dw (0x0000); /* end of table */ ROM_hardfile_init = here (); dl (0x00000100); /* ??? */ dl (functable); dl (datatable); dl (initcode); }
void insert( BSONObj &key ) { bt()->bt_insert( dl(), recordLoc(), key, order(), true, id(), true ); }
bool ChatPanel::Say(const wxString& message) //FIXME: remove all parsing / tokenizing / ... to dedicated file { static const unsigned int flood_threshold = 5; slLogDebugFunc(""); wxStringTokenizer lines(message, _T('\n')); if (lines.CountTokens() > flood_threshold) { PasteDialog dl(this, wxString::Format(_("Are you sure you want to paste %d lines?"), lines.CountTokens())); switch (dl.ShowModal()) { case wxID_NO: return true; case PasteDialog::pasteButtonReturnCode: { wxString url = Paste2Pastebin(message); if (url != wxEmptyString && wxStringTokenizer(url, _T('\n')).CountTokens() <= flood_threshold) { Say(url); return true; } else { customMessageBoxModal(SL_MAIN_ICON, wxString::Format(_("Failed to post to %s"), _T("paste.springfiles.com"))); return false; } } default: break; } } while (lines.HasMoreTokens()) { wxString line = lines.GetNextToken(); wxLogDebug(_T( "line: %s" ), line.c_str()); if (line == "/help") { ui().ConsoleHelp(); return true; } if (line == "/channels") { ui().mw().ShowChannelChooser(); return true; } if (line == _T( "/ver" )) { //!this instance is not replaced with GetAppname for sake of help/debug online OutputLine(wxString::Format(_("You have %s."), GetSpringlobbyAgent()), sett().GetChatColorNormal()); return true; } if (line == _T( "/clear" )) { m_chatlog_text->SetValue(wxEmptyString); return true; } if (m_type == CPT_Channel) { if (m_channel == 0) { OutputError(_("You are not in channel or channel does not exist.")); return true; } if (line.StartsWith(_T( "/" ))) { if (m_channel->ExecuteSayCommand(STD_STRING(line))) return true; if (m_channel->GetServer().ExecuteSayCommand(STD_STRING(line))) return true; OutputError(wxString::Format(_("Command (%s) does not exist, use /help for a list of available commands."), line.c_str())); return true; } m_channel->Say(STD_STRING(line)); } else if (m_type == CPT_Battle) { if (m_battle == 0) { OutputError(_("You are not in battle or battle does not exist, use /help for a list of available commands.")); return true; } if (line.StartsWith(_T( "/" ))) { if (m_battle->ExecuteSayCommand(STD_STRING(line))) return true; if (m_battle->GetServer().ExecuteSayCommand(STD_STRING(line))) return true; OutputError(wxString::Format(_("Command (%s) does not exist, use /help for a list of available commands."), line.c_str())); return true; } m_battle->Say(STD_STRING(line)); } else if (m_type == CPT_User) { if (m_user == 0) { OutputError(_("User is offline.")); return true; } if (line.StartsWith(_T( "/" ))) { if (m_user->ExecuteSayCommand(STD_STRING(line))) return true; if (m_user->GetServer().ExecuteSayCommand(STD_STRING(line))) return true; OutputError(wxString::Format(_("Command (%s) does not exist, use /help for a list of available commands."), line.c_str())); return true; } m_user->Say(STD_STRING(line)); } else if (m_type == CPT_Server) { if (m_server == 0) { OutputError(_("Not connected to server")); return true; } if (line.StartsWith(_T( "/" ))) { if (m_server->ExecuteSayCommand(STD_STRING(line))) return true; OutputError(wxString::Format(_("Command (%s) does not exist, use /help for a list of available commands."), line.c_str())); return true; } m_server->SendCmd(STD_STRING(line), ""); OutputLine(_("Sent: \"") + line + _T("\""), sett().GetChatColorNormal()); } } return true; }
void unindex( BSONObj &key ) { bt()->unindex( dl(), id(), key, recordLoc() ); }
void SoundLibraryImportDialog::on_DownloadBtn_clicked() { QApplication::setOverrideCursor(Qt::WaitCursor); QString selected = m_pDrumkitTree->currentItem()->text(0); for ( uint i = 0; i < m_soundLibraryList.size(); ++i ) { if ( m_soundLibraryList[ i ].getName() == selected ) { // Download the sound library QString sURL = m_soundLibraryList[ i ].getUrl(); QString sType = m_soundLibraryList[ i ].getType(); QString sLocalFile; QString dataDir = H2Core::Preferences::get_instance()->getDataDirectory(); if( sType == "drumkit") { sLocalFile = QDir::tempPath() + "/" + QFileInfo( sURL ).fileName(); } if( sType == "song") { sLocalFile = dataDir + "songs/" + QFileInfo( sURL ).fileName(); } if( sType == "pattern") { sLocalFile = dataDir + "patterns/" + QFileInfo( sURL ).fileName(); } for ( int i = 0; i < 30; ++i ) { DownloadWidget dl( this, trUtf8( "Downloading SoundLibrary..." ), sURL, sLocalFile ); dl.exec(); QString redirect_url = dl.get_redirect_url(); if (redirect_url == "" ) { // ok, we have all data break; } else { sURL = redirect_url; } } // install the new soundlibrary try { if ( sType == "drumkit" ) { H2Core::Drumkit::install( sLocalFile ); QApplication::restoreOverrideCursor(); QMessageBox::information( this, "Hydrogen", QString( trUtf8( "SoundLibrary imported in %1" ) ).arg( dataDir ) ); } if ( sType == "song" || sType == "pattern") { QApplication::restoreOverrideCursor(); } } catch( H2Core::H2Exception ex ) { QApplication::restoreOverrideCursor(); QMessageBox::warning( this, "Hydrogen", trUtf8( "An error occurred importing the SoundLibrary." ) ); } QApplication::setOverrideCursor(Qt::WaitCursor); // remove the downloaded files.. if( sType == "drumkit" ) { QDir dir; dir.remove( sLocalFile ); } // update the drumkit list SoundLibraryDatabase::get_instance()->update(); HydrogenApp::get_instance()->getInstrumentRack()->getSoundLibraryPanel()->test_expandedItems(); HydrogenApp::get_instance()->getInstrumentRack()->getSoundLibraryPanel()->updateDrumkitList(); updateSoundLibraryList(); QApplication::restoreOverrideCursor(); return; } } }
Box* interpretFunction(llvm::Function* f, int nargs, Box* closure, Box* generator, Box* arg1, Box* arg2, Box* arg3, Box** args) { assert(f); #ifdef TIME_INTERPRETS Timer _t("to interpret", 1000000); long this_us = 0; #endif static StatCounter interpreted_runs("interpreted_runs"); interpreted_runs.log(); llvm::DataLayout dl(f->getParent()); // f->dump(); // assert(nargs == f->getArgumentList().size()); SymMap symbols; void* frame_ptr = __builtin_frame_address(0); root_stack_set.get()->push_back(&symbols); UnregisterHelper helper(frame_ptr); int arg_num = -1; int closure_indicator = closure ? 1 : 0; int generator_indicator = generator ? 1 : 0; int arg_offset = closure_indicator + generator_indicator; for (llvm::Argument& arg : f->args()) { arg_num++; if (arg_num == 0 && closure) symbols.insert(std::make_pair(static_cast<llvm::Value*>(&arg), Val(closure))); else if ((arg_num == 0 || (arg_num == 1 && closure)) && generator) symbols.insert(std::make_pair(static_cast<llvm::Value*>(&arg), Val(generator))); else if (arg_num == 0 + arg_offset) symbols.insert(std::make_pair(static_cast<llvm::Value*>(&arg), Val(arg1))); else if (arg_num == 1 + arg_offset) symbols.insert(std::make_pair(static_cast<llvm::Value*>(&arg), Val(arg2))); else if (arg_num == 2 + arg_offset) symbols.insert(std::make_pair(static_cast<llvm::Value*>(&arg), Val(arg3))); else { assert(arg_num == 3 + arg_offset); assert(f->getArgumentList().size() == 4 + arg_offset); assert(f->getArgumentList().back().getType() == g.llvm_value_type_ptr->getPointerTo()); symbols.insert(std::make_pair(static_cast<llvm::Value*>(&arg), Val((int64_t)args))); // printf("loading %%4 with %p\n", (void*)args); break; } } llvm::BasicBlock* prevblock = NULL; llvm::BasicBlock* curblock = &f->getEntryBlock(); // The symbol table at the end of the previous BB // This is important for the following case: // %a = phi [0, %l1], [1, %l2] // %b = phi [0, %l1], [%a, %l2] // The reference to %a in the definition of %b resolves to the *previous* value of %a, // not the value of %a that we just set in the phi. SymMap prev_symbols; struct { Box* exc_obj; int64_t exc_selector; } landingpad_value; while (true) { for (llvm::Instruction& _inst : *curblock) { llvm::Instruction* inst = &_inst; cur_instruction_map[frame_ptr] = inst; if (VERBOSITY("interpreter") >= 2) { printf("executing in %s: ", f->getName().data()); fflush(stdout); inst->dump(); // f->dump(); } #define SET(v) set(symbols, inst, (v)) if (llvm::LandingPadInst* lpad = llvm::dyn_cast<llvm::LandingPadInst>(inst)) { SET((intptr_t)&landingpad_value); continue; } else if (llvm::ExtractValueInst* ev = llvm::dyn_cast<llvm::ExtractValueInst>(inst)) { Val r = fetch(ev->getAggregateOperand(), dl, symbols); llvm::ArrayRef<unsigned> indexes = ev->getIndices(); #ifndef NDEBUG assert(indexes.size() == 1); llvm::Type* t = llvm::ExtractValueInst::getIndexedType(ev->getAggregateOperand()->getType(), indexes); assert(width(t, dl) == 8); #endif int64_t* ptr = (int64_t*)r.n; int64_t val = ptr[indexes[0]]; SET(val); continue; } else if (llvm::LoadInst* li = llvm::dyn_cast<llvm::LoadInst>(inst)) { llvm::Value* ptr = li->getOperand(0); Val v = fetch(ptr, dl, symbols); // printf("loading from %p\n", v.o); if (width(li, dl) == 1) { Val r = Val(*(bool*)v.o); SET(r); continue; } else if (width(li, dl) == 8) { Val r = Val(*(int64_t*)v.o); SET(r); continue; } else { li->dump(); RELEASE_ASSERT(0, ""); } } else if (llvm::StoreInst* si = llvm::dyn_cast<llvm::StoreInst>(inst)) { llvm::Value* val = si->getOperand(0); llvm::Value* ptr = si->getOperand(1); Val v = fetch(val, dl, symbols); Val p = fetch(ptr, dl, symbols); // printf("storing %lx at %lx\n", v.n, p.n); if (width(val, dl) == 1) { *(bool*)p.o = v.b; continue; } else if (width(val, dl) == 8) { *(int64_t*)p.o = v.n; continue; } else { si->dump(); RELEASE_ASSERT(0, ""); } } else if (llvm::CmpInst* ci = llvm::dyn_cast<llvm::CmpInst>(inst)) { assert(ci->getType() == g.i1); Val a0 = fetch(ci->getOperand(0), dl, symbols); Val a1 = fetch(ci->getOperand(1), dl, symbols); llvm::CmpInst::Predicate pred = ci->getPredicate(); switch (pred) { case llvm::CmpInst::ICMP_EQ: SET(a0.n == a1.n); continue; case llvm::CmpInst::ICMP_NE: SET(a0.n != a1.n); continue; case llvm::CmpInst::ICMP_SLT: SET(a0.n < a1.n); continue; case llvm::CmpInst::ICMP_SLE: SET(a0.n <= a1.n); continue; case llvm::CmpInst::ICMP_SGT: SET(a0.n > a1.n); continue; case llvm::CmpInst::ICMP_SGE: SET(a0.n >= a1.n); continue; case llvm::CmpInst::FCMP_OEQ: SET(a0.d == a1.d); continue; case llvm::CmpInst::FCMP_UNE: SET(a0.d != a1.d); continue; case llvm::CmpInst::FCMP_OLT: SET(a0.d < a1.d); continue; case llvm::CmpInst::FCMP_OLE: SET(a0.d <= a1.d); continue; case llvm::CmpInst::FCMP_OGT: SET(a0.d > a1.d); continue; case llvm::CmpInst::FCMP_OGE: SET(a0.d >= a1.d); continue; default: ci->dump(); RELEASE_ASSERT(0, ""); } continue; } else if (llvm::BinaryOperator* bo = llvm::dyn_cast<llvm::BinaryOperator>(inst)) { if (bo->getOperand(0)->getType() == g.i64 || bo->getOperand(0)->getType() == g.i1) { // assert(bo->getOperand(0)->getType() == g.i64); // assert(bo->getOperand(1)->getType() == g.i64); Val a0 = fetch(bo->getOperand(0), dl, symbols); Val a1 = fetch(bo->getOperand(1), dl, symbols); llvm::Instruction::BinaryOps opcode = bo->getOpcode(); switch (opcode) { case llvm::Instruction::Add: SET(a0.n + a1.n); continue; case llvm::Instruction::And: SET(a0.n & a1.n); continue; case llvm::Instruction::AShr: SET(a0.n >> a1.n); continue; case llvm::Instruction::Mul: SET(a0.n * a1.n); continue; case llvm::Instruction::Or: SET(a0.n | a1.n); continue; case llvm::Instruction::Shl: SET(a0.n << a1.n); continue; case llvm::Instruction::Sub: SET(a0.n - a1.n); continue; case llvm::Instruction::Xor: SET(a0.n ^ a1.n); continue; default: bo->dump(); RELEASE_ASSERT(0, ""); } continue; } else if (bo->getOperand(0)->getType() == g.double_) { // assert(bo->getOperand(0)->getType() == g.i64); // assert(bo->getOperand(1)->getType() == g.i64); double lhs = fetch(bo->getOperand(0), dl, symbols).d; double rhs = fetch(bo->getOperand(1), dl, symbols).d; llvm::Instruction::BinaryOps opcode = bo->getOpcode(); switch (opcode) { case llvm::Instruction::FAdd: SET(lhs + rhs); continue; case llvm::Instruction::FMul: SET(lhs * rhs); continue; case llvm::Instruction::FSub: SET(lhs - rhs); continue; default: bo->dump(); RELEASE_ASSERT(0, ""); } continue; } else { bo->dump(); RELEASE_ASSERT(0, ""); } } else if (llvm::GetElementPtrInst* gep = llvm::dyn_cast<llvm::GetElementPtrInst>(inst)) {