int foo_client_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData) { fooAlphaFunc = (fooAlphaFunc_client_proc_t) getProc("fooAlphaFunc", userData); fooIsBuffer = (fooIsBuffer_client_proc_t) getProc("fooIsBuffer", userData); fooUnsupported = (fooUnsupported_client_proc_t) getProc("fooUnsupported", userData); fooDoEncoderFlush = (fooDoEncoderFlush_client_proc_t) getProc("fooDoEncoderFlush", userData); fooTakeConstVoidPtrConstPtr = (fooTakeConstVoidPtrConstPtr_client_proc_t) getProc("fooTakeConstVoidPtrConstPtr", userData); return 0; }
/** * Test the placing of phi functions. */ void CfgTest::testPlacePhi() { auto prog = Prog::open(FRONTIER_PENTIUM); CPPUNIT_ASSERT(prog); auto fe = prog->getFrontEnd(); Type::clearNamedTypes(); fe->decode(); UserProc *pProc = (UserProc *)prog->getProc(0); Cfg *cfg = pProc->getCFG(); // Simplify expressions (e.g. m[ebp + -8] -> m[ebp - 8] prog->finishDecode(); DataFlow *df = pProc->getDataFlow(); df->dominators(cfg); df->placePhiFunctions(pProc); // m[r29 - 8] (x for this program) Exp *e = Location::memOf( new Binary(opMinus, Location::regOf(29), new Const(4))); // A_phi[x] should be the set {7 8 10 15 20 21} (all the join points) std::ostringstream ost; std::set<int> &A_phi = df->getA_phi(e); for (const auto &ii : A_phi) ost << ii << " "; std::string expected("7 8 10 15 20 21 "); CPPUNIT_ASSERT_EQUAL(expected, ost.str()); delete prog; }
void BaseShadow::removeJobPre( const char* reason ) { if( ! jobAd ) { dprintf( D_ALWAYS, "In removeJob() w/ NULL JobAd!" ); } dprintf( D_ALWAYS, "Job %d.%d is being removed: %s\n", getCluster(), getProc(), reason ); // cleanup this shadow (kill starters, etc) cleanUp( jobWantsGracefulRemoval() ); // Put the reason in our job ad. int size = strlen( reason ) + strlen( ATTR_REMOVE_REASON ) + 4; char* buf = (char*)malloc( size * sizeof(char) ); if( ! buf ) { EXCEPT( "Out of memory!" ); } sprintf( buf, "%s=\"%s\"", ATTR_REMOVE_REASON, reason ); jobAd->Insert( buf ); free( buf ); emailRemoveEvent( reason ); // update the job ad in the queue with some important final // attributes so we know what happened to the job when using // condor_history... if( !updateJobInQueue(U_REMOVE) ) { // trouble! TODO: should we do anything else? dprintf( D_ALWAYS, "Failed to update job queue!\n" ); } }
void XS09(struct S09_st *d) { //proc fnc = [blk]; if (getProc(&procList, d->name) != NULL) fprintf(stderr, "%s : proc already coded!\n", d->name); else defineProc(&procList, d->name, d->statements); }
bool Load::canHist(const Record *record) { QUrlQuery query; query.addQueryItem("source", record->source); query.addQueryItem("date", "0"); return getProc("hist?" + query.toString()); }
/* Does not return - goes to scheduler */ void GCFromMutator(Thread_t* curThread) { Proc_t *proc = (Proc_t *) curThread->proc; mem_t alloc = (mem_t) curThread->saveregs[ALLOCPTR]; mem_t limit = (mem_t) curThread->saveregs[ALLOCLIMIT]; mem_t sysAllocLimit = proc->allocLimit; /* Put registers in stacklet */ int i; Stacklet_t *stacklet = CurrentStacklet(curThread->stack); volatile reg_t* primaryRegs = &stacklet->bottomBaseRegs[primaryStackletOffset == 0 ? 0 : 32]; for (i=0; i<32; i++) primaryRegs[i] = curThread->saveregs[i]; /* Check that we are running on own stack and allocation pointers consistent */ if (paranoid) assert(proc == (getProc())); /* getProc is slow */ assert(proc->userThread == curThread); assert((proc->stack - (int) (&proc)) < 1024) ; assert((limit == sysAllocLimit) || (limit == StopHeapLimit)); assert(alloc <= sysAllocLimit); /* ReleaseJob(proc) */ /* Update processor's info, GCRelease thread, but don't unmap */ UpdateJob(proc); procChangeState(proc, Scheduler, 1003); scheduler(proc); DIE("scheduler returned"); }
Assignment *StatementList::findOnLeft(SharedExp loc) { if (empty()) { return nullptr; } for (auto &elem : *this) { assert(elem->isAssignment()); SharedConstExp left = static_cast<Assignment *>(elem)->getLeft(); if (*left == *loc) { return static_cast<Assignment *>(elem); } if (left->isLocal()) { auto l = left->access<Location>(); SharedConstExp e = l->getProc()->expFromSymbol(l->access<Const, 1>()->getStr()); if (e && ((*e == *loc) || (e->isSubscript() && (*e->getSubExp1() == *loc)))) { return static_cast<Assignment *>(elem); } } } return nullptr; }
static ptr_t alloc_bigdispatcharray(ArraySpec_t* spec) { ptr_t result = NULL; Proc_t *proc = getProc(); Thread_t *thread = proc->userThread; assert(spec->byteLen >= 512); if (spec->type == PointerField || spec->type == MirrorPointerField) installThreadRoot(thread,&spec->pointerVal); switch (collector_type) { case Semispace: result = AllocBigArray_Semi(proc,thread,spec); break; case Generational: result = AllocBigArray_Gen(proc,thread,spec); break; case SemispaceParallel: result = AllocBigArray_SemiPara(proc,thread,spec); break; case GenerationalParallel: result = AllocBigArray_GenPara(proc,thread,spec); break; case SemispaceConcurrent: result = AllocBigArray_SemiConc(proc,thread,spec); break; case GenerationalConcurrent: result = AllocBigArray_GenConc(proc,thread,spec); break; default: DIE("collector type"); } if (spec->type == PointerField || spec->type == MirrorPointerField) uninstallThreadRoot(thread,&spec->pointerVal); return result; }
PROC *kfork() { int i; PROC *tmpProc = getProc(&freeList); //if the proc is null if(!tmpProc) { printf("ERROR: kFork failed, empty PROC list.\n"); return 0; } tmpProc->status = READY; tmpProc->priority = 1; tmpProc->ppid = running->pid; //clearing old kstack for(i = 1; i < 10; i++) { tmpProc->kstack[SSIZE - 9] = 0; } tmpProc->kstack[SSIZE - 1] = (int)body; tmpProc->ksp = &tmpProc->kstack[SSIZE - 9]; enqueue(&readyQueue, tmpProc); return tmpProc; }
void BaseShadow::holdJob( const char* reason, int hold_reason_code, int hold_reason_subcode ) { dprintf( D_ALWAYS, "Job %d.%d going into Hold state (code %d,%d): %s\n", getCluster(), getProc(), hold_reason_code, hold_reason_subcode,reason ); if( ! jobAd ) { dprintf( D_ALWAYS, "In HoldJob() w/ NULL JobAd!" ); DC_Exit( JOB_SHOULD_HOLD ); } // cleanup this shadow (kill starters, etc) cleanUp( jobWantsGracefulRemoval() ); // Put the reason in our job ad. jobAd->Assign( ATTR_HOLD_REASON, reason ); jobAd->Assign( ATTR_HOLD_REASON_CODE, hold_reason_code ); jobAd->Assign( ATTR_HOLD_REASON_SUBCODE, hold_reason_subcode ); // try to send email (if the user wants it) emailHoldEvent( reason ); // update the job queue for the attributes we care about if( !updateJobInQueue(U_HOLD) ) { // trouble! TODO: should we do anything else? dprintf( D_ALWAYS, "Failed to update job queue!\n" ); } }
/** * Test the renaming of variables. */ void CfgTest::testRenameVars() { auto prog = Prog::open(FRONTIER_PENTIUM); CPPUNIT_ASSERT(prog); auto fe = prog->getFrontEnd(); Type::clearNamedTypes(); fe->decode(); UserProc *pProc = (UserProc *)prog->getProc(0); Cfg *cfg = pProc->getCFG(); DataFlow *df = pProc->getDataFlow(); // Simplify expressions (e.g. m[ebp + -8] -> m[ebp - 8] prog->finishDecode(); df->dominators(cfg); df->placePhiFunctions(pProc); pProc->numberStatements(); // After placing phi functions! df->renameBlockVars(pProc, 0, 1); // Block 0, mem depth 1 // MIKE: something missing here? delete prog; }
bool load( const char * libName ) { if ( !_lib ) { _lib = dlopen( libName, RTLD_NOW | RTLD_LOCAL ); } if ( _lib ) { AndroidBitmap_getInfo = (int (*)(JNIEnv* env, jobject jbitmap, AndroidBitmapInfo* info)) getProc( "AndroidBitmap_getInfo" ); AndroidBitmap_lockPixels = (int (*)(JNIEnv* env, jobject jbitmap, void** addrPtr)) getProc( "AndroidBitmap_lockPixels" ); AndroidBitmap_unlockPixels = (int (*)(JNIEnv* env, jobject jbitmap)) getProc( "AndroidBitmap_unlockPixels"); if ( !AndroidBitmap_getInfo || !AndroidBitmap_lockPixels || !AndroidBitmap_unlockPixels ) unload(); // not all functions found in library, fail } return ( _lib!=NULL ); }
void StdScheduler::Remove(StdSchedulerProc *pProc) { // Search int iPos = getProc(pProc); // Not found? if (iPos >= iProcCnt) return; // Remove for (int i = iPos + 1; i < iProcCnt; i++) ppProcs[i - 1] = ppProcs[i]; iProcCnt--; }
Load::Task Load::codeToTask(QString code) { Task task; task.processer = getProc(code); task.code = code; APlayer *aplayer = APlayer::instance(); task.delay = aplayer->getState() != APlayer::Stop&&Config::getValue("/Playing/Delay", false) ? aplayer->getTime() : 0; return task; }
/** * Test the dominator frontier code. */ void CfgTest::testDominators() { #define FRONTIER_FOUR 0x08048347 #define FRONTIER_FIVE 0x08048351 #define FRONTIER_TWELVE 0x080483b2 #define FRONTIER_THIRTEEN 0x080483b9 auto prog = Prog::open(FRONTIER_PENTIUM); CPPUNIT_ASSERT(prog); auto fe = prog->getFrontEnd(); Type::clearNamedTypes(); fe->decode(); bool gotMain; ADDRESS addr = fe->getMainEntryPoint(gotMain); CPPUNIT_ASSERT(addr != NO_ADDRESS); UserProc *pProc = (UserProc *)prog->getProc(0); Cfg *cfg = pProc->getCFG(); DataFlow *df = pProc->getDataFlow(); df->dominators(cfg); // Find BB "5" (as per Appel, Figure 19.5). BasicBlock *bb = nullptr; for (const auto &b : *cfg) { if (b->getLowAddr() == FRONTIER_FIVE) { bb = b; break; } } CPPUNIT_ASSERT(bb); std::ostringstream expected, actual; #if 0 expected << std::hex << FRONTIER_FIVE << " " << FRONTIER_THIRTEEN << " " << FRONTIER_TWELVE << " " << FRONTIER_FOUR << " " << std::dec; #endif expected << std::hex << FRONTIER_THIRTEEN << " " << FRONTIER_FOUR << " " << FRONTIER_TWELVE << " " << FRONTIER_FIVE << " " << std::dec; int n5 = df->pbbToNode(bb); std::set<int> &DFset = df->getDF(n5); for (const auto &ii : DFset) actual << std::hex << (unsigned)df->nodeToBB(ii)->getLowAddr() << std::dec << " "; CPPUNIT_ASSERT_EQUAL(expected.str(), actual.str()); delete prog; }
void Post::postComment(const Record *r, const Comment *c) { Task task; task.code = r->access; task.comment = *c; task.comment.time -= r->delay; task.target = r; task.processer = getProc(task.code); enqueue(task); }
/** * Test a case where semi dominators are different to dominators. */ void CfgTest::testSemiDominators() { #define SEMI_L 0x80483b0 #define SEMI_M 0x80483e2 #define SEMI_B 0x8048345 #define SEMI_D 0x8048354 #define SEMI_M 0x80483e2 auto prog = Prog::open(SEMI_PENTIUM); CPPUNIT_ASSERT(prog); auto fe = prog->getFrontEnd(); Type::clearNamedTypes(); fe->decode(); bool gotMain; ADDRESS addr = fe->getMainEntryPoint(gotMain); CPPUNIT_ASSERT(addr != NO_ADDRESS); UserProc *pProc = (UserProc *)prog->getProc(0); Cfg *cfg = pProc->getCFG(); DataFlow *df = pProc->getDataFlow(); df->dominators(cfg); // Find BB "L (6)" (as per Appel, Figure 19.8). BasicBlock *bb = nullptr; for (const auto &b : *cfg) { if (b->getLowAddr() == SEMI_L) { bb = b; break; } } CPPUNIT_ASSERT(bb); int nL = df->pbbToNode(bb); // The dominator for L should be B, where the semi dominator is D // (book says F) unsigned actual_dom = (unsigned)df->nodeToBB(df->getIdom(nL))->getLowAddr(); unsigned actual_semi = (unsigned)df->nodeToBB(df->getSemi(nL))->getLowAddr(); CPPUNIT_ASSERT_EQUAL((unsigned)SEMI_B, actual_dom); CPPUNIT_ASSERT_EQUAL((unsigned)SEMI_D, actual_semi); // Check the final dominator frontier as well; should be M and B std::ostringstream expected, actual; #if 0 expected << std::hex << SEMI_M << " " << SEMI_B << " " << std::dec; #endif expected << std::hex << SEMI_B << " " << SEMI_M << " " << std::dec; std::set<int> &DFset = df->getDF(nL); for (const auto &ii : DFset) actual << std::hex << (unsigned)df->nodeToBB(ii)->getLowAddr() << std::dec << " "; CPPUNIT_ASSERT_EQUAL(expected.str(), actual.str()); delete prog; }
/** * Test a case where a phi function is not needed. */ void CfgTest::testPlacePhi2() { auto prog = Prog::open(IFTHEN_PENTIUM); CPPUNIT_ASSERT(prog); auto fe = prog->getFrontEnd(); Type::clearNamedTypes(); fe->decode(); UserProc *pProc = (UserProc *)prog->getProc(0); Cfg *cfg = pProc->getCFG(); DataFlow *df = pProc->getDataFlow(); // Simplify expressions (e.g. m[ebp + -8] -> m[ebp - 8] prog->finishDecode(); df->dominators(cfg); df->placePhiFunctions(pProc); // In this program, x is allocated at [ebp-4], a at [ebp-8], and // b at [ebp-12] // We check that A_phi[ m[ebp-8] ] is 4, and that // A_phi A_phi[ m[ebp-8] ] is null // (block 4 comes out with n=4) std::string expected = "4 "; std::ostringstream actual; // m[r29 - 8] Exp *e = Location::memOf( new Binary(opMinus, Location::regOf(29), new Const(8))); std::set<int> &s = df->getA_phi(e); for (const auto &pp : s) actual << pp << " "; CPPUNIT_ASSERT_EQUAL(expected, actual.str()); delete e; expected = ""; std::ostringstream actual2; // m[r29 - 12] e = Location::memOf( new Binary(opMinus, Location::regOf(29), new Const(12))); std::set<int> &s2 = df->getA_phi(e); for (const auto &pp : s2) actual2 << pp << " "; CPPUNIT_ASSERT_EQUAL(expected, actual2.str()); delete e; delete prog; }
BOOL kiArcDLLRaw::check( LPCSTR filename, const int mode ) { if( not_loaded_yet ) if( !load() ) return FALSE; if( !f_Chk ) f_Chk = getProc( "CheckArchive" ); typedef BOOL (WINAPI * CARC_CHK)(const char*,const int); return f_Chk ? ((CARC_CHK)f_Chk)( filename, mode ) : FALSE; }
HARC kiArcDLLRaw::openArc( const HWND wnd, LPCSTR arcname, const DWORD flag ) { if( not_loaded_yet ) if( !load() ) return NULL; if( !f_Opn ) f_Opn = getProc( "OpenArchive" ); typedef HARC (WINAPI * CARC_OPN)(const HWND,LPCSTR,const DWORD); return f_Opn ? ((CARC_OPN)f_Opn)( wnd, arcname, flag ) : NULL; }
int kiArcDLLRaw::findnext( HARC arc, INDIVIDUALINFO* inf ) { if( not_loaded_yet ) if( !load() ) return ERROR_NOT_SUPPORT; if( !f_Fnx ) f_Fnx = getProc( "FindNext" ); typedef int (WINAPI * CARC_FNX)(HARC,INDIVIDUALINFO FAR *); return f_Fnx ? ((CARC_FNX)f_Fnx)( arc, inf ) : ERROR_NOT_SUPPORT; }
int kiArcDLLRaw::findfirst( HARC arc, LPCSTR wildname, INDIVIDUALINFO* inf ) { if( not_loaded_yet ) if( !load() ) return ERROR_NOT_SUPPORT; if( !f_Ffs ) f_Ffs = getProc( "FindFirst" ); typedef int (WINAPI * CARC_FFS)(HARC,LPCSTR,INDIVIDUALINFO FAR *); return f_Ffs ? ((CARC_FFS)f_Ffs)( arc, wildname, inf ) : ERROR_NOT_SUPPORT; }
int kiArcDLLRaw::getAttr( HARC arc ) { if( not_loaded_yet ) if( !load() ) return ERROR_NOT_SUPPORT; if( !f_GAr ) f_GAr = getProc( "GetAttribute" ); typedef int (WINAPI * CARC_GAR)(HARC); return f_GAr ? ((CARC_GAR)f_GAr)( arc ) : 0; }
BOOL kiArcDLLRaw::setOwner( HWND wnd ) { if( not_loaded_yet ) if( !load() ) return ERROR_NOT_SUPPORT; if( !f_SOw ) f_SOw = getProc( "SetOwnerWindow" ); typedef BOOL (WINAPI * CARC_SOW)(HWND); return f_SOw ? ((CARC_SOW)f_SOw)( wnd ) : FALSE; }
WORD kiArcDLLRaw::getVerSub() { if( not_loaded_yet ) if( !load() ) return 0; if( !f_VSb ) f_VSb = getProc( "GetSubVersion" ); typedef WORD (WINAPI * CARC_VER)(void); return f_VSb ? ((CARC_VER)f_VSb)() : 0; }
BOOL kiArcDLLRaw::clearOwner() { if( not_loaded_yet ) if( !load() ) return ERROR_NOT_SUPPORT; if( !f_COw ) f_COw = getProc( "ClearOwnerWindow" ); typedef BOOL (WINAPI * CARC_COW)(); return f_COw ? ((CARC_COW)f_COw)() : FALSE; }
int kiArcDLLRaw::getArcType( LPCSTR filename ) { if( not_loaded_yet ) if( !load() ) return FALSE; if( !f_Gat ) f_Gat = getProc( "GetArchiveType" ); typedef BOOL (WINAPI * CARC_GAT)(const char*); return f_Gat ? ((CARC_GAT)f_Gat)( filename ) : 0; }
void kiArcDLLRaw::closeArc( HARC arc ) { if( not_loaded_yet ) if( !load() ) return; if( !f_Cls ) f_Cls = getProc( "CloseArchive" ); typedef int (WINAPI * CARC_CLS)(HARC); if( f_Cls ) ((CARC_CLS)f_Cls)( arc ); }
// Find the first Assignment with loc on the LHS Assignment * StatementList::findOnLeft(Exp *loc) const { for (const auto &s : slist) { auto as = (Assignment *)s; Exp *left = as->getLeft(); if (*left == *loc) return as; if (left->isLocal()) { auto l = (Location *)left; Exp *e = l->getProc()->expFromSymbol(((Const *)l->getSubExp1())->getStr()); if (e && ((*e == *loc) || (e->isSubscript() && *e->getSubExp1() == *loc))) { return as; } } } return nullptr; }
void BaseShadow::mockTerminateJob( MyString exit_reason, bool exited_by_signal, int exit_code, int exit_signal, bool core_dumped ) { if (exit_reason == "") { exit_reason = "Exited normally"; } dprintf( D_ALWAYS, "Mock terminating job %d.%d: " "exited_by_signal=%s, exit_code=%d OR exit_signal=%d, " "core_dumped=%s, exit_reason=\"%s\"\n", getCluster(), getProc(), exited_by_signal ? "TRUE" : "FALSE", exit_code, exit_signal, core_dumped ? "TRUE" : "FALSE", exit_reason.Value()); if( ! jobAd ) { dprintf(D_ALWAYS, "BaseShadow::mockTerminateJob(): NULL JobAd! " "Holding Job!"); DC_Exit( JOB_SHOULD_HOLD ); } // Insert the various exit attributes into our job ad. jobAd->Assign( ATTR_JOB_CORE_DUMPED, core_dumped ); jobAd->Assign( ATTR_ON_EXIT_BY_SIGNAL, exited_by_signal ); if (exited_by_signal) { jobAd->Assign( ATTR_ON_EXIT_SIGNAL, exit_signal ); } else { jobAd->Assign( ATTR_ON_EXIT_CODE, exit_code ); } jobAd->Assign( ATTR_EXIT_REASON, exit_reason ); // update the job queue for the attributes we care about if( !updateJobInQueue(U_TERMINATE) ) { // trouble! TODO: should we do anything else? dprintf( D_ALWAYS, "Failed to update job queue!\n" ); } }