static int testaddr(void *addr, volatile void *want) { #if defined(__s390__) if (addr != (void *) ((unsigned long) want & ~0xffful)) { #else if (addr != want) { #endif fprintf(stderr, " FAIL: expected si_addr==%p, not %p\n", want, addr); return 0; } return 1; } static void handler(int sig, siginfo_t *si, void *uc) { int ok = 1; ok = ok && testsig(sig, cur_test->sig); ok = ok && testcode(si->si_code, cur_test->code); if (cur_test->addr) ok = ok && testaddr(si->si_addr, cur_test->addr); if (ok) fprintf(stderr, " PASS\n"); siglongjmp(escape, ok + 1); }
static int testaddr(void *addr, volatile void *want) { /* Some architectures (e.g. s390) just provide enough information to resolve the page fault, but do not provide the offset within a page */ #if defined(__s390__) if (addr != (void *) ((unsigned long) want & ~0xffful)) { #else if (addr != want) { #endif fprintf(stderr, " FAIL: expected si_addr==%p, not %p\n", want, addr); return 0; } return 1; } static void handler(int sig, siginfo_t *si, void *uc) { int ok = 1; ok = ok && testsig(sig, cur_test->sig); ok = ok && testcode(si->si_code, cur_test->code); if (cur_test->addr) ok = ok && testaddr(si->si_addr, cur_test->addr); if (ok) fprintf(stderr, " PASS\n"); siglongjmp(escape, ok + 1); }
int main( int argc, char **argv ){ (void) argc; (void) argv; testsig(); testfault(); return 0; }
static void handler(int sig, siginfo_t *si, void *uc) { int ok = 1; ok = ok && testsig(sig, curr_test->sig); ok = ok && testcode(si->si_code, curr_test->code); if (ok) fprintf(stderr, " PASS\n"); siglongjmp(escape, ok + 1); }
void Graph::findCommus(){ int successiveFails = 0; while(successiveFails <10){ int v = rand() % numVertices; Community c(this); c.addVertex(v); c.optimize(); if(c.sig<sigthresh){ storeCommunity(c); successiveFails=0; print(); }else{ successiveFails++; cout << "failed " << successiveFails << endl; } } bool foundone = true; level = 1; while(foundone){ foundone = false; successiveFails = 0; while(successiveFails <10){ int comm = rand() % commusperlevel[level-1].size(); SuperCommunity s(this,level); s.addCommu(commusperlevel[level-1][comm]); Community c(this); if(supercomOpt(s,c) && c.sig < sigthresh){ storeCommunity(c); foundone = true; successiveFails = 0; intset tested; for(vecintset::iterator ov = overlaps[overlaps.size()-1].begin(); ov != overlaps[overlaps.size()-1].end(); ov++){ for(int i=0; i<ov->size(); i++){ if(tested.count((*ov)[i]) > 0){ int comm = (*ov)[i]; tested.insert(comm); if(communities[comm].level < level){ if(testsig(comm) > sigthresh){ deleteCommunity(comm); } } } } } }else{ successiveFails++; } } } }
void Graph::optimizeCommus(){ bool haschanged = true; while(haschanged){ haschanged = false; for(int v=0; v<numVertices; v++){ intset neighborcommus; for(edgemap::iterator e = vertices[v].edges.begin(); e != vertices[v].edges.end(); e++){ for(int i=0; i<commupervertex[e->first].size(); i++){ neighborcommus.insert(commupervertex[e->first][i]); } } for(int i=0; i<commupervertex[v].size(); i++){ neighborcommus.erase(commupervertex[v][i]); } for(int i=0; i<commupervertex[v].size(); i++){ if(testwithout(v,commupervertex[v][i])){ removeVertexCommunity(v,commupervertex[v][i]); if(testsig(commupervertex[v][i]) > sigthresh){ deleteCommunity(commupervertex[v][i]); } updateModel(); } } for(intset::iterator c = neighborcommus.begin(); c != neighborcommus.end(); c++){ if(testwith(v,*c)){ addVertexCommunity(v,*c); if(testsig(*c) > sigthresh){ removeVertexCommunity(v,*c); }else{ updateModel(); } } } } } }