/* A whole sub-tree went away or appeared */ static void show_tree(struct diff_options *opt, const char *prefix, struct tree_desc *desc, const char *base) { while (desc->size) { if (interesting(desc, base)) show_entry(opt, prefix, desc, base); update_tree_entry(desc); } }
static void i82563interrupt(Ureg*, void* arg) { int icr, im, rdh, txdw = 0; Block *bp; Ctlr *ctlr; Ether *edev; Rdesc *rdesc; edev = arg; ctlr = edev->ctlr; ilock(&ctlr->imlock); csr32w(ctlr, Imc, ~0); im = ctlr->im; for(icr = csr32r(ctlr, Icr); icr & ctlr->im; icr = csr32r(ctlr, Icr)){ if(icr & (Rxseq|Lsc)){ /* should be more here */ } rdh = ctlr->rdh; for (;;) { rdesc = &ctlr->rdba[rdh]; if(!(rdesc->status & Rdd)) break; if ((rdesc->status & Reop) && rdesc->errors == 0) { bp = ctlr->rb[rdh]; if(0 && memcmp(bp->rp, broadcast, 6) != 0) print("#l%d: rx %d %E %E %d\n", edev->ctlrno, rdh, bp->rp, bp->rp+6, rdesc->length); ctlr->rb[rdh] = nil; bp->wp += rdesc->length; if (interesting(bp)) toringbuf(edev, bp); freeb(bp); } else if (rdesc->status & Reop && rdesc->errors) print("%s: input packet error %#ux\n", tname[ctlr->type], rdesc->errors); rdesc->status = 0; rdh = NEXT(rdh, Nrdesc); } ctlr->rdh = rdh; if(icr & Rxdmt0) i82563replenish(ctlr); if(icr & Txdw){ im &= ~Txdw; txdw++; } } ctlr->im = im; csr32w(ctlr, Ims, im); iunlock(&ctlr->imlock); if(txdw) i82563transmit(edev); }
/* * Usage: rev-tree [--edges] [--cache <cache-file>] <commit-id> [<commit-id2>] * * The cache-file can be quite important for big trees. This is an * expensive operation if you have to walk the whole chain of * parents in a tree with a long revision history. */ int main(int argc, char **argv) { int i; int nr = 0; unsigned char sha1[MAX_COMMITS][20]; /* * First - pick up all the revisions we can (both from * caches and from commit file chains). */ for (i = 1; i < argc ; i++) { char *arg = argv[i]; if (!strcmp(arg, "--cache")) { read_cache_file(argv[2]); i++; continue; } if (!strcmp(arg, "--edges")) { show_edges = 1; continue; } if (nr >= MAX_COMMITS || get_sha1_hex(arg, sha1[nr])) usage("rev-tree [--edges] [--cache <cache-file>] <commit-id> [<commit-id>]"); parse_commit(sha1[nr]); nr++; } /* * Now we have the maximal tree. Walk the different sha files back to the root. */ for (i = 0; i < nr; i++) mark_sha1_path(lookup_rev(sha1[i]), 1 << i); /* * Now print out the results.. */ for (i = 0; i < nr_revs; i++) { struct revision *rev = revs[i]; struct parent *p; if (!interesting(rev)) continue; printf("%s:%d", sha1_to_hex(rev->sha1), marked(rev)); p = rev->parent; while (p) { printf(" %s:%d", sha1_to_hex(p->parent->sha1), marked(p->parent)); p = p->next; } printf("\n"); } return 0; }
int main(void) { for (size_t value = 30; value != 50; ++value) { if (should_stop(value)) { break; } if (!interesting(value)) { continue; } process(value); } return 0; }
int diff_tree(struct tree_desc *t1, struct tree_desc *t2, const char *base, struct diff_options *opt) { while (t1->size | t2->size) { if (nr_paths && t1->size && !interesting(t1, base)) { update_tree_entry(t1); continue; } if (nr_paths && t2->size && !interesting(t2, base)) { update_tree_entry(t2); continue; } if (!t1->size) { show_entry(opt, "+", t2, base); update_tree_entry(t2); continue; } if (!t2->size) { show_entry(opt, "-", t1, base); update_tree_entry(t1); continue; } switch (compare_tree_entry(t1, t2, base, opt)) { case -1: update_tree_entry(t1); continue; case 0: update_tree_entry(t1); /* Fallthrough */ case 1: update_tree_entry(t2); continue; } die("git-diff-tree: internal error"); } return 0; }
static int premark_uninteresting(git_revwalk *walk) { int error = 0; unsigned short i; git_pqueue q; git_commit_list *list; git_commit_list_node *commit, *parent; if ((error = git_pqueue_init(&q, 0, 8, git_commit_list_time_cmp)) < 0) return error; for (list = walk->user_input; list; list = list->next) { if ((error = git_commit_list_parse(walk, list->item)) < 0) goto cleanup; if ((error = git_pqueue_insert(&q, list->item)) < 0) goto cleanup; } while (interesting(&q)) { commit = git_pqueue_pop(&q); for (i = 0; i < commit->out_degree; i++) { parent = commit->parents[i]; if ((error = git_commit_list_parse(walk, parent)) < 0) goto cleanup; if (commit->uninteresting) parent->uninteresting = 1; if (contains(&q, parent)) continue; if ((error = git_pqueue_insert(&q, parent)) < 0) goto cleanup; } } cleanup: git_pqueue_free(&q); return error; }
static void toringbuf(Ether* edev, uint8_t* data, int len) { RingBuf *rb; extern int interesting(void*); if(!interesting(data)) return; rb = &edev->rb[edev->ri]; if(rb->owner == Interface){ if(len > sizeof(rb->pkt)) len = sizeof(rb->pkt); rb->len = len; memmove(rb->pkt, data, rb->len); rb->owner = Host; edev->ri = NEXT(edev->ri, edev->nrb); } else if(debug){ print("#l%d: toringbuf: dropping packets @ ri %d\n", edev->ctlrno, edev->ri); } }
static void join_revs(struct commit_list **list_p, struct commit_list **seen_p, int num_rev, int extra) { int all_mask = ((1u << (REV_SHIFT + num_rev)) - 1); int all_revs = all_mask & ~((1u << REV_SHIFT) - 1); while (*list_p) { struct commit_list *parents; int still_interesting = !!interesting(*list_p); struct commit *commit = pop_one_commit(list_p); int flags = commit->object.flags & all_mask; if (!still_interesting && extra <= 0) break; mark_seen(commit, seen_p); if ((flags & all_revs) == all_revs) flags |= UNINTERESTING; parents = commit->parents; while (parents) { struct commit *p = parents->item; int this_flag = p->object.flags; parents = parents->next; if ((this_flag & flags) == flags) continue; if (!p->object.parsed) parse_commit(p); if (mark_seen(p, seen_p) && !still_interesting) extra--; p->object.flags |= flags; commit_list_insert_by_date(p, list_p); } } /* * Postprocess to complete well-poisoning. * * At this point we have all the commits we have seen in * seen_p list. Mark anything that can be reached from * uninteresting commits not interesting. */ for (;;) { int changed = 0; struct commit_list *s; for (s = *seen_p; s; s = s->next) { struct commit *c = s->item; struct commit_list *parents; if (((c->object.flags & all_revs) != all_revs) && !(c->object.flags & UNINTERESTING)) continue; /* The current commit is either a merge base or * already uninteresting one. Mark its parents * as uninteresting commits _only_ if they are * already parsed. No reason to find new ones * here. */ parents = c->parents; while (parents) { struct commit *p = parents->item; parents = parents->next; if (!(p->object.flags & UNINTERESTING)) { p->object.flags |= UNINTERESTING; changed = 1; } } } if (!changed) break; } }
static int make_hunks(struct sline *sline, unsigned long cnt, int num_parent, int dense) { unsigned long all_mask = (1UL<<num_parent) - 1; unsigned long mark = (1UL<<num_parent); unsigned long i; int has_interesting = 0; for (i = 0; i <= cnt; i++) { if (interesting(&sline[i], all_mask)) sline[i].flag |= mark; else sline[i].flag &= ~mark; } if (!dense) return give_context(sline, cnt, num_parent); /* Look at each hunk, and if we have changes from only one * parent, or the changes are the same from all but one * parent, mark that uninteresting. */ i = 0; while (i <= cnt) { unsigned long j, hunk_begin, hunk_end; unsigned long same_diff; while (i <= cnt && !(sline[i].flag & mark)) i++; if (cnt < i) break; /* No more interesting hunks */ hunk_begin = i; for (j = i + 1; j <= cnt; j++) { if (!(sline[j].flag & mark)) { /* Look beyond the end to see if there * is an interesting line after this * hunk within context span. */ unsigned long la; /* lookahead */ int contin = 0; la = adjust_hunk_tail(sline, all_mask, hunk_begin, j); la = (la + context < cnt + 1) ? (la + context) : cnt + 1; while (j <= --la) { if (sline[la].flag & mark) { contin = 1; break; } } if (!contin) break; j = la; } } hunk_end = j; /* [i..hunk_end) are interesting. Now is it really * interesting? We check if there are only two versions * and the result matches one of them. That is, we look * at: * (+) line, which records lines added to which parents; * this line appears in the result. * (-) line, which records from what parents the line * was removed; this line does not appear in the result. * then check the set of parents the result has difference * from, from all lines. If there are lines that has * different set of parents that the result has differences * from, that means we have more than two versions. * * Even when we have only two versions, if the result does * not match any of the parents, the it should be considered * interesting. In such a case, we would have all '+' line. * After passing the above "two versions" test, that would * appear as "the same set of parents" to be "all parents". */ same_diff = 0; has_interesting = 0; for (j = i; j < hunk_end && !has_interesting; j++) { unsigned long this_diff = sline[j].flag & all_mask; struct lline *ll = sline[j].lost_head; if (this_diff) { /* This has some changes. Is it the * same as others? */ if (!same_diff) same_diff = this_diff; else if (same_diff != this_diff) { has_interesting = 1; break; } } while (ll && !has_interesting) { /* Lost this line from these parents; * who are they? Are they the same? */ this_diff = ll->parent_map; if (!same_diff) same_diff = this_diff; else if (same_diff != this_diff) { has_interesting = 1; } ll = ll->next; } } if (!has_interesting && same_diff != all_mask) { /* This hunk is not that interesting after all */ for (j = hunk_begin; j < hunk_end; j++) sline[j].flag &= ~mark; } i = hunk_end; } has_interesting = give_context(sline, cnt, num_parent); return has_interesting; }
Ref<Mesh> MeshReader::read(const String& name, const Path& path) { std::ifstream stream(path.name().c_str(), std::ios::in | std::ios::binary); if (stream.fail()) { logError("Failed to open mesh %s", name.c_str()); return nullptr; } String line; uint lineNumber = 0; std::vector<vec3> positions; std::vector<vec3> normals; std::vector<vec2> texcoords; std::vector<Triplet> triplets; std::vector<FaceGroup> groups; FaceGroup* group = nullptr; while (std::getline(stream, line)) { const char* text = line.c_str(); ++lineNumber; if (!interesting(&text)) continue; try { String command = parseName(&text); if (command == "g") { // Silently ignore group names } else if (command == "o") { // Silently ignore object names } else if (command == "s") { // Silently ignore smoothing } else if (command == "v") { vec3 vertex; vertex.x = parseFloat(&text); vertex.y = parseFloat(&text); vertex.z = parseFloat(&text); positions.push_back(vertex); } else if (command == "vt") { vec2 texcoord; texcoord.x = parseFloat(&text); texcoord.y = parseFloat(&text); texcoords.push_back(texcoord); } else if (command == "vn") { vec3 normal; normal.x = parseFloat(&text); normal.y = parseFloat(&text); normal.z = parseFloat(&text); normals.push_back(normalize(normal)); } else if (command == "usemtl") { String materialName = parseName(&text); group = nullptr; for (auto& g : groups) { if (g.name == materialName) group = &g; } if (!group) { groups.push_back(FaceGroup()); groups.back().name = materialName; group = &(groups.back()); } } else if (command == "mtllib") { // Silently ignore .mtl material files } else if (command == "f") { if (!group) throw Exception("Expected \'usemtl\' before \'f\'"); triplets.clear(); while (*text != '\0') { triplets.push_back(Triplet()); Triplet& triplet = triplets.back(); triplet.vertex = parseInteger(&text); triplet.texcoord = 0; triplet.normal = 0; if (*text == '/') { if (std::isdigit(*(++text))) triplet.texcoord = parseInteger(&text); if (*text == '/') { if (std::isdigit(*(++text))) triplet.normal = parseInteger(&text); } } while (std::isspace(*text)) text++; } for (size_t i = 2; i < triplets.size(); i++) { group->faces.push_back(Face()); Face& face = group->faces.back(); face.p[0] = triplets[0]; face.p[1] = triplets[i - 1]; face.p[2] = triplets[i]; } } else { logWarning("Unknown command %s in mesh %s line %d", command.c_str(), name.c_str(), lineNumber); } } catch (Exception& e) { logError("%s in mesh %s line %d", e.what(), name.c_str(), lineNumber); return nullptr; } } Ref<Mesh> mesh = new Mesh(ResourceInfo(cache, name, path)); mesh->vertices.resize(positions.size()); for (size_t i = 0; i < positions.size(); i++) mesh->vertices[i].position = positions[i]; VertexTool tool(mesh->vertices); for (auto& g : groups) { mesh->sections.push_back(MeshSection()); MeshSection& geometry = mesh->sections.back(); const FaceList& faces = g.faces; geometry.materialName = g.name; geometry.triangles.resize(faces.size()); for (size_t i = 0; i < faces.size(); i++) { const Face& face = faces[i]; MeshTriangle& triangle = geometry.triangles[i]; for (size_t j = 0; j < 3; j++) { const Triplet& point = face.p[j]; vec3 normal; if (point.normal) normal = normals[point.normal - 1]; vec2 texcoord; if (point.texcoord) texcoord = texcoords[point.texcoord - 1]; triangle.indices[j] = tool.addAttributeLayer(point.vertex - 1, normal, texcoord); } } } tool.realizeVertices(mesh->vertices); return mesh; }